def __init__(self, cpu_filename=None):
        self.archmap = {}
        if not cpu_filename:
            cpu_filename = "/usr/share/libvirt/cpu_map.xml"
        xml = file(cpu_filename).read()

        _util.parse_node_helper(xml, "cpus",
                                self._parseXML,
                                CapabilitiesParserException)
    def __init__(self, cpu_filename=None):
        self.archmap = {}
        if not cpu_filename:
            cpu_filename = "/usr/share/libvirt/cpu_map.xml"
        xml = file(cpu_filename).read()

        _util.parse_node_helper(xml, "cpus",
                                self._parseXML,
                                CapabilitiesParserException)
示例#3
0
def _parse_pool_source_list(source_xml):
    def source_parser(node):
        ret_list = []

        child = node.children
        while child:
            if child.name == "source":
                val_dict = {}
                source = child.children

                while source:
                    if source.name == "name":
                        val_dict["source_name"] = source.content
                    elif source.name == "host":
                        val_dict["host"] = source.prop("name")
                    elif source.name == "format":
                        val_dict["format"] = source.prop("type")
                    elif source.name in ["device", "dir"]:
                        val_dict["source_path"] = source.prop("path")
                    source = source.next

                ret_list.append(val_dict)

            child = child.next

        for val_dict in ret_list:
            if (val_dict.get("format") == "lvm2" and
                val_dict.get("source_name") and
                not val_dict.get("target_path")):
                val_dict["target_path"] = (DEFAULT_LVM_TARGET_BASE +
                                           val_dict["source_name"])

        return ret_list

    return _util.parse_node_helper(source_xml, "sources", source_parser)
示例#4
0
def _parse_pool_source_list(source_xml):
    def source_parser(node):
        ret_list = []

        child = node.children
        while child:
            if child.name == "source":
                val_dict = {}
                source = child.children

                while source:
                    if source.name == "name":
                        val_dict["source_name"] = source.content
                    elif source.name == "host":
                        val_dict["host"] = source.prop("name")
                    elif source.name == "format":
                        val_dict["format"] = source.prop("type")
                    elif source.name in ["device", "dir"]:
                        val_dict["source_path"] = source.prop("path")
                    source = source.next

                ret_list.append(val_dict)

            child = child.next

        for val_dict in ret_list:
            if (val_dict.get("format") == "lvm2" and
                val_dict.get("source_name") and
                not val_dict.get("target_path")):
                val_dict["target_path"] = (DEFAULT_LVM_TARGET_BASE +
                                           val_dict["source_name"])

        return ret_list

    return _util.parse_node_helper(source_xml, "sources", source_parser)
示例#5
0
def parse(xml):
    """
    Convert the passed libvirt node device xml into a NodeDevice object

    @param xml: libvirt node device xml
    @type xml: C{str}

    @returns: L{NodeDevice} instance
    """
    def _parse_func(root):
        t = _findNodeType(root)
        devclass = _typeToDeviceClass(t)
        device = devclass(root)
        return device

    return _util.parse_node_helper(xml, "device", _parse_func)
def parse(xml):
    """
    Convert the passed libvirt node device xml into a NodeDevice object

    @param xml: libvirt node device xml
    @type xml: C{str}

    @returns: L{NodeDevice} instance
    """
    def _parse_func(root):
        t = _findNodeType(root)
        devclass = _typeToDeviceClass(t)
        device = devclass(root)
        return device

    return _util.parse_node_helper(xml, "device", _parse_func)
def parse(xml):
    return _util.parse_node_helper(xml, "capabilities",
                                   Capabilities,
                                   CapabilitiesParserException)
def parse(xml):
    return _util.parse_node_helper(xml, "capabilities",
                                   Capabilities,
                                   CapabilitiesParserException)