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

Python objects.DeploymentGraph类代码示例

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

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



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

示例1: create

    def create(cls, data):
        """Create Release instance with specified parameters in DB.

        :param data: dictionary of key-value pairs as object fields
        :returns: Release instance
        """
        # in order to be compatible with old API, let's drop input
        # roles array. since fuel 7.0 we don't use it anymore, and
        # we don't require it even for old releases.
        data.pop("roles", None)
        # process graphs
        graphs = {}
        graphs_list = data.pop('graphs', [])
        for graph in graphs_list:
            graphs[graph.pop('type')] = graph

        deployment_tasks = data.pop("deployment_tasks", [])

        if not graphs.get(consts.DEFAULT_DEPLOYMENT_GRAPH_TYPE):
            graphs[consts.DEFAULT_DEPLOYMENT_GRAPH_TYPE] = \
                {'tasks': deployment_tasks}

        release_obj = super(Release, cls).create(data)

        for graph_type, graph_data in six.iteritems(graphs):
            DeploymentGraph.create_for_model(
                graph_data, release_obj, graph_type)

        cls.create_tags(release_obj)
        return release_obj
开发者ID:sebrandon1,项目名称:fuel-web,代码行数:30,代码来源:release.py


示例2: delete

    def delete(cls, instance):
        """Delete release.

        :param instance: Release model instance
        :type instance: models.Release
        """
        DeploymentGraph.delete_for_parent(instance)
        super(Release, cls).delete(instance)
开发者ID:mmalchuk,项目名称:openstack-fuel-web,代码行数:8,代码来源:release.py


示例3: delete

    def delete(cls, instance):
        """Delete plugin.

        :param instance: Plugin model instance
        :type instance: models.Plugin
        """
        DeploymentGraph.delete_for_parent(instance)
        super(Plugin, cls).delete(instance)
开发者ID:huyupeng,项目名称:fuel-web,代码行数:8,代码来源:plugin.py


示例4: test_get_deployment_tasks

    def test_get_deployment_tasks(self):
        dg = DeploymentGraph.get_for_model(self.plugin_adapter.plugin)
        DeploymentGraph.update(
            dg,
            {
                'tasks': self.env.get_default_plugin_deployment_tasks()
            }
        )

        depl_task = self.plugin_adapter.get_deployment_tasks()[0]
        self.assertEqual(depl_task['parameters'].get('cwd'),
                         self.plugin_adapter.slaves_scripts_path)
开发者ID:openstack,项目名称:fuel-web,代码行数:12,代码来源:test_plugin_adapters.py


示例5: test_get_deployment_tasks_params_not_changed

 def test_get_deployment_tasks_params_not_changed(self):
     expected = 'path/to/some/dir'
     dg = DeploymentGraph.get_for_model(self.plugin_adapter.plugin)
     DeploymentGraph.update(
         dg,
         {
             'tasks': self.env.get_default_plugin_deployment_tasks(
                 parameters={'cwd': expected})
         }
     )
     depl_task = self.plugin_adapter.get_deployment_tasks()[0]
     self.assertEqual(depl_task['parameters'].get('cwd'), expected)
开发者ID:openstack,项目名称:fuel-web,代码行数:12,代码来源:test_plugin_adapters.py


示例6: test_graphs_list_filtered_cluster

    def test_graphs_list_filtered_cluster(self):
        expected_list = [
            {
                'id': DeploymentGraph.get_for_model(
                    self.cluster.release, graph_type='default').id,
                'name': None,
                'relations': [{
                    'model_id': self.cluster.release.id,
                    'model': 'release',
                    'type': 'default'
                }]
            },
            {
                'id': DeploymentGraph.get_for_model(self.cluster).id,
                'name': None,
                'relations': [{
                    'model_id': self.cluster.id,
                    'model': 'cluster',
                    'type': 'default'
                }]
            },
            {
                'id': DeploymentGraph.get_for_model(
                    self.cluster, graph_type='custom-graph').id,
                'name': 'custom-graph-name',
                'relations': [{
                    'model_id': self.cluster.id,
                    'model': 'cluster',
                    'type': 'custom-graph'
                }]
            },
            {
                'id': DeploymentGraph.get_for_model(self.plugin).id,
                'name': None,
                'relations': [{
                    'model_id': self.plugin.id,
                    'model': 'plugin',
                    'type': 'default'
                }],
            }
        ]

        response = self.app.get(
            reverse(
                'DeploymentGraphCollectionHandler',
                kwargs={}
            ) + '?clusters_ids={}&fetch_related=1'.format(self.cluster.id),
            headers=self.default_headers
        ).json_body

        for r in response:
            r.pop('tasks')
        self.assertItemsEqual(expected_list, response)
开发者ID:mmalchuk,项目名称:openstack-fuel-web,代码行数:53,代码来源:test_deployment_graph_handlers.py


