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

Python resource_registry.register_resource_by_name函数代码示例

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

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



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

示例1: setUp

 def setUp(self):
     super(QuotaExtensionTestCase, self).setUp()
     resource_registry.register_resource_by_name('pool')
     resource_registry.register_resource_by_name('loadbalancer')
     resource_registry.register_resource_by_name('listener')
     resource_registry.register_resource_by_name('healthmonitor')
     resource_registry.register_resource_by_name('member')
开发者ID:openstack,项目名称:neutron-lbaas,代码行数:7,代码来源:base.py


示例2: register_resources_from_config

def register_resources_from_config():
    # This operation is now deprecated. All the neutron core and extended
    # resource for which  quota limits are enforced explicitly register
    # themselves with the quota engine.
    for resource_item in (set(cfg.CONF.QUOTAS.quota_items) -
                          set(default_quota_items)):
        resource_registry.register_resource_by_name(resource_item)
开发者ID:punithks,项目名称:neutron,代码行数:7,代码来源:__init__.py


示例3: setUp

    def setUp(self):
        super(QuotaExtensionTestCase, self).setUp()
        # Ensure existing ExtensionManager is not used
        extensions.PluginAwareExtensionManager._instance = None

        self.useFixture(tools.AttributeMapMemento())

        # Create the default configurations
        self.config_parse()

        # Update the plugin and extensions path
        self.setup_coreplugin(TARGET_PLUGIN)
        cfg.CONF.set_override(
            'quota_items',
            ['network', 'subnet', 'port', 'extra1'],
            group='QUOTAS')
        quota.QUOTAS = quota.QuotaEngine()
        quota.register_resources_from_config()
        self._plugin_patcher = mock.patch(TARGET_PLUGIN, autospec=True)
        self.plugin = self._plugin_patcher.start()
        self.plugin.return_value.supported_extension_aliases = ['quotas']
        # QUOTAS will register the items in conf when starting
        # extra1 here is added later, so have to do it manually
        resource_registry.register_resource_by_name('extra1')
        ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
        app = config.load_paste_app('extensions_test_app')
        ext_middleware = extensions.ExtensionMiddleware(app, ext_mgr=ext_mgr)
        self.api = webtest.TestApp(ext_middleware)
        # Initialize the router for the core API in order to ensure core quota
        # resources are registered
        router.APIRouter()
开发者ID:HoratiusTang,项目名称:neutron,代码行数:31,代码来源:test_quotasv2.py


示例4: initialize_all

def initialize_all():
    ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
    ext_mgr.extend_resources("2.0", attributes.RESOURCE_ATTRIBUTE_MAP)
    # At this stage we have a fully populated resource attribute map;
    # build Pecan controllers and routes for every resource (both core
    # and extensions)
    pecanized_exts = [ext for ext in ext_mgr.extensions.values() if hasattr(ext, "get_pecan_controllers")]
    pecan_controllers = {}
    for ext in pecanized_exts:
        LOG.debug("Extension %s is pecan-enabled. Fetching resources " "and controllers", ext.get_name())
        controllers = ext.get_pecan_controllers()
        # controllers is actually a list of pairs where the first element is
        # the collection name and the second the actual controller
        for (collection, coll_controller) in controllers:
            pecan_controllers[collection] = coll_controller

    for collection in attributes.RESOURCE_ATTRIBUTE_MAP:
        if collection not in pecan_controllers:
            resource = _handle_plurals(collection)
            LOG.debug("Building controller for resource:%s", resource)
            plugin = _plugin_for_resource(collection)
            if plugin:
                manager.NeutronManager.set_plugin_for_resource(resource, plugin)
            controller = root.CollectionsController(collection, resource)
            manager.NeutronManager.set_controller_for_resource(collection, controller)
            LOG.info(
                _LI("Added controller for resource %(resource)s " "via URI path segment:%(collection)s"),
                {"resource": resource, "collection": collection},
            )
        else:
            LOG.debug("There are already controllers for resource:%s", resource)

    # NOTE(salv-orlando): If you are care about code quality, please read below
    # Hackiness is strong with the piece of code below. It is used for
    # populating resource plurals and registering resources with the quota
    # engine, but the method it calls were not conceived with this aim.
    # Therefore it only leverages side-effects from those methods. Moreover,
    # as it is really not advisable to load an instance of
    # neutron.api.v2.router.APIRouter just to register resources with the
    # quota  engine, core resources are explicitly registered here.
    # TODO(salv-orlando): The Pecan WSGI support should provide its own
    # solution to manage resource plurals and registration of resources with
    # the quota engine
    for resource in router.RESOURCES.keys():
        resource_registry.register_resource_by_name(resource)
    for ext in ext_mgr.extensions.values():
        # make each extension populate its plurals
        if hasattr(ext, "get_resources"):
            ext.get_resources()
        if hasattr(ext, "get_extended_resources"):
            ext.get_extended_resources("v2.0")
    # Certain policy checks require that the extensions are loaded
    # and the RESOURCE_ATTRIBUTE_MAP populated before they can be
    # properly initialized. This can only be claimed with certainty
    # once this point in the code has been reached. In the event
    # that the policies have been initialized before this point,
    # calling reset will cause the next policy check to
    # re-initialize with all of the required data in place.
    policy.reset()
