Example #1
0
    def cancel_migration(self, ctxt, migration_id):
        migration = self._get_migration(ctxt, migration_id)
        if migration.status != constants.MIGRATION_STATUS_RUNNING:
            raise exception.InvalidMigrationState(
                "The migration is not running")

        for task in migration.tasks:
            if task.status in [constants.TASK_STATUS_PENDING,
                               constants.TASK_STATUS_RUNNING]:
                if task.status == constants.TASK_STATUS_RUNNING:
                    self._rpc_worker_client.cancel_task(
                        ctxt, task.host, task.process_id)
                db_api.set_task_status(
                    ctxt, task.id, constants.TASK_STATUS_CANCELED)

        db_api.set_migration_status(
            ctxt, migration_id, constants.MIGRATION_STATUS_ERROR)
Example #2
0
    def task_completed(self, ctxt, task_id, task_info):
        LOG.info("Task completed: %s", task_id)

        db_api.set_task_status(
            ctxt, task_id, constants.TASK_STATUS_COMPLETED)

        task = db_api.get_task(
            ctxt, task_id, include_migration_tasks=True)

        migration = task.migration
        has_pending_tasks = self._start_pending_tasks(ctxt, migration, task,
                                                      task_info)

        if not has_pending_tasks:
            LOG.info("Migration completed: %s", migration.id)
            db_api.set_migration_status(
                ctxt, migration.id, constants.MIGRATION_STATUS_COMPLETED)
Example #3
0
    def set_task_error(self, ctxt, task_id, exception_details):
        LOG.error("Task error: %(task_id)s - %(ex)s",
                  {"task_id": task_id, "ex": exception_details})

        db_api.set_task_status(
            ctxt, task_id, constants.TASK_STATUS_ERROR, exception_details)

        task = db_api.get_task(
            ctxt, task_id, include_migration_tasks=True)
        migration = task.migration

        for task in migration.tasks:
            if task.status == constants.TASK_STATUS_PENDING:
                db_api.set_task_status(
                    ctxt, task.id, constants.TASK_STATUS_CANCELED)

        LOG.error("Migration failed: %s", migration.id)
        db_api.set_migration_status(
            ctxt, migration.id, constants.MIGRATION_STATUS_ERROR)
Example #4
0
    def cancel_migration(self, ctxt, migration_id):
        migration = self._get_migration(ctxt, migration_id)
        if migration.status != constants.MIGRATION_STATUS_RUNNING:
            raise exception.InvalidParameterValue(
                "The migration is not running: %s" % migration_id)

        has_running_tasks = False
        for task in migration.tasks:
            if task.status == constants.TASK_STATUS_RUNNING:
                self._rpc_worker_client.cancel_task(
                    ctxt, task.host, task.process_id)
                has_running_tasks = True
            elif task.status == constants.TASK_STATUS_PENDING:
                db_api.set_task_status(
                    ctxt, task.id, constants.TASK_STATUS_CANCELED)

        if not has_running_tasks:
            db_api.set_migration_status(
                ctxt, migration_id, constants.MIGRATION_STATUS_ERROR)