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

Implemented titles on VMs

parent aaf181f3
......@@ -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
......
......@@ -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."""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment