def load_xml_config(self,string):

        doc = XMLParse(string)
        xpath_prefix = "/capabilities"

        ###################
        # host section
        host_xpath = "%s/host" % xpath_prefix
        host = {}

        # host - cpu section
        host_cpu_xpath = "%s/cpu" % host_xpath
        cpu = {}
        cpu['arch']  = XMLXpath(doc, '%s/arch/text()'  % host_cpu_xpath)
        cpu['model'] = XMLXpath(doc, '%s/model/text()' % host_cpu_xpath)
        topology = {}
        topology['sockets'] = XMLXpath(doc, '%s/topology/@sockets' % host_cpu_xpath)
        topology['cores']   = XMLXpath(doc, '%s/topology/@cores'   % host_cpu_xpath)
        topology['threads'] = XMLXpath(doc, '%s/topology/@threads' % host_cpu_xpath)
        cpu['topology'] = topology

        features = {}
        feature = []
        feature_num = XMLXpathNum(doc, '%s/feature' % host_cpu_xpath)
        for n in range(1, feature_num + 1):
            name = XMLXpath(doc, '%s/feature[%i]/@name' % (host_cpu_xpath, n,))
            feature.append(name)
        vmx = XMLXpath(doc, '%s/features/vmx' % host_cpu_xpath)
        features['feature'] = feature
        features['vmx'] = vmx
        cpu['feature'] = features

        host['cpu'] = cpu

        # host - migration_features section
        host_migration_features_xpath = "%s/migration_features" % host_xpath
        migration_features = {}

        uri_transports = []
        uri_transport_num = XMLXpathNum(doc,'%s/uri_transports/uri_transport' % host_migration_features_xpath)
        for n in range(1, uri_transport_num + 1):
            uri_transport = XMLXpath(doc,'%s/uri_transports/uri_transport/text()' % host_migration_features_xpath)
            uri_transports.append(uri_transport)
        live = XMLXpath(doc, '%s/live' % host_migration_features_xpath)
        migration_features['uri_transports'] = uri_transports
        migration_features['live'] = live

        host['migration_features'] = migration_features

        ###################
        # guest section
        guest_xpath = "%s/guest" % xpath_prefix
        guests = []

        guest_num = XMLXpathNum(doc,'%s' % guest_xpath)
        for n in range(1, guest_num + 1):
            guest = {}

            os_type  = XMLXpath(doc, '%s[%i]/os_type/text()' % (guest_xpath,n,))

            arch = {}
            name     = XMLXpath(doc, '%s[%i]/arch/@name'           % (guest_xpath,n,))
            wordsize = XMLXpath(doc, '%s[%i]/arch/wordsize/text()' % (guest_xpath,n,))
            emulator = XMLXpath(doc, '%s[%i]/arch/emulator/text()' % (guest_xpath,n,))
            machines = []
            machine_num = XMLXpathNum(doc, '%s[%i]/arch/machine'      % (guest_xpath,n,))
            for m in range(1, machine_num + 1):
                machine = XMLXpath(doc, '%s[%i]/arch/machine[%i]/text()'  % (guest_xpath,n,m,))
                machines.append(machine)
            domain = {}
            type = XMLXpath(doc, '%s[%i]/arch/domain/@type'        % (guest_xpath,n,))
            domain['type'] = type
            arch['name'] = name
            arch['wordsize'] = wordsize
            arch['emulator'] = emulator
            arch['machine']  = machines
            arch['domain']   = domain

            features = {}
            cpuselection  = XMLXpath(doc, '%s[%i]/features/cpuselection' % (guest_xpath,n,))
            pae      = XMLXpath(doc, '%s[%i]/features/pae'           % (guest_xpath,n,))
            nonpae   = XMLXpath(doc, '%s[%i]/features/nonpae'        % (guest_xpath,n,))
            acpi = {}
            default  = XMLXpath(doc, '%s[%i]/features/acpi/@default' % (guest_xpath,n,))
            toggle   = XMLXpath(doc, '%s[%i]/features/acpi/@toggle'  % (guest_xpath,n,))
            acpi['default'] = default
            acpi['toggle']  = toggle
            apic = {}
            default  = XMLXpath(doc, '%s[%i]/features/apic/@default' % (guest_xpath,n,))
            toggle   = XMLXpath(doc, '%s[%i]/features/apic/@toggle'  % (guest_xpath,n,))
            apic['default'] = default
            apic['toggle']  = toggle
            features['acpi'] = acpi
            features['apic'] = apic

            guest['os_type']  = os_type
            guest['arch']     = arch
            guest['features'] = features
            guests.append(guest)

        self.host  = host
        self.guest = guests

        return { "host" :self.host, "guest":self.guest }
dataset/ETHPy150Open karesansui/karesansui/karesansui/lib/virt/config_capabilities.py/CapabilitiesConfigParam.load_xml_config/original