当前位置: 首页>>代码示例>>Python>>正文


Python TaskHelper.update_task_status方法代码示例

本文整理汇总了Python中nailgun.task.task.TaskHelper.update_task_status方法的典型用法代码示例。如果您正苦于以下问题:Python TaskHelper.update_task_status方法的具体用法?Python TaskHelper.update_task_status怎么用?Python TaskHelper.update_task_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nailgun.task.task.TaskHelper的用法示例。


在下文中一共展示了TaskHelper.update_task_status方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: execute

# 需要导入模块: from nailgun.task.task import TaskHelper [as 别名]
# 或者: from nailgun.task.task.TaskHelper import update_task_status [as 别名]
    def execute(self, data, check_admin_untagged=False):
        check_networks = db().query(Task).filter_by(
            cluster=self.cluster,
            name="check_networks"
        ).first()
        if check_networks:
            db().delete(check_networks)
            db().commit()

        task = Task(
            name="check_networks",
            cluster=self.cluster
        )
        db().add(task)
        db().commit()
        self._call_silently(
            task,
            tasks.CheckNetworksTask,
            data,
            check_admin_untagged
        )
        db().refresh(task)
        if task.status == 'running':
            TaskHelper.update_task_status(
                task.uuid,
                status="ready",
                progress=100
            )
        return task
开发者ID:MsiRgb,项目名称:fuel-web,代码行数:31,代码来源:manager.py

示例2: execute

# 需要导入模块: from nailgun.task.task import TaskHelper [as 别名]
# 或者: from nailgun.task.task.TaskHelper import update_task_status [as 别名]
 def execute(self, data, check_admin_untagged=False):
     task = Task(name="check_networks", cluster=self.cluster)
     db().add(task)
     db().commit()
     self._call_silently(task, tasks.CheckNetworksTask, data, check_admin_untagged)
     db().refresh(task)
     if task.status == "running":
         TaskHelper.update_task_status(task.uuid, status="ready", progress=100)
     return task
开发者ID:nfschina,项目名称:fuelweb,代码行数:11,代码来源:manager.py

示例3: _call_silently

# 需要导入模块: from nailgun.task.task import TaskHelper [as 别名]
# 或者: from nailgun.task.task.TaskHelper import update_task_status [as 别名]
 def _call_silently(self, task, instance, *args, **kwargs):
     method = getattr(instance, kwargs.pop("method_name", "execute"))
     if task.status == "error":
         return
     try:
         return method(task, *args, **kwargs)
     except Exception as exc:
         err = str(exc)
         if any([not hasattr(exc, "log_traceback"), hasattr(exc, "log_traceback") and exc.log_traceback]):
             logger.error(traceback.format_exc())
         TaskHelper.update_task_status(task.uuid, status="error", progress=100, msg=err)
开发者ID:nfschina,项目名称:fuelweb,代码行数:13,代码来源:manager.py

示例4: execute

# 需要导入模块: from nailgun.task.task import TaskHelper [as 别名]
# 或者: from nailgun.task.task.TaskHelper import update_task_status [as 别名]
    def execute(self):
        task = Task(
            name='check_before_deployment',
            cluster=self.cluster
        )
        db().add(task)
        db().commit()
        self._call_silently(task, tasks.CheckBeforeDeploymentTask)
        db().refresh(task)
        if task.status == 'running':
            TaskHelper.update_task_status(
                task.uuid, status="ready", progress=100)

        return task
开发者ID:99cloud-net,项目名称:fuelweb,代码行数:16,代码来源:manager.py

示例5: _redhat_messages

# 需要导入模块: from nailgun.task.task import TaskHelper [as 别名]
# 或者: from nailgun.task.task.TaskHelper import update_task_status [as 别名]
    def _redhat_messages(self, supertask, nodes_info):
        account = db().query(RedHatAccount).first()
        if not account:
            TaskHelper.update_task_status(supertask.uuid, status="error", progress=100, msg="RHEL account is not found")
            return supertask

        rhel_data = {
            "release_id": supertask.cluster.release.id,
            "release_name": supertask.cluster.release.name,
            "redhat": {
                "license_type": account.license_type,
                "username": account.username,
                "password": account.password,
                "satellite": account.satellite,
                "activation_key": account.activation_key,
            },
        }

        subtasks = [
            supertask.create_subtask("redhat_check_credentials"),
            supertask.create_subtask("redhat_check_licenses"),
        ]

        map(lambda t: setattr(t, "weight", 0.01), subtasks)
        db().commit()

        subtask_messages = [
            self._call_silently(subtasks[0], tasks.RedHatCheckCredentialsTask, rhel_data, method_name="message"),
            self._call_silently(
                subtasks[1], tasks.RedHatCheckLicensesTask, rhel_data, nodes_info, method_name="message"
            ),
        ]

        for task, message in zip(subtasks, subtask_messages):
            task.cache = message
        db().commit()

        map(db().refresh, subtasks)

        for task in subtasks:
            if task.status == "error":
                raise errors.RedHatSetupError(task.message)

        return subtask_messages
开发者ID:nfschina,项目名称:fuelweb,代码行数:46,代码来源:manager.py

示例6: execute

# 需要导入模块: from nailgun.task.task import TaskHelper [as 别名]
# 或者: from nailgun.task.task.TaskHelper import update_task_status [as 别名]
 def execute(self, data):
     task = Task(
         name="check_networks",
         cluster=self.cluster
     )
     orm().add(task)
     orm().commit()
     self._call_silently(
         task,
         tasks.CheckNetworksTask,
         data
     )
     orm().refresh(task)
     if task.status == 'running':
         TaskHelper.update_task_status(
             task.uuid,
             status="ready",
             progress=100
         )
     return task
开发者ID:akolinko,项目名称:product,代码行数:22,代码来源:manager.py

示例7: execute

# 需要导入模块: from nailgun.task.task import TaskHelper [as 别名]
# 或者: from nailgun.task.task.TaskHelper import update_task_status [as 别名]
    def execute(self):
        logger.info(
            u"Trying to start deployment at cluster '{0}'".format(
                self.cluster.name or self.cluster.id,
            )
        )

        current_tasks = db().query(Task).filter_by(
            cluster_id=self.cluster.id,
            name="deploy"
        )
        for task in current_tasks:
            if task.status == "running":
                raise errors.DeploymentAlreadyStarted()
            elif task.status in ("ready", "error"):
                for subtask in task.subtasks:
                    db().delete(subtask)
                db().delete(task)
                db().commit()

        task_messages = []

        nodes_to_delete = TaskHelper.nodes_to_delete(self.cluster)
        nodes_to_deploy = TaskHelper.nodes_to_deploy(self.cluster)
        nodes_to_provision = TaskHelper.nodes_to_provision(self.cluster)

        if not any([nodes_to_provision, nodes_to_deploy, nodes_to_delete]):
            raise errors.WrongNodeStatus("No changes to deploy")

        self.cluster.status = 'deployment'
        db().add(self.cluster)
        db().commit()

        supertask = Task(
            name="deploy",
            cluster=self.cluster
        )
        db().add(supertask)
        db().commit()
        if not self.cluster.replaced_provisioning_info \
           and not self.cluster.replaced_deployment_info:
            try:
                self.check_before_deployment(supertask)
            except errors.CheckBeforeDeploymentError:
                return supertask
        # in case of Red Hat
        if self.cluster.release.operating_system == "RHEL":
            try:
                redhat_messages = self._redhat_messages(
                    supertask,
                    # provision only?
                    [
                        {"uid": n.id, "platform_name": n.platform_name}
                        for n in nodes_to_provision
                    ]
                )
            except Exception as exc:
                TaskHelper.update_task_status(
                    supertask.uuid,
                    status='error',
                    progress=100,
                    msg=str(exc)
                )
                return supertask
            task_messages.extend(redhat_messages)
        # /in case of Red Hat

        task_deletion, task_provision, task_deployment = None, None, None

        if nodes_to_delete:
            task_deletion = supertask.create_subtask("node_deletion")
            logger.debug("Launching deletion task: %s", task_deletion.uuid)
            self._call_silently(
                task_deletion,
                tasks.DeletionTask
            )

        if nodes_to_provision:
            TaskHelper.update_slave_nodes_fqdn(nodes_to_provision)
            logger.debug("There are nodes to provision: %s",
                         " ".join([n.fqdn for n in nodes_to_provision]))
            task_provision = supertask.create_subtask("provision")
            # we assume here that task_provision just adds system to
            # cobbler and reboots it, so it has extremely small weight
            task_provision.weight = 0.05
            provision_message = self._call_silently(
                task_provision,
                tasks.ProvisionTask,
                method_name='message'
            )
            db().refresh(task_provision)

            # if failed to generate task message for orchestrator
            # then task is already set to error
            if task_provision.status == 'error':
                return supertask

            task_provision.cache = provision_message
            db().add(task_provision)
            db().commit()