示例7: create

    def create(cls, data):
        # accidental because i've seen this way of tasks creation only in tests
        deployment_tasks = data.pop('deployment_tasks', [])
        new_plugin = super(Plugin, cls).create(data)

        # create default graph in any case
        DeploymentGraph.create_for_model(
            {'tasks': deployment_tasks}, new_plugin)

        plugin_adapter = wrap_plugin(new_plugin)
        cls.update(new_plugin, plugin_adapter.get_metadata())

        ClusterPlugin.add_compatible_clusters(new_plugin)

        return new_plugin
开发者ID:huyupeng,项目名称:fuel-web,代码行数:15,代码来源:plugin.py


示例8: create

    def create(cls, data):
        """Create Release instance with specified parameters in DB.

        :param data: dictionary of key-value pairs as object fields
        :returns: Release instance
        """
        # in order to be compatible with old API, let's drop input
        # roles array. since fuel 7.0 we don't use it anymore, and
        # we don't require it even for old releases.
        data.pop("roles", None)
        deployment_tasks = data.pop("deployment_tasks", [])
        release_obj = super(Release, cls).create(data)

        DeploymentGraph.create_for_model(
            {'tasks': deployment_tasks}, release_obj)
        return release_obj
开发者ID:jiaolongsun,项目名称:fuel-web,代码行数:16,代码来源:release.py


示例9: setUp

 def setUp(self):
     super(TestGraphHandlers, self).setUp()
     self.cluster = self.env.create_cluster(api=False)
     plugin_data = {
         'releases': [
             {
                 'repository_path': 'repositories/ubuntu',
                 'version': self.cluster.release.version,
                 'os': self.cluster.release.operating_system.lower(),
                 'mode': [self.cluster.mode],
             }
         ],
         'cluster': self.cluster,
         'enabled': True,
     }
     self.plugin = self.env.create_plugin(**plugin_data)
     self.custom_graph = DeploymentGraph.create_for_model(
         {
             'name': 'custom-graph-name',
             'tasks': [{
                 'id': 'custom-task',
                 'type': 'puppet'
             }]
         },
         self.cluster,
         graph_type='custom-graph'
     )
     self.env.db().commit()
开发者ID:mmalchuk,项目名称:openstack-fuel-web,代码行数:28,代码来源:test_deployment_graph_handlers.py


示例10: update

    def update(cls, instance, data):
        graphs = {}
        data_graphs = data.pop("graphs", [])
        for graph in data_graphs:
            graphs[graph.pop('type')] = graph

        data.pop("deployment_tasks", [])    # could not be updated
        super(Plugin, cls).update(instance, data)

        for graph_type, graph_data in six.iteritems(graphs):
            existing_graph = DeploymentGraph.get_for_model(
                instance, graph_type=graph_type)
            if existing_graph:
                DeploymentGraph.update(existing_graph, graph_data)
            else:
                DeploymentGraph.create_for_model(
                    graph_data, instance, graph_type)
开发者ID:sebrandon1,项目名称:fuel-web,代码行数:17,代码来源:plugin.py


示例11: test_graphs_list_request

    def test_graphs_list_request(self):
        default_graph = DeploymentGraph.get_for_model(self.cluster)

        expected_list = [
            {
                'id': DeploymentGraph.get_for_model(
                    self.cluster.release, graph_type='default').id,
                'name': None,
                'relations': [{
                    'model_id': self.cluster.release.id,
                    'model': 'release',
                    'type': 'default'
                }]
            },
            {
                'id': self.custom_graph.id,
                'name': 'custom-graph-name',
                'relations': [{
                    'type': 'custom-graph',
                    'model': 'cluster',
                    'model_id': self.cluster.id
                }]
            },
            {
                'id': default_graph.id,
                'relations': [
                    {
                        'model': 'cluster',
                        'model_id': self.cluster.id,
                        'type': 'default'
                    }
                ],
                'name': None
            }
        ]
        resp = self.app.get(
            reverse(
                'DeploymentGraphCollectionHandler',
                kwargs={}
            ),
            headers=self.default_headers
        )
        response = resp.json_body
        for r in response:
            r.pop('tasks')
        self.assertItemsEqual(expected_list, response)
开发者ID:ekorekin,项目名称:fuel-web,代码行数:46,代码来源:test_deployment_graph_handlers.py


示例12: update

    def update(cls, instance, data):
        """Update existing Release instance with specified parameters.

        :param instance: Release instance
        :param data: dictionary of key-value pairs as object fields
        :returns: Release instance
        """
        # in order to be compatible with old API, let's drop input
        # roles array. since fuel 7.0 we don't use it anymore, and
        # we don't require it even for old releases.
        data.pop("roles", None)
        deployment_tasks = data.pop("deployment_tasks", None)
        release_obj = super(Release, cls).update(instance, data)
        if deployment_tasks:
            deployment_graph_instance = DeploymentGraph.get_for_model(instance)
            DeploymentGraph.update(deployment_graph_instance,
                                   {'tasks': deployment_tasks})
        return release_obj
