Commit 78659913 authored by Antoine Millet's avatar Antoine Millet

Implemented title edition

parent 0b1ba886
......@@ -342,34 +342,6 @@ class Handler(HostHandler):
logger.error(msg)
raise UndefinedDomain(msg)
@libvirt_handler
def vm_reset(self, name):
logger.debug('VM reset %s', name)
try:
self.hypervisor.domains[name].reset()
except libvirt.libvirtError:
logger.exception('Error while resetting VM %s', name)
raise
except KeyError:
msg = 'Cannot reset VM %s because it is not defined' % name
logger.error(msg)
raise UndefinedDomain(msg)
@libvirt_handler
def vm_cycle(self, name):
logger.debug('VM cycle %s', name)
try:
self.hypervisor.domains[name].destroy()
time.sleep(1)
self.hypervisor.domains[name].start()
except libvirt.libvirtError:
logger.exception('Error while cycle VM %s', name)
raise
except KeyError:
msg = 'Cannot cycle VM %s because it is not defined' % name
logger.error(msg)
raise UndefinedDomain(msg)
@libvirt_handler
def vm_change_title(self, name, new_title):
logger.debug('VM edit title %s', name)
......
......@@ -61,14 +61,6 @@ class VirtualMachine(object):
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
......@@ -125,6 +117,25 @@ class VirtualMachine(object):
self.tag_db['__main__']['vncport'].update_value()
self.sync_description_tags()
@property
def title(self):
try:
return self.lv_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
return None
@title.setter
def title(self, value):
try:
self.lv_dom.setMetadata(libvirt.VIR_DOMAIN_METADATA_TITLE, value, None, None)
except AttributeError:
raise NotImplementedError('This hv doesn\'t handle VM titles')
else:
self.tag_db['__main__']['t'].update_value()
@property
def description(self):
xml = self.lv_dom.XMLDesc(libvirt.VIR_DOMAIN_XML_INACTIVE)
......
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