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

Python manager.PluginManager类代码示例

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

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



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

示例1: test_raise_exception_when_plugin_overlap_release_component

    def test_raise_exception_when_plugin_overlap_release_component(self):
        release = self.env.create_release(
            version='2015.1-8.1',
            operating_system='Ubuntu',
            modes=[consts.CLUSTER_MODES.ha_compact],
            components_metadata=self.env.get_default_components())

        self.env.create_plugin(
            name='plugin_with_components',
            package_version='4.0.0',
            fuel_version=['8.0'],
            releases=[{
                'repository_path': 'repositories/ubuntu',
                'version': '2015.1-8.1', 'os': 'ubuntu',
                'mode': ['ha'],
                'deployment_scripts_path': 'deployment_scripts/'}],
            components_metadata=self.env.get_default_components())

        expected_message = (
            'Plugin plugin_with_components is overlapping with release '
            'by introducing the same component with name '
            '"hypervisor:test_hypervisor"')

        with self.assertRaisesRegexp(errors.AlreadyExists,
                                     expected_message):
            PluginManager.get_components_metadata(release)
开发者ID:sebrandon1,项目名称:fuel-web,代码行数:26,代码来源:test_plugin_manager.py


示例2: test_raise_exception_when_plugin_overlap_release_volumes

    def test_raise_exception_when_plugin_overlap_release_volumes(self):
        cluster = self.env.create_cluster(api=False)
        plugin_name = 'test_plugin_3'
        volumes_metadata = {
            'volumes_roles_mapping': {
                plugin_name: [
                    {'allocate_size': 'min', 'id': plugin_name}
                ]
            },
            'volumes': [
                {'id': 'os', 'type': 'vg'},
                {'id': plugin_name, 'type': 'vg'}
            ]
        }
        self.env.create_plugin(
            api=True,
            cluster=cluster,
            name=plugin_name,
            package_version='3.0.0',
            fuel_version=['7.0'],
            volumes_metadata=volumes_metadata
        )

        expected_message = (
            'Plugin test_plugin_3-0.1.0 is overlapping with release '
            'by introducing the same volume with id "os"')

        with self.assertRaisesRegexp(errors.AlreadyExists,
                                     expected_message):
            PluginManager.get_volumes_metadata(cluster)
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:30,代码来源:test_plugin_manager.py


示例3: test_raise_exception_when_plugin_overlap_another_plugin_volumes

    def test_raise_exception_when_plugin_overlap_another_plugin_volumes(self):
        plugin_name = 'test_plugin_4'
        volumes_metadata = {
            'volumes_roles_mapping': {
                plugin_name: [
                    {'allocate_size': 'min', 'id': plugin_name}
                ]
            },
            'volumes': [
                {'id': 'test_plugin_2', 'type': 'vg'},
                {'id': plugin_name, 'type': 'vg'}
            ]
        }
        self.env.create_plugin(
            cluster=self.cluster,
            name=plugin_name,
            package_version='3.0.0',
            fuel_version=['7.0'],
            volumes_metadata=volumes_metadata
        )

        expected_message = (
            'Plugin test_plugin_4-0.1.0 is overlapping with plugin '
            'test_plugin_2-0.1.0 by introducing the same volume '
            'with id "test_plugin_2"')

        with self.assertRaisesRegexp(errors.AlreadyExists,
                                     expected_message):
            PluginManager.get_volumes_metadata(self.cluster)
开发者ID:sebrandon1,项目名称:fuel-web,代码行数:29,代码来源:test_plugin_manager.py


示例4: patch_attributes

 def patch_attributes(cls, instance, data):
     PluginManager.process_cluster_attributes(instance, data['editable'])
     instance.attributes.editable = dict_merge(
         instance.attributes.editable, data['editable'])
     cls.add_pending_changes(instance, "attributes")
     cls.get_network_manager(instance).update_restricted_networks(instance)
     db().flush()
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:7,代码来源:cluster.py


示例5: update_attributes

    def update_attributes(cls, instance, data):
        PluginManager.process_cluster_attributes(instance, data['editable'])

        for key, value in data.iteritems():
            setattr(instance.attributes, key, value)
        cls.add_pending_changes(instance, "attributes")
        db().flush()
开发者ID:linglong0820,项目名称:fuel-web,代码行数:7,代码来源:cluster.py


示例6: create_attributes

    def create_attributes(cls, instance):
        """Create attributes for interface with default values.

        :param instance: NodeNICInterface instance
        :type instance: NodeNICInterface model
        :returns: None
        """
        instance.attributes = cls._get_default_attributes(instance)
        PluginManager.add_plugin_attributes_for_interface(instance)

        db().flush()
开发者ID:openstack,项目名称:fuel-web,代码行数:11,代码来源:interface.py


示例7: test_get_specific_version

    def test_get_specific_version(self):
        versions = [
            {'metadata': {'plugin_id': '1'}},
            {'metadata': {'plugin_id': '2'}}
        ]

        plugin_version_attrs = PluginManager._get_specific_version(
            versions, '1')
        self.assertEqual(versions[0], plugin_version_attrs)
        not_existed_plugin_version_attrs = PluginManager._get_specific_version(
            versions, '3')
        self.assertEqual({}, not_existed_plugin_version_attrs)
开发者ID:sebrandon1,项目名称:fuel-web,代码行数:12,代码来源:test_plugin_manager.py


示例8: POST

    def POST(self):
        """:returns: JSONized REST object.
        :http: * 200 (plugins successfully synced)
               * 404 (plugin not found in db)
               * 400 (problem with parsing metadata file)
        """
        data = self.checked_data()
        ids = data.get("ids", None)

        try:
            PluginManager.sync_plugins_metadata(plugin_ids=ids)
        except errors.ParseError as exc:
            raise self.http(400, msg=six.text_type(exc))

        raise self.http(200)
开发者ID:nebril,项目名称:fuel-web,代码行数:15,代码来源:plugin.py


示例9: update

    def update(cls, instance, data):
        """Update data of native and plugin attributes for interface.

        :param instance: NodeNICInterface instance
        :type instance: NodeNICInterface model
        :param data: Data to update
        :type data: dict
        :returns: instance of an object (model)
        """
        attributes = data.pop('attributes', None)
        if attributes:
            PluginManager.update_nic_attributes(attributes)
            instance.attributes = utils.dict_merge(
                instance.attributes, attributes)

        return super(NIC, cls).update(instance, data)
开发者ID:openstack,项目名称:fuel-web,代码行数:16,代码来源:interface.py


示例10: serialize

 def serialize(self):
     plugins = PluginManager.get_cluster_plugins_with_tasks(self.cluster)
     return itertools.chain(
         self.create_repositories(plugins),
         self.sync_scripts(plugins),
         self.deployment_tasks(plugins)
     )
开发者ID:ansumanbebarta,项目名称:fuel-web,代码行数:7,代码来源:plugins_serializers.py


示例11: serialize

 def serialize(self):
     tasks = []
     plugins = PluginManager.get_cluster_plugins_with_tasks(self.cluster)
     tasks.extend(self.create_repositories(plugins))
     tasks.extend(self.sync_scripts(plugins))
     tasks.extend(self.deployment_tasks(plugins))
     return tasks
开发者ID:SmartInfrastructures,项目名称:fuel-web-dev,代码行数:7,代码来源:plugins_serializers.py


示例12: validate_allowed_attributes

    def validate_allowed_attributes(cls, cluster, data, force):
        """Validates if attributes are hot pluggable or not.

        :param cluster: A cluster instance
        :type cluster: nailgun.db.sqlalchemy.models.cluster.Cluster
        :param data: Changed attributes of cluster
        :type data: dict
        :param force: Allow forcefully update cluster attributes
        :type force: bool
        :raises: errors.NotAllowed
        """
        # TODO(need to enable restrictions check for cluster attributes[1])
        # [1] https://bugs.launchpad.net/fuel/+bug/1519904
        # Validates only that plugin can be installed on deployed env.

        # If cluster is locked we have to check which attributes
        # we want to change and block an entire operation if there
        # one with always_editable=False.
        if not cluster.is_locked or force:
            return

        editable_cluster = objects.Cluster.get_editable_attributes(
            cluster, all_plugins_versions=True)
        editable_request = data.get('editable', {})

        for attr_name, attr_request in six.iteritems(editable_request):
            attr_cluster = editable_cluster.get(attr_name, {})
            meta_cluster = attr_cluster.get('metadata', {})
            meta_request = attr_request.get('metadata', {})

            if PluginManager.is_plugin_data(attr_cluster):
                if meta_request['enabled']:
                    changed_ids = [meta_request['chosen_id']]
                    if meta_cluster['enabled']:
                        changed_ids.append(meta_cluster['chosen_id'])
                    changed_ids = set(changed_ids)
                elif meta_cluster['enabled']:
                    changed_ids = [meta_cluster['chosen_id']]
                else:
                    continue

                for plugin in meta_cluster['versions']:
                    plugin_id = plugin['metadata']['plugin_id']
                    always_editable = plugin['metadata']\
                        .get('always_editable', False)
                    if plugin_id in changed_ids and not always_editable:
                        raise errors.NotAllowed(
                            "Plugin '{0}' version '{1}' couldn't be changed "
                            "after or during deployment."
                            .format(attr_name,
                                    plugin['metadata']['plugin_version']),
                            log_message=True
                        )

            elif not meta_cluster.get('always_editable', False):
                raise errors.NotAllowed(
                    "Environment attribute '{0}' couldn't be changed "
                    "after or during deployment.".format(attr_name),
                    log_message=True
                )
开发者ID:mmalchuk,项目名称:openstack-fuel-web,代码行数:60,代码来源:cluster.py


示例13: get_all_components

    def get_all_components(cls, instance):
        """Get all components related to release

        Due to components architecture compatible/incompatible are duplex
        relations. So if some component is compatible/incompatible with another
        the last one also should have such relation.

        :param instance: Release instance
        :type instance: Release DB instance
        :returns: list -- list of all components
        """
        plugin_components = PluginManager.get_components_metadata(instance)
        components = copy.deepcopy(
            instance.components_metadata + plugin_components)
        # we should provide commutative property for compatible/incompatible
        # relations between components
        for comp_i, comp_j in itertools.permutations(components, 2):
            if cls._check_relation(comp_j, comp_i, 'incompatible'):
                comp_i.setdefault('incompatible', []).append({
                    'name': comp_j['name'],
                    'message': "Not compatible with {0}".format(
                        comp_j.get('label') or comp_j.get('name'))})
            if cls._check_relation(comp_j, comp_i, 'compatible'):
                comp_i.setdefault('compatible', []).append({
                    'name': comp_j['name']})

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


示例14: get_network_roles

    def get_network_roles(cls, instance):
        """Method for receiving network roles for particular cluster

        :param instance: nailgun.db.sqlalchemy.models.Cluster instance
        :returns: List of network roles' descriptions
        """
        return instance.release.network_roles_metadata + PluginManager.get_network_roles(instance)
开发者ID:anbangr,项目名称:fuel-web,代码行数:7,代码来源:cluster.py


示例15: get_attributes

    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,代码行数:33,代码来源:cluster.py


示例16: get_default_attributes

    def get_default_attributes(cls, instance):
        """Get default attributes for interface.

        :param instance: NodeNICInterface instance
        :type instance: NodeNICInterface model
        :returns: dict -- Dict object of NIC attributes
        """
        attributes = cls._get_default_attributes(instance)
        attributes = utils.dict_merge(
            attributes,
            PluginManager.get_nic_attributes(instance))
        attributes = utils.dict_merge(
            attributes,
            PluginManager.get_nic_default_attributes(
                instance.node.cluster))

        return attributes
开发者ID:openstack,项目名称:fuel-web,代码行数:17,代码来源:interface.py


示例17: update

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

        :param instance: object (model) instance
        :param data: dictionary of key-value pairs as object fields
        :returns: instance of an object (model)
        """
        attributes = data.pop('attributes', None)
        if attributes:
            PluginManager.update_bond_attributes(attributes)
            instance.attributes = utils.dict_merge(
                instance.attributes, attributes)

        instance = super(Bond, cls).update(instance, data)
        instance.offloading_modes = data.get('offloading_modes', {})

        return instance
开发者ID:openstack,项目名称:fuel-web,代码行数:17,代码来源:bond.py


示例18: get_network_roles

    def get_network_roles(
            cls, instance, merge_policy=NetworkRoleMergePolicy()):
        """Method for receiving network roles for particular cluster

        :param instance: nailgun.db.sqlalchemy.models.Cluster instance
        :param merge_policy: the policy to merge same roles
        :returns: List of network roles' descriptions
        """
        return PluginManager.get_network_roles(instance, merge_policy)
开发者ID:gdyuldin,项目名称:fuel-web,代码行数:9,代码来源:cluster.py


示例19: get_all_components

    def get_all_components(cls, instance):
        """Get all components related to release

        :param instance: Release instance
        :type instance: Release DB instance
        :returns: list -- list of all components
        """
        plugin_components = PluginManager.get_components_metadata(instance)
        return instance.components_metadata + plugin_components
开发者ID:vangogh-ken,项目名称:fuel-web,代码行数:9,代码来源:release.py


示例20: get_roles

    def get_roles(cls, instance):
        """Returns a dictionary of node roles available for deployment.

        :param instance: cluster instance
        :returns: a dictionary of roles metadata
        """
        available_roles = copy.deepcopy(instance.release.roles_metadata)
        available_roles.update(PluginManager.get_plugins_node_roles(instance))
        return available_roles
开发者ID:anbangr,项目名称:fuel-web,代码行数:9,代码来源:cluster.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python rpc.cast函数代码示例发布时间:2022-05-27
下一篇:
Python adapters.wrap_plugin函数代码示例发布时间: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