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


Python manager.CheckNetworksTaskManager类代码示例

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


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

示例1: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized Task object.
        :http: * 200 (task successfully executed)
               * 202 (network checking task scheduled for execution)
               * 400 (data validation failed)
               * 404 (cluster not found in db)
        """
        # TODO(pkaminski): this seems to be synchronous, no task needed here
        data = jsonutils.loads(web.data())
        cluster = self.get_object_or_404(objects.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 != consts.TASK_STATUSES.error:
            try:
                if "networks" in data:
                    self.validator.validate_networks_update(jsonutils.dumps(data))

                if "networking_parameters" in data:
                    self.validator.validate_neutron_params(jsonutils.dumps(data), cluster_id=cluster_id)

                objects.Cluster.get_network_manager(cluster).update(cluster, data)
            except Exception as exc:
                # set task status to error and update its corresponding data
                data = {"status": "error", "progress": 100, "message": six.text_type(exc)}
                objects.Task.update(task, data)
                logger.error(traceback.format_exc())

        self.raise_task(task)
开发者ID:thefuyang,项目名称:fuel-web,代码行数:33,代码来源:network_configuration.py

示例2: 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

示例3: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized Task object.
        :http: * 200 (task successfully executed)
               * 202 (network checking task scheduled for execution)
               * 400 (data validation failed)
               * 404 (cluster not found in db)
        """
        cluster = self.get_object_or_404(objects.Cluster, cluster_id)
        self.check_net_provider(cluster)

        self.check_if_network_configuration_locked(cluster)

        try:
            data = self.validator.validate_networks_data(web.data(), cluster)
        except Exception as exc:
            self._raise_error_task(cluster, exc)

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

        if task.status != consts.TASK_STATUSES.error:
            objects.Cluster.get_network_manager(
                cluster
            ).update(cluster, data)

        # TODO(pkaminski): this is synchronous, no task needed here
        self.raise_task(task)
开发者ID:SergK,项目名称:fuel-web,代码行数:27,代码来源:network_configuration.py

示例4: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized network configuration for cluster.

        :http: * 200 (task successfully executed)
               * 202 (network checking task scheduled for execution)
               * 400 (data validation failed)
               * 404 (cluster not found in db)
        """
        cluster = self.get_object_or_404(objects.Cluster, cluster_id)
        self.check_net_provider(cluster)

        self.check_if_network_configuration_locked(cluster)

        data = self.checked_data(
            self.validator.validate_networks_data,
            data=web.data(), cluster=cluster, networks_required=False)

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

        if task.status == consts.TASK_STATUSES.error:
            raise self.http(400, task.message, err_list=task.result)

        objects.Cluster.get_network_manager(
            cluster
        ).update(cluster, data)
        return self.serializer.serialize_for_cluster(cluster)
开发者ID:ibelikov,项目名称:fuel-web,代码行数:27,代码来源:network_configuration.py

示例5: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized network configuration for cluster.

        :http: * 200 (OK)
               * 400 (data validation or some of tasks failed)
               * 404 (cluster not found in db)
               * 409 (previous dsnmasq setup is not finished yet)
        """
        cluster, data = self._get_cluster_and_validated_network_data(
            cluster_id)

        self.check_if_network_configuration_locked(cluster)

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

        if task.status == consts.TASK_STATUSES.error:
            raise self.http(400, task.message, err_list=task.result)

        nm = objects.Cluster.get_network_manager(cluster)
        admin_nets = nm.get_admin_networks()
        nm.update(cluster, data)

        network_config = self.serializer.serialize_for_cluster(cluster)

        if admin_nets != nm.get_admin_networks():
            try:
                task = UpdateDnsmasqTaskManager().execute()
            except errors.TaskAlreadyRunning:
                raise self.http(409, errors.UpdateDnsmasqTaskIsRunning.message)
            if task.status == consts.TASK_STATUSES.error:
                raise self.http(400, task.message)

        return network_config
开发者ID:huyupeng,项目名称:fuel-web,代码行数:34,代码来源:network_configuration.py

示例6: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized Task object.
        :http: * 202 (network checking task created)
               * 404 (cluster not found in db)
        """
        data = jsonutils.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(objects.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 != consts.TASK_STATUSES.error:
            try:
                if "networks" in data:
                    self.validator.validate_networks_update(jsonutils.dumps(data))

                if "dns_nameservers" in data:
                    self.validator.validate_dns_servers_update(jsonutils.dumps(data))

                objects.Cluster.get_network_manager(cluster).update(cluster, data)
            except Exception as exc:
                # set task status to error and update its corresponding data
                data = {"status": consts.TASK_STATUSES.error, "progress": 100, "message": six.text_type(exc)}
                objects.Task.update(task, data)

                logger.error(traceback.format_exc())

        raise self.http(202, objects.Task.to_json(task))
开发者ID:yxh1990,项目名称:fuel-cloudmaster,代码行数:34,代码来源:network_configuration.py

示例7: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized Task object.
        :http: * 202 (network checking task created)
               * 404 (cluster not found in db)
        """
        data = jsonutils.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(
                        jsonutils.dumps(data)
                    )

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

                objects.Cluster.get_network_manager(
                    cluster
                ).update(cluster, data)
            except Exception as exc:
                # set task status to error and update its corresponding data
                data = {'status': 'error',
                        'progress': 100,
                        'message': six.text_type(exc)}
                objects.Task.update(task, data)

                logger.error(traceback.format_exc())

        #TODO(enchantner): research this behaviour
        if task.status == 'error':
            db().rollback()
        else:
            db().commit()

        raise self.http(202, Task.to_json(task))
开发者ID:iberezovskiy,项目名称:fuel-web,代码行数:50,代码来源:network_configuration.py

示例8: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized network configuration for cluster.

        :http: * 200 (OK)
               * 400 (data validation or some of tasks failed)
               * 404 (cluster not found in db)
               * 409 (previous dsnmasq setup is not finished yet)
        """
        cluster = self.get_object_or_404(objects.Cluster, cluster_id)
        self.check_net_provider(cluster)

        self.check_if_network_configuration_locked(cluster)

        data = self.checked_data(
            self.validator.validate_networks_data,
            data=web.data(), cluster=cluster, networks_required=False)

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

        if task.status == consts.TASK_STATUSES.error:
            raise self.http(400, task.message, err_list=task.result)

        nm = objects.Cluster.get_network_manager(cluster)
        admin_nets = nm.get_admin_networks()
        nm.update(cluster, data)

        try:
            network_config = self.serializer.serialize_for_cluster(cluster,
                                                                   True)
        except errors.DuplicatedVIPNames as exc:
            raise self.http(400, six.text_type(exc))
        except errors.OutOfIPs as exc:
            network_id = getattr(exc, 'network_id', None)
            raise self.http(
                400,
                six.text_type(exc),
                err_list=[{"errors": ["ip_ranges"], "ids": [network_id]}]
            )

        if admin_nets != nm.get_admin_networks():
            try:
                task = UpdateDnsmasqTaskManager().execute()
            except errors.TaskAlreadyRunning:
                raise self.http(409, errors.UpdateDnsmasqTaskIsRunning.message)
            if task.status == consts.TASK_STATUSES.error:
                raise self.http(400, task.message)

        return network_config
开发者ID:tonycot,项目名称:fuel-web,代码行数:49,代码来源:network_configuration.py

示例9: PUT

    def PUT(self, cluster_id):
        """:returns: JSONized Task object.
        :http: * 200 (task successfully executed)
               * 202 (network checking task scheduled for execution)
               * 400 (data validation failed)
               * 404 (cluster not found in db)
        """
        # TODO(pkaminski): this seems to be synchronous, no task needed here
        data = jsonutils.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(objects.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 != consts.TASK_STATUSES.error:
            try:
                if 'networks' in data:
                    self.validator.validate_networks_update(
                        jsonutils.dumps(data)
                    )

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

                objects.Cluster.get_network_manager(
                    cluster
                ).update(cluster, data)
            except Exception as exc:
                # set task status to error and update its corresponding data
                data = {'status': consts.TASK_STATUSES.error,
                        'progress': 100,
                        'message': six.text_type(exc)}
                objects.Task.update(task, data)

                logger.error(traceback.format_exc())

        self.raise_task(task)
开发者ID:linglong0820,项目名称:fuel-web,代码行数:47,代码来源:network_configuration.py

示例10: 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

示例11: PUT

    def PUT(self, cluster_id):
        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 'networking_parameters' in data:
                    self.validator.validate_neutron_params(
                        json.dumps(data),
                        cluster_id=cluster_id
                    )

                objects.Cluster.get_network_manager(
                    cluster
                ).update(cluster, data)
            except Exception as exc:
                TaskHelper.set_error(task.uuid, exc)
                logger.error(traceback.format_exc())

        #TODO(enchantner): research this behaviour
        if task.status == 'error':
            db().rollback()
        else:
            db().commit()

        raise self.http(202, Task.to_json(task))
开发者ID:enchantner,项目名称:fuel-web,代码行数:42,代码来源:network_configuration.py

示例12: PUT

    def PUT(self, cluster_id):
        data = jsonutils.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(
                        jsonutils.dumps(data)
                    )

                if 'networking_parameters' in data:
                    self.validator.validate_neutron_params(
                        jsonutils.dumps(data),
                        cluster_id=cluster_id
                    )

                objects.Cluster.get_network_manager(
                    cluster
                ).update(cluster, data)
            except Exception as exc:
                # set task status to error and update its corresponding data
                data = {'status': 'error',
                        'progress': 100,
                        'message': six.text_type(exc)}
                objects.Task.update(task, data)

                logger.error(traceback.format_exc())

        raise self.http(202, Task.to_json(task))
开发者ID:igajsin,项目名称:fuel-web,代码行数:41,代码来源:network_configuration.py


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