def vm_netstats(vm_=None):
 with _get_xapi_session() as xapi:
  def _info(vm_):
   ret = {}
   vm_rec = _get_record_by_label(xapi, 'VM', vm_)
   if (vm_rec is False):
    return False
   for vif in vm_rec['VIFs']:
    vif_rec = _get_record(xapi, 'VIF', vif)
    ret[vif_rec['device']] = _get_metrics_record(xapi, 'VIF', vif_rec)
    del ret[vif_rec['device']]['last_updated']
   return ret
  info = {}
  if vm_:
   info[vm_] = _info(vm_)
  else:
   for vm_ in list_domains():
    info[vm_] = _info(vm_)
  return info

def vm_netstats ( vm_ = None ) : with _get_xapi_session ( ) as xapi : def _info ( vm_ ) : ret = { } vm_rec = _get_record_by_label ( xapi , 'VM' , vm_ ) if ( vm_rec is False ) : return False for vif in vm_rec [ 'VIFs' ] : vif_rec = _get_record ( xapi , 'VIF' , vif ) ret [ vif_rec [ 'device' ] ] = _get_metrics_record ( xapi , 'VIF' , vif_rec ) del ret [ vif_rec [ 'device' ] ] [ 'last_updated' ] return ret info = { } if vm_ : info [ vm_ ] = _info ( vm_ ) else : for vm_ in list_domains ( ) : info [ vm_ ] = _info ( vm_ ) return info
return combined network counters used by the vms on this hyper in a list of dicts: .