开发者ID:davidcusatis,项目名称:neutron,代码行数:59,代码来源:startup.py


示例5: build_resource_info

def build_resource_info(plural_mappings, resource_map, which_service,
                        action_map=None, register_quota=False,
                        translate_name=False, allow_bulk=False):
    """Build resources for advanced services.

    Takes the resource information, and singular/plural mappings, and creates
    API resource objects for advanced services extensions. Will optionally
    translate underscores to dashes in resource names, register the resource,
    and accept action information for resources.

    :param plural_mappings: mappings between singular and plural forms
    :param resource_map: attribute map for the WSGI resources to create
    :param which_service: The name of the service for which the WSGI resources
                          are being created. This name will be used to pass
                          the appropriate plugin to the WSGI resource.
                          It can be set to None or "CORE" to create WSGI
                          resources for the core plugin
    :param action_map: custom resource actions
    :param register_quota: it can be set to True to register quotas for the
                           resource(s) being created
    :param translate_name: replaces underscores with dashes
    :param allow_bulk: True if bulk create are allowed
    """
    resources = []
    if not which_service:
        which_service = constants.CORE
    if action_map is None:
        action_map = {}
    if which_service != constants.CORE:
        plugin = manager.NeutronManager.get_service_plugins()[which_service]
    else:
        plugin = manager.NeutronManager.get_plugin()
    path_prefix = getattr(plugin, "path_prefix", "")
    LOG.debug('Service %(service)s assigned prefix: %(prefix)s',
              {'service': which_service, 'prefix': path_prefix})
    for collection_name in resource_map:
        resource_name = plural_mappings[collection_name]
        params = resource_map.get(collection_name, {})
        if translate_name:
            collection_name = collection_name.replace('_', '-')
        if register_quota:
            resource_registry.register_resource_by_name(resource_name)
        member_actions = action_map.get(resource_name, {})
        controller = base.create_resource(
            collection_name, resource_name, plugin, params,
            member_actions=member_actions,
            allow_bulk=allow_bulk,
            allow_pagination=cfg.CONF.allow_pagination,
            allow_sorting=cfg.CONF.allow_sorting)
        resource = extensions.ResourceExtension(
            collection_name,
            controller,
            path_prefix=path_prefix,
            member_actions=member_actions,
            attr_map=params)
        resources.append(resource)
    return resources
开发者ID:annp,项目名称:neutron,代码行数:57,代码来源:resource_helper.py


示例6: get_resources

 def get_resources(cls):
     plural_mappings = resource_helper.build_plural_mappings(
         {}, RESOURCE_ATTRIBUTE_MAP)
     attr.PLURALS.update(plural_mappings)
     for resource_name in ['servicechain_node', 'servicechain_spec',
                           'servicechain_instance', 'service_profile']:
         resource_registry.register_resource_by_name(resource_name)
     return resource_helper.build_resource_info(plural_mappings,
                                                RESOURCE_ATTRIBUTE_MAP,
                                                constants.SERVICECHAIN)
开发者ID:anilgkurian,项目名称:group-based-policy,代码行数:10,代码来源:servicechain.py


