diff --git a/cloudcontrol/node/hypervisor/__init__.py b/cloudcontrol/node/hypervisor/__init__.py index a1a615e94ff45e5304bc888ac92e7303750aa9f2..1a7422d59056cbdd325377708df05fcfcbba68f1 100644 --- a/cloudcontrol/node/hypervisor/__init__.py +++ b/cloudcontrol/node/hypervisor/__init__.py @@ -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) diff --git a/cloudcontrol/node/hypervisor/domains/__init__.py b/cloudcontrol/node/hypervisor/domains/__init__.py index 4ce4af5b4dfd25afa3582cf8660f39ed92249780..9f814d9ec6e3c32220ac626905143894990173c9 100644 --- a/cloudcontrol/node/hypervisor/domains/__init__.py +++ b/cloudcontrol/node/hypervisor/domains/__init__.py @@ -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)