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


Python objects.DeploymentGraph类代码示例

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


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


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