#NEWLINE# def collect( self ) : #NEWLINE# #INDENT# if ( vms is None ) : #NEWLINE# #INDENT# self . log . error ( 'Unable to import vms' ) #NEWLINE# return { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# #UNINDENT# vms . virt . init ( ) #NEWLINE# hypervisor = vms . virt . AUTO . Hypervisor ( ) #NEWLINE# domains = hypervisor . domain_list ( ) #NEWLINE# vms_domains = [ ] #NEWLINE# count = 0 #NEWLINE# for d in domains : #NEWLINE# #INDENT# if ( not vms . control . exists ( d ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# dom = hypervisor . domain_lookup ( d ) #NEWLINE# if ( dom is None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# ctrl = dom . _wait_for_control ( wait = False ) #NEWLINE# if ( ctrl is None ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# try : #NEWLINE# #INDENT# if ( ctrl . get ( 'gd.isghost' ) == '1' ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# #UNINDENT# except vms . control . ControlException : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# vms_domains . append ( ( dom , ctrl ) ) #NEWLINE# count += 1 #NEWLINE# #UNINDENT# self . publish ( 'domains' , count ) #NEWLINE# for stat in self . PLUGIN_STATS : #NEWLINE# #INDENT# key = self . PLUGIN_STATS [ stat ] [ 0 ] #NEWLINE# scale = self . PLUGIN_STATS [ stat ] [ 1 ] #NEWLINE# total = 0 #NEWLINE# for ( dom , ctrl ) in vms_domains : #NEWLINE# #INDENT# try : #NEWLINE# #INDENT# value = ( long ( ctrl . get ( key ) ) * scale ) #NEWLINE# #UNINDENT# except vms . control . ControlException : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# self . publish ( stat , value , instance = dom . name ( ) ) #NEWLINE# total = ( total + value ) #NEWLINE# #UNINDENT# self . publish ( stat , total )