예제 #1
0
 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."))
예제 #2
0
    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
예제 #3
0
 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."))
예제 #4
0
    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
예제 #5
0
    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
예제 #6
0
 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
예제 #7
0
    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