示例7: __init__

    def __init__(self, **local_config):
        mapper = routes_mapper.Mapper()
        plugin = manager.NeutronManager.get_plugin()
        ext_mgr = extensions.PluginAwareExtensionManager.get_instance()
        ext_mgr.extend_resources("2.0", attributes.RESOURCE_ATTRIBUTE_MAP)

        col_kwargs = dict(collection_actions=COLLECTION_ACTIONS, member_actions=MEMBER_ACTIONS)

        def _map_resource(collection, resource, params, parent=None):
            allow_bulk = cfg.CONF.allow_bulk
            allow_pagination = cfg.CONF.allow_pagination
            allow_sorting = cfg.CONF.allow_sorting
            controller = base.create_resource(
                collection,
                resource,
                plugin,
                params,
                allow_bulk=allow_bulk,
                parent=parent,
                allow_pagination=allow_pagination,
                allow_sorting=allow_sorting,
            )
            path_prefix = None
            if parent:
                path_prefix = "/%s/{%s_id}/%s" % (parent["collection_name"], parent["member_name"], collection)
            mapper_kwargs = dict(
                controller=controller, requirements=REQUIREMENTS, path_prefix=path_prefix, **col_kwargs
            )
            return mapper.collection(collection, resource, **mapper_kwargs)

        mapper.connect("index", "/", controller=Index(RESOURCES))
        for resource in RESOURCES:
            _map_resource(
                RESOURCES[resource], resource, attributes.RESOURCE_ATTRIBUTE_MAP.get(RESOURCES[resource], dict())
            )
            resource_registry.register_resource_by_name(resource)

        for resource in SUB_RESOURCES:
            _map_resource(
                SUB_RESOURCES[resource]["collection_name"],
                resource,
                attributes.RESOURCE_ATTRIBUTE_MAP.get(SUB_RESOURCES[resource]["collection_name"], dict()),
                SUB_RESOURCES[resource]["parent"],
            )

        # Certain policy checks require that the extensions are loaded
        # and the RESOURCE_ATTRIBUTE_MAP populated before they can be
        # properly initialized. This can only be claimed with certainty
        # once this point in the code has been reached. In the event
        # that the policies have been initialized before this point,
        # calling reset will cause the next policy check to
        # re-initialize with all of the required data in place.
        policy.reset()
        super(APIRouter, self).__init__(mapper)
开发者ID:yizhongyin,项目名称:OpenstackLiberty,代码行数:54,代码来源:router.py


示例8: register_resources_from_config

def register_resources_from_config():
    # This operation is now deprecated. All the neutron core and extended
    # resource for which  quota limits are enforced explicitly register
    # themselves with the quota engine.
    versionutils.report_deprecated_feature(
        LOG, _LW("Registering resources to apply quota limits to using the "
                 "quota_items option is deprecated as of Liberty."
                 "Resource REST controllers should take care of registering "
                 "resources with the quota engine."))
    for resource_item in (set(cfg.CONF.QUOTAS.quota_items) -
                          set(default_quota_items)):
        resource_registry.register_resource_by_name(resource_item)
开发者ID:glove747,项目名称:liberty-neutron,代码行数:12,代码来源:__init__.py


示例9: get_resources

 def get_resources(cls):
     """Returns Ext Resources."""
     plural_mappings = {"rbac_policies": "rbac_policy"}
     attr.PLURALS.update(plural_mappings)
     plugin = manager.NeutronManager.get_plugin()
     params = RESOURCE_ATTRIBUTE_MAP["rbac_policies"]
     collection_name = "rbac-policies"
     resource_name = "rbac_policy"
     resource_registry.register_resource_by_name(resource_name)
     controller = base.create_resource(
         collection_name, resource_name, plugin, params, allow_bulk=True, allow_pagination=False, allow_sorting=True
     )
     return [extensions.ResourceExtension(collection_name, controller, attr_map=params)]
开发者ID:FengFengHan,项目名称:neutron,代码行数:13,代码来源:rbac.py


示例10: get_resources

 def get_resources(cls):
     """Returns Ext Resources."""
     plugin = directory.get_plugin()
     params = RESOURCE_ATTRIBUTE_MAP['rbac_policies']
     collection_name = 'rbac-policies'
     resource_name = 'rbac_policy'
     resource_registry.register_resource_by_name(resource_name)
     controller = base.create_resource(collection_name, resource_name,
                                       plugin, params, allow_bulk=True,
                                       allow_pagination=False,
                                       allow_sorting=True)
     return [extensions.ResourceExtension(collection_name, controller,
                                          attr_map=params)]
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:13,代码来源:rbac.py


示例11: get_resources

 def get_resources(cls):
     """Returns Ext Resources."""
     exts = []
     plugin = manager.NeutronManager.get_service_plugins()[
         nuage_constants.NUAGE_PORT_ATTRIBUTES_SERVICE_PLUGIN]
     resource_name = 'nuage_policy_group'
     collection_name = resource_name.replace('_', '-') + "s"
     params = RESOURCE_ATTRIBUTE_MAP.get(resource_name + "s", dict())
     resource_registry.register_resource_by_name(resource_name)
     controller = base.create_resource(collection_name, resource_name,
                                       plugin, params, allow_bulk=True)
     ex = extensions.ResourceExtension(collection_name, controller)
     exts.append(ex)
     return exts
开发者ID:nuagenetworks,项目名称:nuage-openstack-neutron,代码行数:14,代码来源:nuagepolicygroup.py


示例12: get_resources

    def get_resources(cls):
        """Returns Ext Resources."""
        my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
        attr.PLURALS.update(dict(my_plurals))
        exts = []
        plugin = manager.NeutronManager.get_plugin()
        for resource_name in ["nuage_gateway", "nuage_gateway_port", "nuage_gateway_vlan", "nuage_gateway_vport"]:
            collection_name = resource_name.replace("_", "-") + "s"
            params = RESOURCE_ATTRIBUTE_MAP.get(resource_name + "s", dict())
            resource_registry.register_resource_by_name(resource_name)
            controller = base.create_resource(collection_name, resource_name, plugin, params, allow_bulk=True)
            ex = extensions.ResourceExtension(collection_name, controller)
            exts.append(ex)

        return exts
开发者ID:nuagenetworks,项目名称:nuage-openstack-neutron,代码行数:15,代码来源:nuagegateway.py


示例13: get_resources

    def get_resources(cls):
        """Returns Ext Resources."""
        exts = []
        plugin = manager.NeutronManager.get_plugin()
        resource_name = 'net_partition'
        collection_name = resource_name.replace('_', '-') + "s"
        params = RESOURCE_ATTRIBUTE_MAP.get(resource_name + "s", dict())
        resource_registry.register_resource_by_name(resource_name)
        controller = base.create_resource(collection_name,
                                          resource_name,
                                          plugin, params, allow_bulk=True)
        ex = extensions.ResourceExtension(collection_name,
                                          controller)
        exts.append(ex)

        return exts
开发者ID:nuagenetworks,项目名称:nuage-openstack-neutron,代码行数:16,代码来源:netpartition.py


示例14: get_resources

 def get_resources(cls):
     special_mappings = {
         'l2_policies': 'l2_policy', 'l3_policies': 'l3_policy',
         'network_service_policies': 'network_service_policy',
         'external_policies': 'external_policy'}
     plural_mappings = resource_helper.build_plural_mappings(
         special_mappings, RESOURCE_ATTRIBUTE_MAP)
     attr.PLURALS.update(plural_mappings)
     for resource_name in ['l3_policy', 'l2_policy', 'policy_target_group',
                           'policy_target', 'policy_classifier',
                           'policy_action', 'policy_rule',
                           'policy_rule_set', 'external_policy',
                           'external_segment', 'nat_pool',
                           'network_service_policy']:
         resource_registry.register_resource_by_name(resource_name)
     return resource_helper.build_resource_info(plural_mappings,
                                                RESOURCE_ATTRIBUTE_MAP,
                                                constants.GROUP_POLICY)
开发者ID:anilgkurian,项目名称:group-based-policy,代码行数:18,代码来源:group_policy.py


示例15: get_resources

 def get_resources(cls):
     """Returns Ext Resources."""
     my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
     attr.PLURALS.update(dict(my_plurals))
     exts = []
     plugin = manager.NeutronManager.get_plugin()
     for resource_name in ['vsd_organisation', 'vsd_domain', 'vsd_zone',
                           'vsd_subnet']:
         collection_name = resource_name.replace('_', '-') + "s"
         params = RESOURCE_ATTRIBUTE_MAP.get(resource_name + "s", dict())
         resource_registry.register_resource_by_name(resource_name)
         controller = base.create_resource(collection_name,
                                           resource_name,
                                           plugin, params, allow_bulk=True)
         ex = extensions.ResourceExtension(collection_name,
                                           controller)
         exts.append(ex)
     return exts
开发者ID:jackie-qiu,项目名称:nuage-openstack-neutron,代码行数:18,代码来源:vsd_resource.py


示例16: get_resources

    def get_resources(cls):
        """Returns Ext Resources."""
        exts = []
        plugin = directory.get_plugin()
        for resource_name in ['security_group', 'security_group_rule']:
            collection_name = resource_name.replace('_', '-') + "s"
            params = RESOURCE_ATTRIBUTE_MAP.get(resource_name + "s", dict())
            resource_registry.register_resource_by_name(resource_name)
            controller = base.create_resource(collection_name,
                                              resource_name,
                                              plugin, params, allow_bulk=True,
                                              allow_pagination=True,
                                              allow_sorting=True)

            ex = extensions.ResourceExtension(collection_name,
                                              controller,
                                              attr_map=params)
            exts.append(ex)

        return exts
