def revert(self, *args, **kwargs): LOG.warning(_LW("Revert action: %s"), self.name) try: self.action.revert() except Exception as e: LOG.exception(e) LOG.critical(_LC("Oops! We need a disaster recover plan."))
def _live_migrate_instance(self, nova, destination): result = None try: result = nova.live_migrate_instance(instance_id=self.instance_uuid, dest_hostname=destination) except nova_helper.nvexceptions.ClientException as e: if e.code == 400: LOG.debug("Live migration of instance %s failed. " "Trying to live migrate using block migration." % self.instance_uuid) result = nova.live_migrate_instance( instance_id=self.instance_uuid, dest_hostname=destination, block_migration=True) else: LOG.debug("Nova client exception occurred while live " "migrating instance %s.Exception: %s" % (self.instance_uuid, e)) except Exception: LOG.critical( _LC("Unexpected error occurred. Migration failed for " "instance %s. Leaving instance on previous " "host."), self.instance_uuid) return result
def revert(self, *args, **kwargs): LOG.warning(_LW("Revert action: %s"), self.name) try: # TODO(jed): do we need to update the states in case of failure? self.action.revert() except Exception as e: LOG.exception(e) LOG.critical(_LC("Oops! We need a disaster recover plan."))
def _cold_migrate_instance(self, nova, destination): result = None try: result = nova.watcher_non_live_migrate_instance( instance_id=self.instance_uuid, dest_hostname=destination) except Exception as exc: LOG.exception(exc) LOG.critical(_LC("Unexpected error occurred. Migration failed for " "instance %s. Leaving instance on previous " "host."), self.instance_uuid) return result
def _cold_migrate_instance(self, nova, destination): result = None try: result = nova.watcher_non_live_migrate_instance( instance_id=self.instance_uuid, dest_hostname=destination) except Exception as exc: LOG.exception(exc) LOG.critical( _LC("Unexpected error occurred. Migration failed for " "instance %s. Leaving instance on previous " "host."), self.instance_uuid) return result
def resize(self): nova = nova_helper.NovaHelper(osc=self.osc) LOG.debug("Resize instance %s to %s flavor", self.instance_uuid, self.flavor) instance = nova.find_instance(self.instance_uuid) result = None if instance: try: result = nova.resize_instance(instance_id=self.instance_uuid, flavor=self.flavor) except Exception as exc: LOG.exception(exc) LOG.critical( _LC("Unexpected error occurred. Resizing failed for " "instance %s."), self.instance_uuid) return result
def _live_migrate_instance(self, nova, destination): result = None try: result = nova.live_migrate_instance(instance_id=self.instance_uuid, dest_hostname=destination) except nova_helper.nvexceptions.ClientException as e: if e.code == 400: LOG.debug("Live migration of instance %s failed. " "Trying to live migrate using block migration." % self.instance_uuid) result = nova.live_migrate_instance( instance_id=self.instance_uuid, dest_hostname=destination, block_migration=True) else: LOG.debug("Nova client exception occured while live migrating " "instance %s.Exception: %s" % (self.instance_uuid, e)) except Exception: LOG.critical(_LC("Unexpected error occured. Migration failed for" "instance %s. Leaving instance on previous " "host."), self.instance_uuid) return result