Hi Luiz,
The VIF_metrics is a separate object from the VIF itself – my perl is not very good, but in python I’d do something like this:
vms = session.xenapi.VM.get_all()
for vm in vms:
vm_record = session.xenapi.VM.get_record(vm)
if record[“is_a_template”] == False and record[“is_control_domain”] == False:
for vif in vm_record[“VIFs”]:
metrics = session.xenapi.VIF.get_metrics(vif)
if metrics != “OpaqueRef:NULL”:
metrics_record = session.xenapi.VIF_metrics.get_record(metrics)
# do something with metrics_record…
John
From: xen-api-bounces@xxxxxxxxxxxxx [mailto:xen-api-bounces@xxxxxxxxxxxxx] On Behalf Of Luiz Roberto
Sent: 25 June 2012 16:02
To: xen-api@xxxxxxxxxxxxx
Subject: [Xen-API] Error with VIF_METRICS
Hello everybody,
I need to get VIF_metrics from a specific VM and I got a problem while trying to do that.
(HANDLE_INVALID VIF_metrics OpaqueRef:f71830ff-301b-77a8-37e9-f4c4aaa2905b)
It is very strange, I never got this error before.
Take a look on my code:
$vms_array = $xenserver->VM_get_all();
foreach ($vms_array as $vm) {
$record = $xenserver->VM_get_record($vm);
if($record['is_a_template']==false && $record['is_control_domain']==false) {
var_dump($record['VIFs']); //Return : 0 => string 'OpaqueRef:f71830ff-301b-77a8-37e9-f4c4aaa2905b' (length=46)
foreach($record['VIFs'] as $vif) {
$metrics = $xenserver->__call('VIF_metrics.get_record',array($vif) ));
var_dump($metrics);
}
}
}
I tried many values as parameter but no success...
Anybody here knows what is this problem?
Thanks