#.........这里部分代码省略.........
开发者ID:glacialheart2013,项目名称:fuel-web,代码行数:103,代码来源:manager.py

示例8: execute

# 需要导入模块: from nailgun.task.task import TaskHelper [as 别名]
# 或者: from nailgun.task.task.TaskHelper import update_task_status [as 别名]
    def execute(self):
        logger.info(
            u"Trying to start deployment at cluster '{0}'".format(
                self.cluster.name or self.cluster.id
            )
        )

        network_info = self.serialize_network_cfg(self.cluster)
        logger.info(
            u"Network info:\n{0}".format(
                json.dumps(network_info, indent=4)
            )
        )

        current_tasks = db().query(Task).filter_by(
            cluster_id=self.cluster.id,
            name='deploy')

        for task in current_tasks:
            if task.status == "running":
                raise errors.DeploymentAlreadyStarted()
            elif task.status in ("ready", "error"):
                db().delete(task)
                db().commit()

        obsolete_tasks = db().query(Task).filter_by(
            cluster_id=self.cluster.id,
        ).filter(
            Task.name.in_([
                'stop_deployment',
                'reset_environment'
            ])
        )
        for task in obsolete_tasks:
            db().delete(task)
        db().commit()

        task_messages = []

        nodes_to_delete = TaskHelper.nodes_to_delete(self.cluster)
        nodes_to_deploy = TaskHelper.nodes_to_deploy(self.cluster)
        nodes_to_provision = TaskHelper.nodes_to_provision(self.cluster)

        if not any([nodes_to_provision, nodes_to_deploy, nodes_to_delete]):
            raise errors.WrongNodeStatus("No changes to deploy")

        supertask = Task(name='deploy', cluster=self.cluster)
        db().add(supertask)
        db().commit()

        # Run validation if user didn't redefine
        # provisioning and deployment information
        if not self.cluster.replaced_provisioning_info \
           and not self.cluster.replaced_deployment_info:
            try:
                self.check_before_deployment(supertask)
            except errors.CheckBeforeDeploymentError:
                return supertask

        # in case of Red Hat
        if self.cluster.release.operating_system == "RHEL":
            try:
                redhat_messages = self._redhat_messages(
                    supertask,
                    # provision only?
                    [
                        {"uid": n.id, "platform_name": n.platform_name}
                        for n in nodes_to_provision
                    ]
                )
            except Exception as exc:
                TaskHelper.update_task_status(
                    supertask.uuid,
                    status='error',
                    progress=100,
                    msg=str(exc)
                )
                return supertask
            task_messages.extend(redhat_messages)
        # /in case of Red Hat

        task_deletion, task_provision, task_deployment = None, None, None

        if nodes_to_delete:
            # For more accurate progress calulation
            task_weight = 0.4
            task_deletion = supertask.create_subtask("node_deletion",
                                                     weight=task_weight)
            logger.debug("Launching deletion task: %s", task_deletion.uuid)
            self._call_silently(task_deletion, tasks.DeletionTask)

        if nodes_to_provision:
            TaskHelper.update_slave_nodes_fqdn(nodes_to_provision)
            logger.debug("There are nodes to provision: %s",
                         " ".join([n.fqdn for n in nodes_to_provision]))

            # For more accurate progress calulation
            task_weight = 0.4
            task_provision = supertask.create_subtask("provision",
                                                      weight=task_weight)
#.........这里部分代码省略.........
开发者ID:Mellanox,项目名称:fuel-web,代码行数:103,代码来源:manager.py


注:本文中的nailgun.task.task.TaskHelper.update_task_status方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。