开发者ID:jiaolongsun,项目名称:fuel-web,代码行数:18,代码来源:release.py


示例13: create

    def create(cls, data):
        """Create plugin.

        WARNING: don't pass keys with none to non nullable fields.

        :param data: data
        :type data: dict

        :return: plugin instance
        :rtype: models.Plugin
        """
        graphs = {}
        for graph in data.pop("graphs", []):
            graphs[graph.pop('type')] = graph

        deployment_tasks = data.pop("deployment_tasks", [])
        data['releases'] = [
            r for r in data.pop("releases", [])
            if not r.get('is_release', False)
        ]

        plugin_obj = super(Plugin, cls).create(data)

        if not graphs.get(consts.DEFAULT_DEPLOYMENT_GRAPH_TYPE):
            graphs[consts.DEFAULT_DEPLOYMENT_GRAPH_TYPE] = \
                {'tasks': deployment_tasks}

        for graph_type, graph_data in six.iteritems(graphs):
            DeploymentGraph.create_for_model(
                graph_data, plugin_obj, graph_type)

        plugin_adapter = plugins.wrap_plugin(plugin_obj)

        # todo(ikutukov): this update is a smell from the current plugins
        # installation schema. Remove it.

        cls.update(plugin_obj, plugin_adapter.get_metadata())

        ClusterPlugin.add_compatible_clusters(plugin_obj)

        return plugin_obj
开发者ID:sebrandon1,项目名称:fuel-web,代码行数:41,代码来源:plugin.py


示例14: update

    def update(cls, instance, data):
        """Update existing Release instance with specified parameters.

        :param instance: Release instance
        :param data: dictionary of key-value pairs as object fields
        :returns: Release instance
        """
        # in order to be compatible with old API, let's drop input
        # roles array. since fuel 7.0 we don't use it anymore, and
        # we don't require it even for old releases.
        data.pop("roles", None)

        graphs = data.pop("graphs", {})
        deployment_tasks = data.pop("deployment_tasks", [])

        existing_default_graph = DeploymentGraph.get_for_model(
            instance, consts.DEFAULT_DEPLOYMENT_GRAPH_TYPE)

        if (existing_default_graph and len(deployment_tasks)) \
                or not existing_default_graph:
            graphs[consts.DEFAULT_DEPLOYMENT_GRAPH_TYPE] = \
                {'tasks': deployment_tasks}
        release_obj = super(Release, cls).update(instance, data)

        for graph_type, graph_data in six.iteritems(graphs):
            g = DeploymentGraph.get_for_model(instance, graph_type)
            if g:
                DeploymentGraph.update(g, graph_data)
            else:
                DeploymentGraph.create_for_model(
                    graph_data, instance, graph_type)

        return release_obj
开发者ID:mmalchuk,项目名称:openstack-fuel-web,代码行数:33,代码来源:release.py


示例15: create

    def create(cls, data):
        graphs = data.pop("graphs", {})
        deployment_tasks = data.pop("deployment_tasks", [])

        if not graphs.get(consts.DEFAULT_DEPLOYMENT_GRAPH_TYPE):
            graphs[consts.DEFAULT_DEPLOYMENT_GRAPH_TYPE] = \
                {'tasks': deployment_tasks}
        plugin_obj = super(Plugin, cls).create(data)

        for graph_type, graph_data in six.iteritems(graphs):
            DeploymentGraph.create_for_model(
                graph_data, plugin_obj, graph_type)

        plugin_adapter = plugins.wrap_plugin(plugin_obj)

        # todo(ikutukov): this update is a smell from the current plugins
        # todo:           installation schema. Remove it.
        cls.update(plugin_obj, plugin_adapter.get_metadata())

        ClusterPlugin.add_compatible_clusters(plugin_obj)

        return plugin_obj
开发者ID:mmalchuk,项目名称:openstack-fuel-web,代码行数:22,代码来源:plugin.py


示例16: setUp

 def setUp(self):
     super(TestGraphHandlers, self).setUp()
     self.cluster = self.env.create_cluster(api=False)
     self.custom_graph = DeploymentGraph.create_for_model(
         {
             'name': 'custom-graph-name',
             'tasks': [{
                 'id': 'custom-task',
                 'type': 'puppet'
             }]
         },
         self.cluster,
         graph_type='custom-graph'
     )
开发者ID:ekorekin,项目名称:fuel-web,代码行数:14,代码来源:test_deployment_graph_handlers.py


