• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python tasks.TaskHandler类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中nailgun.api.handlers.tasks.TaskHandler的典型用法代码示例。如果您正苦于以下问题:Python TaskHandler类的具体用法?Python TaskHandler怎么用?Python TaskHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



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

示例1: PUT

    def PUT(self, cluster_id):
        """
        :IMPORTANT: this method should be rewritten to be more RESTful

        :returns: JSONized Task object.
        :http: * 202 (network checking task failed)
               * 200 (network verification task started)
               * 404 (cluster not found in db)
        """
        cluster = self.get_object_or_404(Cluster, cluster_id)

        try:
            data = self.validator.validate_networks_update(web.data())
        except web.webapi.badrequest as exc:
            task = Task(name='check_networks', cluster=cluster)
            db().add(task)
            db().commit()
            TaskHelper.set_error(task.uuid, exc.data)
            logger.error(traceback.format_exc())

            json_task = build_json_response(TaskHandler.render(task))
            raise web.accepted(data=json_task)

        vlan_ids = [{
            'name': n['name'],
            'vlans': NetworkGroup.generate_vlan_ids_list(n)
        } for n in data['networks']]

        task_manager = VerifyNetworksTaskManager(cluster_id=cluster.id)
        task = task_manager.execute(data, vlan_ids)

        return TaskHandler.render(task)
开发者ID:mydaisy2,项目名称:fuelweb,代码行数:32,代码来源:network_configuration.py


示例2: launch_verify

    def launch_verify(self, cluster):
        try:
            data = self.validator.validate_networks_update(web.data())
        except web.webapi.badrequest as exc:
            task = Task(name='check_networks', cluster=cluster)
            db().add(task)
            db().commit()
            TaskHelper.set_error(task.uuid, exc.data)
            logger.error(traceback.format_exc())

            json_task = build_json_response(TaskHandler.render(task))
            raise web.accepted(data=json_task)

        data["networks"] = [
            n for n in data["networks"] if n.get("name") != "fuelweb_admin"
        ]

        vlan_ids = [{
                    'name': n['name'],
                    'vlans': cluster.network_manager.generate_vlan_ids_list(
                        data, cluster, n)
                    } for n in data['networks']]

        task_manager = VerifyNetworksTaskManager(cluster_id=cluster.id)
        try:
            task = task_manager.execute(data, vlan_ids)
        except errors.CantRemoveOldVerificationTask:
            raise web.badrequest("You cannot delete running task manually")
        return TaskHandler.render(task)
开发者ID:tsipa,项目名称:fuel-web,代码行数:29,代码来源:network_configuration.py


