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


Python PluginManager.get_plugins_attributes方法代码示例

本文整理汇总了Python中nailgun.plugins.manager.PluginManager.get_plugins_attributes方法的典型用法代码示例。如果您正苦于以下问题:Python PluginManager.get_plugins_attributes方法的具体用法?Python PluginManager.get_plugins_attributes怎么用?Python PluginManager.get_plugins_attributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nailgun.plugins.manager.PluginManager的用法示例。


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

示例1: get_attributes

# 需要导入模块: from nailgun.plugins.manager import PluginManager [as 别名]
# 或者: from nailgun.plugins.manager.PluginManager import get_plugins_attributes [as 别名]
    def get_attributes(cls, instance, all_plugins_versions=False):
        """Get attributes for current Cluster instance.

        :param instance: Cluster instance
        :param all_plugins_versions: Get attributes of all versions of plugins
        :returns: dict
        """
        try:
            attrs = db().query(models.Attributes).filter(
                models.Attributes.cluster_id == instance.id
            ).one()
        except MultipleResultsFound:
            raise errors.InvalidData(
                u"Multiple rows with attributes were found for cluster '{0}'"
                .format(instance.name)
            )
        except NoResultFound:
            raise errors.InvalidData(
                u"No attributes were found for cluster '{0}'"
                .format(instance.name)
            )
        attrs = dict(attrs)

        # Merge plugins attributes into editable ones
        plugin_attrs = PluginManager.get_plugins_attributes(
            instance, all_versions=all_plugins_versions)
        plugin_attrs = traverse(plugin_attrs, AttributesGenerator, {
            'cluster': instance,
            'settings': settings,
        })
        attrs['editable'].update(plugin_attrs)

        return attrs
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:35,代码来源:cluster.py

示例2: get_default_editable_attributes

# 需要导入模块: from nailgun.plugins.manager import PluginManager [as 别名]
# 或者: from nailgun.plugins.manager.PluginManager import get_plugins_attributes [as 别名]
    def get_default_editable_attributes(cls, instance):
        """Get editable attributes from release metadata

        :param instance: Cluster instance
        :returns: Dict object
        """
        editable = instance.release.attributes_metadata.get("editable")
        # Add default attributes of connected plugins
        plugin_attrs = PluginManager.get_plugins_attributes(
            instance, all_versions=True, default=True)
        editable = dict(plugin_attrs, **editable)
        editable = traverse(editable, AttributesGenerator, {
            'cluster': instance,
            'settings': settings,
        })

        return editable
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:19,代码来源:cluster.py

示例3: test_get_plugins_attributes_when_cluster_is_not_locked

# 需要导入模块: from nailgun.plugins.manager import PluginManager [as 别名]
# 或者: from nailgun.plugins.manager.PluginManager import get_plugins_attributes [as 别名]
    def test_get_plugins_attributes_when_cluster_is_not_locked(self):
        self.env.create(api=False)
        cluster = self.env.clusters[-1]
        plugin_a1 = self.env.create_plugin(
            name='plugin_a', version='1.0.1',
            cluster=cluster, enabled=False
        )
        plugin_a2 = self.env.create_plugin(
            name='plugin_a', version='1.0.2', is_hotpluggable=True,
            cluster=cluster, enabled=True
        )
        plugin_b = self.env.create_plugin(
            name='plugin_b', title='plugin_a_title', cluster=cluster
        )
        self.assertFalse(plugin_a1.is_hotpluggable)
        self.assertTrue(plugin_a2.is_hotpluggable)
        self.assertFalse(plugin_b.is_hotpluggable)
        self.assertFalse(cluster.is_locked)
        attributes = PluginManager.get_plugins_attributes(
            cluster, True, True
        )
        self.assertItemsEqual(
            ['plugin_a', 'plugin_b'], attributes
        )
        self.assertTrue(
            attributes['plugin_a']['metadata']['always_editable']
        )
        self.assertItemsEqual(
            [
                {
                    'data': str(plugin_a1.id),
                    'description': '',
                    'label': plugin_a1.version,
                    'restrictions': [
                        {
                            'action': 'disable',
                            'condition': 'cluster:is_locked'
                        }
                    ],
                },
                {
                    'data': str(plugin_a2.id),
                    'description': '',
                    'label': plugin_a2.version
                }
            ],
            attributes['plugin_a']['plugin_versions']['values']
        )
        self.assertEqual(
            str(plugin_a1.id),
            attributes['plugin_a']['plugin_versions']['value']
        )
        self.assertNotIn(
            'always_editable', attributes['plugin_b']['metadata']
        )
        self.assertItemsEqual(
            [
                {
                    'restrictions': [
                        {
                            'action': 'disable',
                            'condition': 'cluster:is_locked'
                        }
                    ],
                    'data': str(plugin_b.id),
                    'description': '',
                    'label': plugin_b.version,
                },
            ],
            attributes['plugin_b']['plugin_versions']['values']
        )

        self.assertEqual(
            str(plugin_b.id),
            attributes['plugin_b']['plugin_versions']['value']
        )
开发者ID:mba811,项目名称:fuel-web,代码行数:78,代码来源:test_plugin_manager.py

示例4: test_get_plugins_attributes_when_cluster_is_not_locked

# 需要导入模块: from nailgun.plugins.manager import PluginManager [as 别名]
# 或者: from nailgun.plugins.manager.PluginManager import get_plugins_attributes [as 别名]
    def test_get_plugins_attributes_when_cluster_is_not_locked(self):
        cluster = self.env.create(api=False)
        plugin_a1 = self.env.create_plugin(
            name='plugin_a', version='1.0.1',
            cluster=cluster, enabled=False
        )
        plugin_a2 = self.env.create_plugin(
            name='plugin_a', version='1.0.2', is_hotpluggable=True,
            cluster=cluster, enabled=True
        )
        plugin_b = self.env.create_plugin(
            name='plugin_b', title='plugin_a_title', cluster=cluster,
            attributes_metadata={
                'attributes': {
                    'metadata': {
                        'restrictions': [
                            {
                                "condition": "test_condition",
                                "action": "hide"
                            }
                        ]
                    }
                }
            }
        )
        self.assertFalse(plugin_a1.is_hotpluggable)
        self.assertTrue(plugin_a2.is_hotpluggable)
        self.assertFalse(plugin_b.is_hotpluggable)
        self.assertFalse(cluster.is_locked)
        attributes = PluginManager.get_plugins_attributes(
            cluster, all_versions=True, default=True
        )

        pl_a1 = attributes['plugin_a']['metadata']['versions'][0]
        pl_a2 = attributes['plugin_a']['metadata']['versions'][1]
        pl_b = attributes['plugin_b']['metadata']['versions'][0]

        self.assertItemsEqual(['plugin_a', 'plugin_b'], attributes)

        self.assertItemsEqual(
            {
                'plugin_id': plugin_a1.id,
                'plugin_version': plugin_a1.version,
                'hot_pluggable': False,
                'contains_legacy_tasks': False
            }, pl_a1['metadata']
        )
        self.assertItemsEqual(
            {
                'plugin_id': plugin_a2.id,
                'plugin_version': plugin_a2.version,
                'hot_pluggable': True,
                'contains_legacy_tasks': False
            },
            pl_a2['metadata']
        )
        self.assertItemsEqual(
            {
                'plugin_id': plugin_b.id,
                'plugin_version': plugin_b.version,
                'hot_pluggable': False,
                'contains_legacy_tasks': False,
                'restrictions': [
                    {
                        "condition": "cluster:net_provider != 'neutron'",
                        "action": "hide"
                    }
                ]
            }, pl_b['metadata']
        )
        self.assertEqual(
            plugin_a1.id,
            attributes['plugin_a']['metadata']['chosen_id']
        )
        self.assertEqual(
            plugin_b.id,
            attributes['plugin_b']['metadata']['chosen_id']
        )
开发者ID:sebrandon1,项目名称:fuel-web,代码行数:80,代码来源:test_plugin_manager.py

示例5: test_get_plugins_attributes_when_cluster_is_locked

# 需要导入模块: from nailgun.plugins.manager import PluginManager [as 别名]
# 或者: from nailgun.plugins.manager.PluginManager import get_plugins_attributes [as 别名]
    def test_get_plugins_attributes_when_cluster_is_locked(self):
        self.env.create(api=False)
        cluster = self.env.clusters[-1]
        plugin_a1 = self.env.create_plugin(
            name='plugin_a', version='1.0.1',
            cluster=cluster, enabled=False
        )
        plugin_a2 = self.env.create_plugin(
            name='plugin_a', version='1.0.2', is_hotpluggable=True,
            cluster=cluster, enabled=False
        )
        plugin_b = self.env.create_plugin(
            name='plugin_b', title='plugin_a_title', cluster=cluster,
            attributes_metadata={
                'metadata': {
                    'restrictions': [
                        {
                            "condition": "cluster:net_provider != 'neutron'",
                            "action": "hide"
                        }
                    ]
                }
            }
        )
        cluster.status = consts.CLUSTER_STATUSES.operational
        self.db.flush()
        self.assertTrue(cluster.is_locked)
        attributes = PluginManager.get_plugins_attributes(
            cluster, all_versions=True, default=True
        )

        pl_a1 = attributes['plugin_a']['metadata']['versions'][0]
        pl_a2 = attributes['plugin_a']['metadata']['versions'][1]
        pl_b = attributes['plugin_b']['metadata']['versions'][0]

        self.assertItemsEqual(['plugin_a', 'plugin_b'], attributes)
        self.assertItemsEqual(
            {
                'plugin_id': plugin_a1.id,
                'plugin_version': plugin_a1.version,
                'always_editable': False
            }, pl_a1['metadata']
        )
        self.assertItemsEqual(
            {
                'plugin_id': plugin_a2.id,
                'plugin_version': plugin_a2.version,
                'always_editable': True
            },
            pl_a2['metadata']
        )
        self.assertItemsEqual(
            {
                'plugin_id': plugin_b.id,
                'plugin_version': plugin_b.version,
                'always_editable': False,
                'restrictions': [
                    {
                        "condition": "cluster:net_provider != 'neutron'",
                        "action": "hide"
                    }
                ]
            }, pl_b['metadata']
        )
        self.assertEqual(
            plugin_a1.id,
            attributes['plugin_a']['metadata']['chosen_id']
        )
        self.assertEqual(
            plugin_b.id,
            attributes['plugin_b']['metadata']['chosen_id']
        )
开发者ID:ansumanbebarta,项目名称:fuel-web,代码行数:74,代码来源:test_plugin_manager.py


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