示例17: test_existing_graph_update

    def test_existing_graph_update(self):
        for related_class, ref_graph in six.iteritems(self.custom_graphs):
            resp = self.app.put(
                reverse(
                    '{0}DeploymentGraphHandler'.format(related_class),
                    kwargs={
                        'obj_id': ref_graph['model'].id,
                        'graph_type': 'custom-graph1'
                    }
                ),
                jsonutils.dumps({
                    'name': 'updated-graph-name',
                    'tasks': [{
                        'id': 'test-task2',
                        'type': 'puppet',
                        'version': '2.0.0'
                    }]
                }),
                headers=self.default_headers
            )

            graph_id = DeploymentGraph.get_for_model(
                ref_graph['model'], 'custom-graph1').id

            self.assertEqual(200, resp.status_code)
            self.assertEqual(
                {
                    'id': graph_id,
                    'name': 'updated-graph-name',
                    'tasks': [{
                        'id': 'test-task2',
                        'type': 'puppet',
                        'task_name': 'test-task2',
                        'version': '2.0.0'
                    }],
                    'relations': [{
                        'model': related_class.lower(),
                        'model_id': ref_graph['model'].id,
                        'type': 'custom-graph1'
                    }]

                },
                resp.json_body
            )
开发者ID:ekorekin,项目名称:fuel-web,代码行数:44,代码来源:test_deployment_graph_handlers.py


示例18: get_deployment_graph

    def get_deployment_graph(cls, instance, graph_type=None):
        """Get deployment graph based on release version.

        :param instance: Release instance
        :type instance: models.Release
        :param graph_type: deployment graph type
        :type graph_type: basestring|None
        :returns: list of deployment tasks
        :rtype: list
        """
        if graph_type is None:
            graph_type = consts.DEFAULT_DEPLOYMENT_GRAPH_TYPE

        env_version = instance.environment_version

        deployment_graph = DeploymentGraph.get_for_model(instance, graph_type)
        if deployment_graph:
            deployment_tasks = DeploymentGraph.get_tasks(deployment_graph)
        else:
            # deployment tasks list should always be returned
            deployment_tasks = []

        if graph_type == consts.DEFAULT_DEPLOYMENT_GRAPH_TYPE and \
                not deployment_tasks:
            # upload default legacy graphs
            if env_version.startswith('5.0'):
                deployment_tasks = yaml.load(
                    graph_configuration.DEPLOYMENT_50)
            elif env_version.startswith('5.1') \
                    or env_version.startswith('6.0'):
                deployment_tasks = yaml.load(
                    graph_configuration.DEPLOYMENT_51_60)

            if deployment_graph:
                if deployment_tasks:
                    DeploymentGraph.update(
                        deployment_graph, {'tasks': deployment_tasks})
            else:
                # create graph anyway
                deployment_graph = DeploymentGraph.create_for_model(
                    {'tasks': deployment_tasks}, instance)

        if deployment_graph:
            metadata = DeploymentGraph.get_metadata(deployment_graph)
        else:
            metadata = {}

        metadata['tasks'] = deployment_tasks
        return metadata
开发者ID:mmalchuk,项目名称:openstack-fuel-web,代码行数:49,代码来源:release.py


示例19: setUp

 def setUp(self):
     super(TestCustomGraphAction, self).setUp()
     self.custom_tasks = [
         {
             'id': 'first-custom-task',
             'type': 'stage',
             'requires': ['pre_deployment_end']
         }, {
             'id': 'second-custom-task',
             'type': 'stage',
             'requires': ['deploy_start']
         }
     ]
     self.custom_graph = DeploymentGraph.create_for_model(
         {
             'name': 'custom-graph-name',
             'tasks': self.custom_tasks
         },
         self.cluster,
         graph_type='custom-graph'
     )
     self.env.db().commit()
开发者ID:ekorekin,项目名称:fuel-web,代码行数:22,代码来源:test_orchestrator_handlers.py


示例20: test_graph_delete

 def test_graph_delete(self):
     graph_id = self.custom_graph.id
     resp = self.app.delete(
         reverse(
             'DeploymentGraphHandler',
             kwargs={'obj_id': graph_id}
         ),
         headers=self.default_headers,
         expect_errors=True
     )
     self.assertEqual(204, resp.status_code)
     graph = DeploymentGraph.get_by_uid(graph_id)
     self.assertIsNone(graph)
     resp = self.app.get(
         reverse(
             'DeploymentGraphHandler',
             kwargs={'obj_id': graph_id}
         ),
         headers=self.default_headers,
         expect_errors=True
     )
     self.assertEqual(404, resp.status_code)
开发者ID:ekorekin,项目名称:fuel-web,代码行数:22,代码来源:test_deployment_graph_handlers.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python objects.Node类代码示例发布时间:2022-05-27
下一篇:
Python objects.ClusterPlugins类代码示例发布时间: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