示例3: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized Task object.
        :http: * 202 (environment reset initiated)
               * 400 (can't reset environment)
               * 404 (environment not found in db)
        """
        cluster = self.get_object_or_404(Cluster, cluster_id)

        try:
            logger.info(
                u"Trying to reset environment '{0}'".format(
                    cluster_id
                )
            )
            task_manager = ResetEnvironmentTaskManager(
                cluster_id=cluster.id
            )
            task = task_manager.execute()
        except Exception as exc:
            logger.warn(u'Error during execution '
                        u'environment resetting '
                        u'task: {0}'.format(str(exc)))
            raise web.badrequest(str(exc))

        raise web.webapi.HTTPError(
            status="202 Accepted",
            data=TaskHandler.render(task)
        )
开发者ID:tsipa,项目名称:fuel-web,代码行数:28,代码来源:cluster.py


示例4: PUT

    def PUT(self, cluster_id):
        data = json.loads(web.data())
        cluster = self.get_object_or_404(Cluster, cluster_id)

        task_manager = CheckNetworksTaskManager(cluster_id=cluster.id)
        task = task_manager.execute(data)

        if task.status != 'error':
            try:
                if 'networks' in data:
                    network_configuration = self.validator.\
                        validate_networks_update(json.dumps(data))

                NetworkConfiguration.update(cluster, data)
            except web.webapi.badrequest as exc:
                TaskHelper.set_error(task.uuid, exc.data)
                logger.error(traceback.format_exc())
            except Exception as exc:
                TaskHelper.set_error(task.uuid, exc)
                logger.error(traceback.format_exc())

        data = build_json_response(TaskHandler.render(task))
        if task.status == 'error':
            db().rollback()
        else:
            db().commit()
        raise web.accepted(data=data)
开发者ID:99cloud-net,项目名称:fuelweb,代码行数:27,代码来源:network_configuration.py


示例5: PUT

    def PUT(self, cluster_id):
        cluster = self.get_object_or_404(
            Cluster,
            cluster_id,
            log_404=(
                "warning",
                "Error: there is no cluster "
                "with id '{0}' in DB.".format(cluster_id)))

        try:
            network_info = \
                NetworkConfigurationSerializer.serialize_for_cluster(
                    cluster
                )
            logger.info(
                u"Network info:\n{0}".format(
                    json.dumps(network_info, indent=4)
                )
            )
            task_manager = DeploymentTaskManager(
                cluster_id=cluster.id
            )
            task = task_manager.execute()
        except Exception as exc:
            logger.warn(u'ClusterChangesHandler: error while execution'
                        ' deploy task: {0}'.format(str(exc)))
            raise web.badrequest(str(exc))

        return TaskHandler.render(task)
开发者ID:mahak,项目名称:fuelweb,代码行数:29,代码来源:cluster.py


示例6: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized Task object.
        :http: * 200 (task successfully executed)
               * 404 (cluster not found in db)
               * 400 (failed to execute task)
        """
        cluster = self.get_object_or_404(
            Cluster,
            cluster_id,
            log_404=("warning", "Error: there is no cluster " "with id '{0}' in DB.".format(cluster_id)),
        )

        if cluster.net_provider == "nova_network":
            net_serializer = NovaNetworkConfigurationSerializer
        elif cluster.net_provider == "neutron":
            net_serializer = NeutronNetworkConfigurationSerializer

        try:
            network_info = net_serializer.serialize_for_cluster(cluster)
            logger.info(u"Network info:\n{0}".format(json.dumps(network_info, indent=4)))
            task_manager = ApplyChangesTaskManager(cluster_id=cluster.id)
            task = task_manager.execute()
        except Exception as exc:
            logger.warn(u"ClusterChangesHandler: error while execution" " deploy task: {0}".format(str(exc)))
            raise web.badrequest(str(exc))

        return TaskHandler.render(task)
开发者ID:pombredanne,项目名称:fuel-web,代码行数:27,代码来源:cluster.py


示例7: POST

 def POST(self):
     data = self.checked_data()
     # TODO: activate and save status
     task_manager = DownloadReleaseTaskManager(data['release_id'])
     try:
         task = task_manager.execute()
     except Exception as exc:
         logger.warn(u'DownloadReleaseHandler: error while execution'
                     ' deploy task: {0}'.format(exc.message))
         raise web.badrequest(exc.message)
     return TaskHandler.render(task)
开发者ID:ilyinon,项目名称:fuelweb,代码行数:11,代码来源:redhat.py


示例8: PUT

    def PUT(self):
        """Starts capacity data generation.

        :returns: JSONized Task object.
        :http: * 202 (setup task created and started)
        """
        manager = GenerateCapacityLogTaskManager()
        task = manager.execute()

        data = build_json_response(TaskHandler.render(task))
        raise web.accepted(data=data)
开发者ID:e0ne,项目名称:fuel-web,代码行数:11,代码来源:capacity.py


示例9: PUT

 def PUT(self):
     """:returns: JSONized Task object.
     :http: * 200 (task successfully executed)
            * 400 (failed to execute task)
     """
     try:
         task_manager = DumpTaskManager()
         task = task_manager.execute()
     except Exception as exc:
         logger.warn(u'DumpTask: error while execution '
                     'dump environment task: {0}'.format(str(exc)))
         raise web.badrequest(str(exc))
     return TaskHandler.render(task)
开发者ID:e0ne,项目名称:fuel-web,代码行数:13,代码来源:logs.py


示例10: PUT

    def PUT(self, cluster_id):
        cluster = self.get_object_or_404(
            Cluster,
            cluster_id,
            log_404=(
                "warning",
                "Error: there is no cluster "
                "with id '{0}' in DB.".format(cluster_id)))

        check_task_manager = CheckBeforeDeploymentTaskManager(
            cluster_id=cluster.id)
        check_task = check_task_manager.execute()
        if check_task.status == 'error':
            return TaskHandler.render(check_task)

        try:
            task_manager = DeploymentTaskManager(cluster_id=cluster.id)
            task = task_manager.execute()
        except Exception as exc:
            logger.warn(u'ClusterChangesHandler: error while execution'
                        ' deploy task: {0}'.format(str(exc)))
            raise web.badrequest(str(exc))

        return TaskHandler.render(task)
开发者ID:rakeshkk,项目名称:fuelweb,代码行数:24,代码来源:cluster.py


示例11: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized Task object.
        :http: * 202 (network checking task created)
               * 404 (cluster not found in db)
        """
        data = json.loads(web.data())
        if data.get("networks"):
            data["networks"] = [
                n for n in data["networks"] if n.get("name") != "fuelweb_admin"
            ]

        cluster = self.get_object_or_404(Cluster, cluster_id)
        self.check_net_provider(cluster)

        self.check_if_network_configuration_locked(cluster)

        task_manager = CheckNetworksTaskManager(cluster_id=cluster.id)
        task = task_manager.execute(data)

        if task.status != 'error':
            try:
                if 'networks' in data:
                    self.validator.validate_networks_update(
                        json.dumps(data)
                    )

                if 'dns_nameservers' in data:
                    self.validator.validate_dns_servers_update(
                        json.dumps(data)
                    )

                NovaNetworkManager.update(cluster, data)
            except web.webapi.badrequest as exc:
                TaskHelper.set_error(task.uuid, exc.data)
                logger.error(traceback.format_exc())
            except Exception as exc:
                TaskHelper.set_error(task.uuid, exc)
                logger.error(traceback.format_exc())

        data = build_json_response(TaskHandler.render(task))
        if task.status == 'error':
            db().rollback()
        else:
            db().commit()
        raise web.accepted(data=data)
开发者ID:tsipa,项目名称:fuel-web,代码行数:45,代码来源:network_configuration.py


示例12: POST

    def POST(self):
        """
        Starts Red Hat setup and download process

        :returns: JSONized Task object.
        :http: * 202 (setup task created and started)
               * 400 (invalid account data specified)
               * 404 (release not found in db)
        """
        data = self.checked_data()

        license_type = data.get("license_type")
        if license_type == 'rhsm':
            data["satellite"] = ""
            data["activation_key"] = ""

        release_data = {'release_id': data['release_id']}
        release_id = data.pop('release_id')
        release_db = db().query(Release).get(release_id)
        if not release_db:
            raise web.notfound(
                "No release with ID={0} found".format(release_id)
            )
        release_data['redhat'] = data
        release_data['release_name'] = release_db.name

        account = db().query(RedHatAccount).first()
        if account:
            db().query(RedHatAccount).update(data)
        else:
            account = RedHatAccount(**data)
            db().add(account)
        db().commit()

        task_manager = RedHatSetupTaskManager(release_data)
        try:
            task = task_manager.execute()
        except Exception as exc:
            logger.error(u'RedHatAccountHandler: error while execution'
                         ' Red Hat validation task: {0}'.format(str(exc)))
            logger.error(traceback.format_exc())
            raise web.badrequest(str(exc))

        data = build_json_response(TaskHandler.render(task))
        raise web.accepted(data=data)
开发者ID:mydaisy2,项目名称:fuelweb,代码行数:45,代码来源:redhat.py


示例13: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized Task object.
        :http: * 200 (task successfully executed)
               * 404 (cluster or nodes not found in db)
               * 400 (failed to execute task)
        """
        cluster = self.get_object_or_404(Cluster, cluster_id)
        nodes = self.get_nodes(cluster)

        try:
            task_manager = self.task_manager(cluster_id=cluster.id)
            task = task_manager.execute(nodes)
        except Exception as exc:
            logger.warn(u'Cannot execute {0} task nodes: {1}'.format(
                task_manager.__class__.__name__, traceback.format_exc()))
            raise web.badrequest(str(exc))

        return TaskHandler.render(task)
开发者ID:e0ne,项目名称:fuel-web,代码行数:18,代码来源:orchestrator.py


示例14: POST

    def POST(self):
        data = self.checked_data()
        release_data = {"release_id": data["release_id"]}
        data.pop("release_id")
        release_data["redhat"] = data

        account = RedHatAccount(**data)
        db().add(account)
        db().commit()

        task_manager = DownloadReleaseTaskManager(release_data)
        try:
            task = task_manager.execute()
        except Exception as exc:
            logger.error(u"DownloadReleaseHandler: error while execution" " deploy task: {0}".format(str(exc)))
            logger.error(traceback.format_exc())
            raise web.badrequest(str(exc))
        return TaskHandler.render(task)
开发者ID:newsky,项目名称:fuelweb,代码行数:18,代码来源:redhat.py


示例15: POST

    def POST(self):
        plugin_manager = PluginManager()
        task = plugin_manager.add_install_plugin_task(
            json.loads(web.data()))

        return TaskHandler.render(task)
开发者ID:mydaisy2,项目名称:fuelweb,代码行数:6,代码来源:plugin.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python models.Task类代码示例发布时间:2022-05-27
下一篇:
Python security.has_permissions函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap