def vm_state(vm_=None):
 with _get_xapi_session() as xapi:
  info = {}
  if vm_:
   info[vm_] = _get_record_by_label(xapi, 'VM', vm_)['power_state']
   return info
  for vm_ in list_domains():
   info[vm_] = _get_record_by_label(xapi, 'VM', vm_)['power_state']
  return info

def vm_state ( vm_ = None ) : with _get_xapi_session ( ) as xapi : info = { } if vm_ : info [ vm_ ] = _get_record_by_label ( xapi , 'VM' , vm_ ) [ 'power_state' ] return info for vm_ in list_domains ( ) : info [ vm_ ] = _get_record_by_label ( xapi , 'VM' , vm_ ) [ 'power_state' ] return info
return list of all the vms and their state .