<s> """<STR_LIT>""" <EOL> import os <EOL> import time <EOL> from StringIO import StringIO <EOL> import errno <EOL> import karesansui <EOL> from karesansui . lib . utils import get_xml_xpath as XMLXpath , get_nums_xml_xpath as XMLXpathNum , get_xml_parse as XMLParse , r_chgrp , r_chmod , preprint_r <EOL> class KaresasnuiCapabilitiesConfigParamException ( karesansui . KaresansuiLibException ) : <EOL> pass <EOL> class CapabilitiesConfigParam : <EOL> def __init__ ( self ) : <EOL> self . host = { } <EOL> self . guest = [ ] <EOL> def get_host_cpu_arch ( self ) : <EOL> try : <EOL> return self . host [ '<STR_LIT>' ] [ '<STR_LIT>' ] <EOL> except : <EOL> return None <EOL> def load_xml_config ( self , string ) : <EOL> doc = XMLParse ( string ) <EOL> xpath_prefix = "<STR_LIT>" <EOL> host_xpath = "<STR_LIT>" % xpath_prefix <EOL> host = { } <EOL> host_cpu_xpath = "<STR_LIT>" % host_xpath <EOL> cpu = { } <EOL> cpu [ '<STR_LIT>' ] = XMLXpath ( doc , '<STR_LIT>' % host_cpu_xpath ) <EOL> cpu [ '<STR_LIT>' ] = XMLXpath ( doc , '<STR_LIT>' % host_cpu_xpath ) <EOL> topology = { } <EOL> topology [ '<STR_LIT>' ] = XMLXpath ( doc , '<STR_LIT>' % host_cpu_xpath ) <EOL> topology [ '<STR_LIT>' ] = XMLXpath ( doc , '<STR_LIT>' % host_cpu_xpath ) <EOL> topology [ '<STR_LIT>' ] = XMLXpath ( doc , '<STR_LIT>' % host_cpu_xpath ) <EOL> cpu [ '<STR_LIT>' ] = topology <EOL> features = { } <EOL> feature = [ ] <EOL> feature_num = XMLXpathNum ( doc , '<STR_LIT>' % host_cpu_xpath ) <EOL> for n in range ( <NUM_LIT:1> , feature_num + <NUM_LIT:1> ) : <EOL> name = XMLXpath ( doc , '<STR_LIT>' % ( host_cpu_xpath , n , ) ) <EOL> feature . append ( name ) <EOL> vmx = XMLXpath ( doc , '<STR_LIT>' % host_cpu_xpath ) <EOL> features [ '<STR_LIT>' ] = feature <EOL> features [ '<STR_LIT>' ] = vmx <EOL> cpu [ '<STR_LIT>' ] = features <EOL> host [ '<STR_LIT>' ] = cpu <EOL> host_migration_features_xpath = "<STR_LIT>" % host_xpath <EOL> migration_features = { } <EOL> uri_transports = [ ] <EOL> uri_transport_num = XMLXpathNum ( doc , '<STR_LIT>' % host_migration_features_xpath ) <EOL> for n in range ( <NUM_LIT:1> , uri_transport_num + <NUM_LIT:1> ) : <EOL> uri_transport = XMLXpath ( doc , '<STR_LIT>' % host_migration_features_xpath ) <EOL> uri_transports . append ( uri_transport ) <EOL> live = XMLXpath ( doc , '<STR_LIT>' % host_migration_features_xpath ) <EOL> migration_features [ '<STR_LIT>' ] = uri_transports <EOL> migration_features [ '<STR_LIT>' ] = live <EOL> host [ '<STR_LIT>' ] = migration_features <EOL> guest_xpath = "<STR_LIT>" % xpath_prefix <EOL> guests = [ ] <EOL> guest_num = XMLXpathNum ( doc , '<STR_LIT:%s>' % guest_xpath ) <EOL> for n in range ( <NUM_LIT:1> , guest_num + <NUM_LIT:1> ) : <EOL> guest = { } <EOL> os_type = XMLXpath ( doc , '<STR_LIT>' % ( guest_xpath , n , ) ) <EOL> arch = { } <EOL> name = XMLXpath ( doc , '<STR_LIT>' % ( guest_xpath , n , ) ) <EOL> wordsize = XMLXpath ( doc , '<STR_LIT>' % ( guest_xpath , n , ) ) <EOL> emulator = XMLXpath ( doc , '<STR_LIT>' % ( guest_xpath , n , ) ) <EOL> machines = [ ] <EOL> machine_num = XMLXpathNum ( doc , '<STR_LIT>' % ( guest_xpath , n , ) ) <EOL> for m in range ( <NUM_LIT:1> , machine_num + <NUM_LIT:1> ) : <EOL> machine = XMLXpath ( doc , '<STR_LIT>' % ( guest_xpath , n , m , ) ) <EOL> machines . append ( machine ) <EOL> domain = { } <EOL> type = XMLXpath ( doc , '<STR_LIT>' % ( guest_xpath , n , ) ) <EOL> domain [ '<STR_LIT:type>' ] = type <EOL> arch [ '<STR_LIT:name>' ] = name <EOL> arch [ '<STR_LIT>' ] = wordsize <EOL> arch [ '<STR_LIT>' ] = emulator <EOL> arch [ '<STR_LIT>' ] = machines <EOL> arch [ '<STR_LIT>' ] = domain <EOL> features = { } <EOL> cpuselection = XMLXpath ( doc , '<STR_LIT>' % ( guest_xpath , n , ) ) <EOL> pae = XMLXpath ( doc , '<STR_LIT>' % ( guest_xpath , n , ) ) <EOL> nonpae = XMLXpath ( doc , '<STR_LIT>' % ( guest_xpath , n , ) ) <EOL> acpi = { } <EOL> default = XMLXpath ( doc , '<STR_LIT>' % ( guest_xpath , n , ) ) <EOL> toggle = XMLXpath ( doc , '<STR_LIT>' % ( guest_xpath , n , ) ) <EOL> acpi [ '<STR_LIT:default>' ] = default <EOL> acpi [ '<STR_LIT>' ] = toggle <EOL> apic = { } <EOL> default = XMLXpath ( doc , '<STR_LIT>' % ( guest_xpath , n , ) ) <EOL> toggle = XMLXpath ( doc , '<STR_LIT>' % ( guest_xpath , n , ) ) <EOL> apic [ '<STR_LIT:default>' ] = default <EOL> apic [ '<STR_LIT>' ] = toggle <EOL> features [ '<STR_LIT>' ] = acpi <EOL> features [ '<STR_LIT>' ] = apic <EOL> guest [ '<STR_LIT>' ] = os_type <EOL> guest [ '<STR_LIT>' ] = arch <EOL> guest [ '<STR_LIT>' ] = features <EOL> guests . append ( guest ) <EOL> self . host = host <EOL> self . guest = guests <EOL> return { "<STR_LIT:host>" : self . host , "<STR_LIT>" : self . guest } <EOL> def validate ( self ) : <EOL> pass <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> string = """<STR_LIT>""" <EOL> param = CapabilitiesConfigParam ( ) <EOL> param . load_xml_config ( string ) <EOL> preprint_r ( param . host ) <EOL> preprint_r ( param . guest ) </s>