开发者ID:igordcard,项目名称:neutron,代码行数:20,代码来源:securitygroup.py


示例17: get_resources

    def get_resources(cls):
        """Returns Ext Resources."""
        exts = []
        plugin = directory.get_plugin()
        resource_name = 'ext_test_resource'
        collection_name = resource_name + "s"
        params = RESOURCE_ATTRIBUTE_MAP.get(collection_name, dict())

        resource_registry.register_resource_by_name(resource_name)

        controller = base.create_resource(collection_name,
                                          resource_name,
                                          plugin, params,
                                          member_actions={})

        ex = extensions.ResourceExtension(collection_name,
                                          controller,
                                          member_actions={})
        exts.append(ex)

        return exts
开发者ID:AradhanaSingh,项目名称:neutron,代码行数:21,代码来源:extensionattribute.py


示例18: get_resources

    def get_resources(cls):
        plural_mappings = resource_helper.build_plural_mappings(
            {}, RESOURCE_ATTRIBUTE_MAP)
        action_map = {'loadbalancer': {'stats': 'GET', 'statuses': 'GET'}}
        plural_mappings['members'] = 'member'
        resource_registry.register_resource_by_name('member', 'members')
        plural_mappings['sni_container_refs'] = 'sni_container_ref'
        plural_mappings['sni_container_ids'] = 'sni_container_id'
        resources = resource_helper.build_resource_info(
            plural_mappings,
            RESOURCE_ATTRIBUTE_MAP,
            constants.LOADBALANCERV2,
            action_map=action_map,
            register_quota=True)
        plugin = directory.get_plugin(constants.LOADBALANCERV2)
        for collection_name in SUB_RESOURCE_ATTRIBUTE_MAP:
            # Special handling needed for sub-resources with 'y' ending
            # (e.g. proxies -> proxy)
            resource_name = collection_name[:-1]
            parent = SUB_RESOURCE_ATTRIBUTE_MAP[collection_name].get('parent')
            params = SUB_RESOURCE_ATTRIBUTE_MAP[collection_name].get(
                'parameters')

            controller = base.create_resource(collection_name, resource_name,
                                              plugin, params,
                                              allow_bulk=True,
                                              parent=parent,
                                              allow_pagination=True,
                                              allow_sorting=True)

            resource = extensions.ResourceExtension(
                collection_name,
                controller, parent,
                path_prefix=LOADBALANCERV2_PREFIX,
                attr_map=params)
            resources.append(resource)

        return resources
开发者ID:openstack,项目名称:neutron-lbaas,代码行数:38,代码来源:loadbalancerv2.py


示例19: get_resources

    def get_resources(cls):
        """ Returns Ext Resources """
        exts = []
        if _use_plugins_directory:
            plugin = directory.get_plugin()
        else:
            plugin = manager.NeutronManager.get_plugin()

        for resource_name in ['route_table', 'nat_instance']:
            collection_name = resource_name.replace('_', '-') + "s"
            params = RESOURCE_ATTRIBUTE_MAP.get(resource_name + "s", dict())
            quota.register_resource_by_name(resource_name)
            controller = base.create_resource(collection_name,
                                              resource_name,
                                              plugin, params, allow_bulk=True,
                                              allow_pagination=True,
                                              allow_sorting=True)

            ex = ResourceExtension(collection_name, controller,
                                   attr_map=params)
            exts.append(ex)

        return exts
开发者ID:Juniper,项目名称:contrail-neutron-plugin,代码行数:23,代码来源:vpcroutetable.py


示例20: get_resources

    def get_resources(cls):
        """Returns Ext Resources."""
        my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
        attr.PLURALS.update(dict(my_plurals))
        exts = []
        plugin = manager.NeutronManager.get_service_plugins()['FUEL']
        for resource_name in ['nic']:
            collection_name = resource_name.replace('_', '-') + "s"
            params = RESOURCE_ATTRIBUTE_MAP.get(resource_name + "s", dict())
            resource_registry.register_resource_by_name(resource_name)
            controller = base.create_resource(collection_name,
                                              resource_name,
                                              plugin, params, allow_bulk=True,
                                              allow_pagination=True,
                                              allow_sorting=True)

            ex = extensions.ResourceExtension(collection_name,
                                              controller,
                                              path_prefix='fuel',
                                              attr_map=params)
            exts.append(ex)

        return exts
开发者ID:rmoe,项目名称:fuel-neutron,代码行数:23,代码来源:fuel.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap