コード例 #1
0
    def _start_pending_tasks(self, ctxt, execution, parent_task, task_info):
        origin = self._get_task_origin(ctxt, execution.action)
        destination = self._get_task_destination(ctxt, execution.action)

        for task in execution.tasks:
            if task.status == constants.TASK_STATUS_PENDING:
                if task.depends_on and parent_task.id in task.depends_on:
                    start_task = True
                    for depend_task_id in task.depends_on:
                        if depend_task_id != parent_task.id:
                            depend_task = db_api.get_task(ctxt, depend_task_id)
                            if (depend_task.status !=
                                    constants.TASK_STATUS_COMPLETED):
                                start_task = False
                                break
                    if start_task:
                        # instance imports need to be executed on the same host
                        server = None
                        if (task.task_type ==
                                constants.TASK_TYPE_IMPORT_INSTANCE):
                            server = parent_task.host

                        self._rpc_worker_client.begin_task(
                            ctxt,
                            server=server,
                            task_id=task.id,
                            task_type=task.task_type,
                            origin=origin,
                            destination=destination,
                            instance=task.instance,
                            task_info=task_info)
コード例 #2
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)
        execution = db_api.get_tasks_execution(ctxt, task.execution_id)

        with lockutils.lock(execution.action_id):
            self._cancel_tasks_execution(ctxt, execution)
コード例 #3
0
ファイル: server.py プロジェクト: paperandsoap/coriolis
    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)
コード例 #4
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)
        execution = db_api.get_tasks_execution(ctxt, task.execution_id)

        action_id = execution.action_id
        with lockutils.lock(action_id):
            LOG.info(
                "Setting instance %(instance)s "
                "action info: %(task_info)s", {
                    "instance": task.instance,
                    "task_info": task_info
                })
            updated_task_info = db_api.set_transfer_action_info(
                ctxt, action_id, task.instance, task_info)

            self._handle_post_task_actions(ctxt, task, execution,
                                           updated_task_info)

            if execution.status == constants.EXECUTION_STATUS_RUNNING:
                self._start_pending_tasks(ctxt, execution, task,
                                          updated_task_info)

                if not [
                        t for t in execution.tasks if t.status in [
                            constants.TASK_STATUS_RUNNING,
                            constants.TASK_STATUS_PENDING
                        ]
                ]:
                    # The execution is in error status if there's one or more
                    # tasks in error or canceled status
                    if [
                            t for t in execution.tasks if t.status in [
                                constants.TASK_STATUS_ERROR,
                                constants.TASK_STATUS_CANCELED
                            ]
                    ]:
                        execution_status = constants.EXECUTION_STATUS_ERROR
                    else:
                        execution_status = constants.EXECUTION_STATUS_COMPLETED

                    self._set_tasks_execution_status(ctxt, execution.id,
                                                     execution_status)
コード例 #5
0
ファイル: server.py プロジェクト: cloudbase/coriolis
    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)
コード例 #6
0
ファイル: server.py プロジェクト: cloudbase/coriolis
    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)
コード例 #7
0
ファイル: server.py プロジェクト: paperandsoap/coriolis
    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)