Commit 4de1b5cb authored by Antoine Millet's avatar Antoine Millet
Browse files

Implemented titles on VMs

parent aaf181f3
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -61,6 +61,15 @@ class VirtualMachine(object):
        #: UUID string of domain
        self.uuid = dom.UUIDString()
        self.name = dom.name()

        # Get title of VM
        try:
            self.title = dom.metadata(libvirt.VIR_DOMAIN_METADATA_TITLE, None)
        except (libvirt.libvirtError, AttributeError):
            # libvirtError handle the case where the title is not defined on the
            # vm, AttributeError handle the case where the libvirt is too old
            # to allow metadata handling
            self.title = None
        #: state of VM: started, stoped, paused
        self._state = STATE[dom.info()[0]]
        #: tags for this VM
+8 −0
Original line number Diff line number Diff line
@@ -83,6 +83,14 @@ def h(dom):
    return dom.name


def t(dom):
    """Title of the VM (or name if title is not defined)."""
    if dom.title is None:
        return dom.name
    else:
        return dom.title


@_vir_tag
def cpu(dom):
    """Number of CPU of the VM."""