Ejemplo n.º 1
0
    def __init__(self):
        _CPUAPIValues.__init__(self)
        self.archmap = {}
        xml = file(self._cpu_filename).read()

        util.parse_node_helper(xml, "cpus",
                                self._parseXML,
                                RuntimeError)
Ejemplo n.º 2
0
    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,
                                RuntimeError)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    def __init__(self):
        _CPUAPIValues.__init__(self)
        self.archmap = {}
        cpu_filename = "/usr/share/libvirt/cpu_map.xml"
        xml = file(cpu_filename).read()

        util.parse_node_helper(xml, "cpus",
                                self._parseXML,
                                RuntimeError)
Ejemplo n.º 5
0
    def __init__(self, xml):
        self.host = None
        self.guests = []
        self.xml = xml
        self._topology = None
        self._cpu_values = None

        util.parse_node_helper(self.xml, "capabilities",
                               self.parseXML,
                               RuntimeError)
Ejemplo n.º 6
0
def parse(xml, filename):
    """Parse the XML description of a VM image into a data structure. Returns
    an object of class Image. BASE should be the directory where the disk
    image files for this image can be found"""
    def cb(x):
        return Image(x, filename=filename)
    return util.parse_node_helper(xml, "image", cb, RuntimeError)
Ejemplo n.º 7
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)
Ejemplo n.º 8
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)
Ejemplo n.º 9
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)
Ejemplo n.º 10
0
def parse(xml):
    return util.parse_node_helper(xml, "capabilities",
                                   Capabilities,
                                   CapabilitiesParserException)