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


Python adapters.wrap_plugin函数代码示例

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


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

示例1: get_cluster_plugins_with_tasks

 def get_cluster_plugins_with_tasks(cls, cluster):
     cluster_plugins = []
     for plugin_db in cluster.plugins:
         plugin_adapter = wrap_plugin(plugin_db)
         plugin_adapter.set_cluster_tasks()
         cluster_plugins.append(plugin_adapter)
     return cluster_plugins
开发者ID:ymkins,项目名称:fuel-web,代码行数:7,代码来源:manager.py

示例2: get_cluster_plugins_with_tasks

 def get_cluster_plugins_with_tasks(cls, cluster):
     cluster_plugins = []
     for plugin_db in ClusterPlugins.get_enabled(cluster.id):
         plugin_adapter = wrap_plugin(plugin_db)
         plugin_adapter.set_cluster_tasks()
         cluster_plugins.append(plugin_adapter)
     return cluster_plugins
开发者ID:mba811,项目名称:fuel-web,代码行数:7,代码来源:manager.py

示例3: get_plugins_node_roles

    def get_plugins_node_roles(cls, cluster):
        result = {}
        core_roles = set(cluster.release.roles_metadata)

        for plugin_db in cluster.plugins:
            plugin_roles = wrap_plugin(plugin_db).normalized_roles_metadata

            # we should check all possible cases of roles intersection
            # with core ones and those from other plugins
            # and afterwards show them in error message;
            # thus role names for which following checks
            # fails are accumulated in err_info variable
            err_roles = set()
            if set(plugin_roles) & core_roles:
                err_roles |= set(plugin_roles) & core_roles
            if set(plugin_roles) & set(result):
                err_roles |= set(plugin_roles) & set(result)

            if err_roles:
                raise errors.AlreadyExists(
                    "Plugin (ID={0}) is unable to register the following "
                    "node roles: {1}".format(plugin_db.id,
                                             ", ".join(err_roles))
                )

            # update info on processed roles in case of
            # success of all intersection checks
            result.update(plugin_roles)

        return result
开发者ID:ymkins,项目名称:fuel-web,代码行数:30,代码来源:manager.py

示例4: get_plugin_attributes

 def get_plugin_attributes(cls, cluster):
     plugin_attributes = {}
     for plugin_db in PluginCollection.all_newest():
         plugin_adapter = wrap_plugin(plugin_db)
         attributes = plugin_adapter.get_plugin_attributes(cluster)
         plugin_attributes.update(attributes)
     return plugin_attributes
开发者ID:ymkins,项目名称:fuel-web,代码行数:7,代码来源:manager.py

示例5: test_get_particular_role_for_cluster_w_plugin

    def test_get_particular_role_for_cluster_w_plugin(self):
        plugin_data = self.env.get_default_plugin_metadata()
        plugin_data['roles_metadata'] = self.ROLES
        plugin_data['volumes_metadata'] = self.VOLUMES
        plugin = objects.Plugin.create(plugin_data)
        self.cluster.plugins.append(plugin)
        objects.ClusterPlugin.set_attributes(self.cluster.id,
                                             plugin.id,
                                             enabled=True)
        self.db.flush()
        plugin_adapter = adapters.wrap_plugin(plugin)

        role = self.app.get(
            url=base.reverse(
                'ClusterRolesHandler',
                {'cluster_id': self.cluster.id, 'role_name': 'test_role'}
            )
        ).json

        self.assertEqual(role['name'], 'test_role')
        self.assertDictEqual(
            role['meta'],
            plugin_adapter.normalized_roles_metadata['test_role']
        )
        self.assertItemsEqual(
            role['volumes_roles_mapping'],
            plugin_adapter.volumes_metadata[
                'volumes_roles_mapping']['test_role']
        )
开发者ID:huyupeng,项目名称:fuel-web,代码行数:29,代码来源:test_cluster_roles_handler.py

示例6: sync_plugins_metadata

    def sync_plugins_metadata(cls, plugin_ids=None):
        """Sync metadata for plugins by given ids. If there is not
        ids all newest plugins will be synced
        """
        if plugin_ids:
            plugins = PluginCollection.get_by_uids(plugin_ids)
        else:
            plugins = PluginCollection.all()

        for plugin in plugins:
            plugin_adapter = wrap_plugin(plugin)
            plugin_adapter.sync_metadata_to_db()
开发者ID:anbangr,项目名称:fuel-web,代码行数:12,代码来源:manager.py

示例7: is_compatible

    def is_compatible(cls, cluster, plugin):
        """Validates if plugin is compatible with cluster.

        :param cluster: A cluster instance
        :type cluster: nailgun.db.sqlalchemy.models.cluster.Cluster
        :param plugin: A plugin instance
        :type plugin: nailgun.db.sqlalchemy.models.plugins.Plugin
        :return: True if compatible, False if not
        :rtype: bool
        """
        plugin_adapter = wrap_plugin(plugin)

        return plugin_adapter.validate_compatibility(cluster)
开发者ID:huyupeng,项目名称:fuel-web,代码行数:13,代码来源:plugin.py

示例8: create

    def create(cls, data):
        new_plugin = super(Plugin, cls).create(data)

        # FIXME (vmygal): This is very ugly hack and it must be fixed ASAP.
        # Need to remove the syncing of plugin metadata from here.
        # All plugin metadata must be sent via 'data' argument of this
        # function and it must be fixed in 'python-fuelclient' repository.
        from nailgun.plugins.adapters import wrap_plugin
        plugin_adapter = wrap_plugin(new_plugin)
        plugin_adapter.sync_metadata_to_db()

        ClusterPlugins.add_compatible_clusters(new_plugin)

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

示例9: 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

示例10: setUp

    def setUp(self):
        super(TestPrePostHooks, self).setUp()

        self._requests_mock = mock.patch(
            'nailgun.utils.debian.requests.get',
            return_value=mock.Mock(text='Archive: test'))
        self._requests_mock.start()

        resp = self.create_plugin()
        self.plugin = adapters.wrap_plugin(
            objects.Plugin.get_by_uid(resp.json['id']))
        self.cluster = self.create_cluster([
            {'roles': ['controller'], 'pending_addition': True},
            {'roles': ['compute'], 'pending_addition': True}])
        self.enable_plugin(self.cluster, self.sample_plugin['name'])
开发者ID:naveenzhang,项目名称:fuel-web,代码行数:15,代码来源:test_plugins_api.py

示例11: get_plugins_attributes

    def get_plugins_attributes(
            cls, cluster, all_versions=False, default=False):
        """Gets attributes of all plugins connected with given cluster.

        :param cluster: A cluster instance
        :type cluster: nailgun.db.sqlalchemy.models.cluster.Cluster
        :param all_versions: True to get attributes of all versions of plugins
        :type all_versions: bool
        :param default: True to return a default plugins attributes (for UI)
        :type default: bool
        :return: Plugins attributes
        :rtype: dict
        """
        plugins_attributes = {}
        for plugin in ClusterPlugins.get_connected_plugins_data(cluster.id):
            db_plugin = Plugin.get_by_uid(plugin.id)
            plugin_adapter = wrap_plugin(db_plugin)
            default_attrs = plugin_adapter.attributes_metadata

            if all_versions:
                container = plugins_attributes.setdefault(plugin.name, {})
                enabled = plugin.enabled and not (all_versions and default)
                cls.create_common_metadata(plugin, container, enabled)
                container['metadata']['default'] = default

                versions = container['metadata'].setdefault('versions', [])
                if default:
                    actual_attrs = copy.deepcopy(default_attrs)
                    actual_attrs.setdefault('metadata', {})
                else:
                    actual_attrs = copy.deepcopy(plugin.attributes)
                    actual_attrs['metadata'] = default_attrs.get('metadata',
                                                                 {})
                cls.fill_plugin_metadata(plugin, actual_attrs['metadata'])
                versions.append(actual_attrs)

                container['metadata'].setdefault('chosen_id', plugin.id)
                if enabled:
                    container['metadata']['chosen_id'] = plugin.id

            elif plugin.enabled:
                container = plugins_attributes.setdefault(plugin.name, {})
                cls.create_common_metadata(plugin, container)
                container['metadata'].update(default_attrs.get('metadata', {}))
                cls.fill_plugin_metadata(plugin, container['metadata'])
                container.update(plugin.attributes)

        return plugins_attributes
开发者ID:ogelbukh,项目名称:fuel-web,代码行数:48,代码来源:manager.py

示例12: sync_plugins_metadata

    def sync_plugins_metadata(cls, plugin_ids=None):
        """Sync metadata for plugins by given IDs.

        If there are no IDs, all newest plugins will be synced.

        :param plugin_ids: list of plugin IDs
        :type plugin_ids: list
        """
        if plugin_ids:
            plugins = PluginCollection.get_by_uids(plugin_ids)
        else:
            plugins = PluginCollection.all()

        for plugin in plugins:
            plugin_adapter = wrap_plugin(plugin)
            plugin_adapter.sync_metadata_to_db()
开发者ID:mba811,项目名称:fuel-web,代码行数:16,代码来源:manager.py

示例13: setUp

    def setUp(self):
        super(TestPrePostHooks, self).setUp()

        self._requests_mock = mock.patch(
            "nailgun.utils.debian.requests.get", return_value=mock.Mock(text="Archive: test")
        )
        self._requests_mock.start()

        resp = self.create_plugin()
        self.plugin = adapters.wrap_plugin(objects.Plugin.get_by_uid(resp.json["id"]))
        self.cluster = self.create_cluster(
            [{"roles": ["controller"], "pending_addition": True}, {"roles": ["compute"], "pending_addition": True}]
        )
        objects.Cluster.prepare_for_deployment(self.cluster)

        self.enable_plugin(self.cluster, self.sample_plugin["name"], resp.json["id"])
开发者ID:mba811,项目名称:fuel-web,代码行数:16,代码来源:test_plugins_api.py

示例14: setUp

    def setUp(self):
        super(TestPluginBase, self).setUp()
        self.plugin_metadata = self.env.get_default_plugin_metadata(
            package_version=self.package_version)
        self.plugin = Plugin.create(self.plugin_metadata)
        self.env.create(
            cluster_kwargs={'mode': 'multinode'},
            release_kwargs={
                'version': '2014.2-6.0',
                'operating_system': 'Ubuntu'})
        self.cluster = self.env.clusters[0]
        self.plugin_adapter = adapters.wrap_plugin(self.plugin)
        self.env_config = self.env.get_default_plugin_env_config()
        self.get_config = lambda *args: mock.mock_open(
            read_data=yaml.dump(self.env_config))()

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

示例15: enable_plugins_by_components

    def enable_plugins_by_components(cls, cluster):
        """Enable plugin by components.

        :param cluster: A cluster instance
        :type cluster: Cluster model
        """
        cluster_components = set(cluster.components)
        plugin_ids = [p.id for p in PluginCollection.all_newest()]

        for plugin in ClusterPlugins.get_connected_plugins(
                cluster, plugin_ids):
            plugin_adapter = wrap_plugin(plugin)
            plugin_components = set(
                component['name']
                for component in plugin_adapter.components_metadata)

            if cluster_components & plugin_components:
                ClusterPlugins.set_attributes(
                    cluster.id, plugin.id, enabled=True)
开发者ID:ogelbukh,项目名称:fuel-web,代码行数:19,代码来源:manager.py


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