當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。