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

Python base.create_resource函数代码示例

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

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



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

示例1: get_resources

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

        # subnets
        collection_name = SUBNETS
        params = RESOURCE_ATTRIBUTE_MAP.get(collection_name, dict())
        subnet_controller = base.create_resource(
            collection_name, SUBNET, plugin, params, allow_bulk=True)
        ex = extensions.ResourceExtension(collection_name, subnet_controller)
        exts.append(ex)

        # hosts
        parent = dict(member_name=SUBNET,
                      collection_name=SUBNETS)
        collection_name = DHCP_HOSTS
        params = RESOURCE_ATTRIBUTE_MAP.get(collection_name, dict())
        host_controller = base.create_resource(
            collection_name, DHCP_HOST, plugin, params,
            parent=parent, allow_bulk=True)
        ex = extensions.ResourceExtension(
            collection_name, host_controller, parent=parent)
        exts.append(ex)

        return exts
开发者ID:midokura,项目名称:python-neutron-plugin-midonet,代码行数:26,代码来源:subnet.py


示例2: get_resources

    def get_resources(self):
        collection = self.HYPHENATED_COLLECTION.replace('_', '-')
        params = self.RAM.get(self.HYPHENATED_COLLECTION, {})
        attributes.PLURALS.update({self.HYPHENATED_COLLECTION:
                                   self.HYPHENATED_RESOURCE})
        fake_plugin = FakePlugin()
        controller = base.create_resource(
            collection, self.HYPHENATED_RESOURCE, FakePlugin(),
            params, allow_bulk=True, allow_pagination=True,
            allow_sorting=True)
        resources = [extensions.ResourceExtension(collection,
                                                  controller,
                                                  attr_map=params)]
        for collection_name in self.SUB_RESOURCE_ATTRIBUTE_MAP:
            resource_name = collection_name
            parent = self.SUB_RESOURCE_ATTRIBUTE_MAP[collection_name].get(
                'parent')
            params = self.SUB_RESOURCE_ATTRIBUTE_MAP[collection_name].get(
                'parameters')

            controller = base.create_resource(collection_name, resource_name,
                                              fake_plugin, params,
                                              allow_bulk=True,
                                              parent=parent)

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

        return resources
开发者ID:annp,项目名称:neutron,代码行数:33,代码来源:utils.py


示例3: get_resources

    def get_resources(cls):
        exts = list()
        plugin = manager.NeutronManager.get_plugin()
        resource_name = TUNNELZONE
        collection_name = TUNNELZONES
        params = RESOURCE_ATTRIBUTE_MAP.get(collection_name, dict())
        controller = base.create_resource(collection_name, resource_name,
                                          plugin, params, allow_bulk=False)
        ex = extensions.ResourceExtension(collection_name, controller)
        exts.append(ex)

        # Tunnel Zone Host
        parent = dict(member_name=resource_name,
                      collection_name=collection_name)
        tunnelzone_plugin = manager.NeutronManager.get_service_plugins().get(
            TUNNELZONE)

        resource_name = TUNNELZONE_HOST
        collection_name = TUNNELZONE_HOSTS
        params = RESOURCE_ATTRIBUTE_MAP.get(collection_name, dict())
        tunnelzonehost_controller = base.create_resource(
            collection_name, resource_name,
            tunnelzone_plugin, params,
            parent=parent, allow_bulk=True)
        tunnelzonehost_extension = extensions.ResourceExtension(
            collection_name, tunnelzonehost_controller, parent=parent)
        exts.append(tunnelzonehost_extension)

        return exts
开发者ID:midokura,项目名称:python-neutron-plugin-midonet,代码行数:29,代码来源:tunnelzone.py


示例4: get_resources

    def get_resources(cls):
        my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
        my_plurals.append(("health_monitors_status", "health_monitor_status"))
        attr.PLURALS.update(dict(my_plurals))
        resources = []
        plugin = manager.NeutronManager.get_service_plugins()[constants.LOADBALANCER]
        for collection_name in RESOURCE_ATTRIBUTE_MAP:
            # Special handling needed for resources with 'y' ending
            # (e.g. proxies -> proxy)
            resource_name = collection_name[:-1]
            params = RESOURCE_ATTRIBUTE_MAP[collection_name]

            member_actions = {}
            if resource_name == "pool":
                member_actions = {"stats": "GET"}

            controller = base.create_resource(
                collection_name,
                resource_name,
                plugin,
                params,
                member_actions=member_actions,
                allow_pagination=cfg.CONF.allow_pagination,
                allow_sorting=cfg.CONF.allow_sorting,
            )

            resource = extensions.ResourceExtension(
                collection_name,
                controller,
                path_prefix=constants.COMMON_PREFIXES[constants.LOADBALANCER],
                member_actions=member_actions,
                attr_map=params,
            )
            resources.append(resource)

        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
            )

            resource = extensions.ResourceExtension(
                collection_name,
                controller,
                parent,
                path_prefix=constants.COMMON_PREFIXES[constants.LOADBALANCER],
                attr_map=params,
            )
            resources.append(resource)

        return resources
开发者ID:nash-x,项目名称:hws,代码行数:56,代码来源:loadbalancer.py


示例5: 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()[constants.METERING]
        for resource_name in ["metering_label", "metering_label_rule"]:
            collection_name = resource_name + "s"

            collection_name = collection_name.replace("_", "-")
            params = RESOURCE_ATTRIBUTE_MAP.get(resource_name + "s", dict())

            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=constants.COMMON_PREFIXES[constants.METERING], attr_map=params
            )
            exts.append(ex)

        return exts
开发者ID:midokura,项目名称:neutron,代码行数:28,代码来源:metering.py


示例6: get_resources

    def get_resources(cls):
        plugin = directory.get_plugin()

        params = pbe_ext.SUB_RESOURCE_ATTRIBUTE_MAP[
            pbe_ext.COLLECTION_NAME]['parameters']
        # TODO(hongbin): Delete _populate_is_filter_keyword once neutron-lib
        # containing https://review.openstack.org/#/c/583437/ is released.
        cls._populate_is_filter_keyword(params)
        parent = pbe_ext.SUB_RESOURCE_ATTRIBUTE_MAP[
            pbe_ext.COLLECTION_NAME]['parent']
        controller = base.create_resource(
            pbe_ext.COLLECTION_NAME,
            pbe_ext.RESOURCE_NAME,
            plugin,
            params,
            member_actions=pbe_ext.ACTION_MAP[pbe_ext.RESOURCE_NAME],
            parent=parent,
            allow_pagination=True,
            allow_sorting=True,
        )
        exts = [
            extensions.ResourceExtension(
                pbe_ext.COLLECTION_NAME,
                controller,
                parent,
                member_actions=pbe_ext.ACTION_MAP[pbe_ext.RESOURCE_NAME],
                attr_map=params,
            ),
        ]

        return exts
开发者ID:cubeek,项目名称:neutron,代码行数:31,代码来源:portbindings_extended.py


示例7: get_resources

    def get_resources(cls):
        plural_mappings = resource_helper.build_plural_mappings(
            {}, RESOURCE_ATTRIBUTE_MAP)
        plural_mappings['health_monitors_status'] = 'health_monitor_status'
        attr.PLURALS.update(plural_mappings)
        action_map = {'pool': {'stats': 'GET'}}
        resources = resource_helper.build_resource_info(plural_mappings,
                                                        RESOURCE_ATTRIBUTE_MAP,
                                                        constants.LOADBALANCER,
                                                        action_map=action_map)
        plugin = manager.NeutronManager.get_service_plugins()[
            constants.LOADBALANCER]
        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)

            resource = extensions.ResourceExtension(
                collection_name,
                controller, parent,
                path_prefix=constants.COMMON_PREFIXES[constants.LOADBALANCER],
                attr_map=params)
            resources.append(resource)

        return resources
开发者ID:actus10,项目名称:neutron,代码行数:33,代码来源:loadbalancer.py


示例8: 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):
    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()
    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:
            quota.QUOTAS.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=skycloud_constants.PORT_FORWARD_PATH_PREFIX,
            member_actions=member_actions,
            attr_map=params)
        resources.append(resource)
    return resources
开发者ID:swordboy,项目名称:neutron-portforward-service,代码行数:34,代码来源:routerportforward.py


示例9: get_resources

    def get_resources(cls):
        """Returns Ext Resources."""
        special_mappings = {"policies": "policy"}
        plural_mappings = resource_helper.build_plural_mappings(
            special_mappings, itertools.chain(RESOURCE_ATTRIBUTE_MAP, SUB_RESOURCE_ATTRIBUTE_MAP)
        )
        attr.PLURALS.update(plural_mappings)

        resources = resource_helper.build_resource_info(
            plural_mappings, RESOURCE_ATTRIBUTE_MAP, constants.QOS, translate_name=True, allow_bulk=True
        )

        plugin = manager.NeutronManager.get_service_plugins()[constants.QOS]
        for collection_name in SUB_RESOURCE_ATTRIBUTE_MAP:
            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=QOS_PREFIX, attr_map=params
            )
            resources.append(resource)

        return resources
开发者ID:electrocucaracha,项目名称:neutron,代码行数:35,代码来源:qos.py


示例10: get_resources

    def get_resources(cls):
        """Returns Ext Resources."""
        plural_mappings = resource_helper.build_plural_mappings(
            {}, RESOURCE_ATTRIBUTE_MAP)
        attr.PLURALS.update(plural_mappings)
        resources = resource_helper.build_resource_info(
            plural_mappings,
            RESOURCE_ATTRIBUTE_MAP,
            constants.FLAVORS)
        plugin = manager.NeutronManager.get_service_plugins()[
            constants.FLAVORS]
        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)

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

        return resources
开发者ID:cloudbase,项目名称:neutron,代码行数:32,代码来源:flavors.py


示例11: get_resources

    def get_resources(cls):
        plural_mapping = {
            'vpnusers': 'vpnuser',
        }
        my_plurals = []
        for plural in RESOURCE_ATTRIBUTE_MAP:
            singular = plural_mapping.get(plural, plural[:-1])
            my_plurals.append((plural, singular))
        attr.PLURALS.update(dict(my_plurals))
        resources = []
        plugin = manager.NeutronManager.get_service_plugins()[
            constants.VPN]
        for collection_name in RESOURCE_ATTRIBUTE_MAP:
            resource_name = plural_mapping.get(
                collection_name, collection_name[:-1])
            params = RESOURCE_ATTRIBUTE_MAP[collection_name]
            collection_name = collection_name.replace('_', '-')

            quota.QUOTAS.register_resource_by_name(resource_name)
            controller = base.create_resource(
                collection_name, resource_name, plugin, params,
                allow_pagination=cfg.CONF.allow_pagination,
                allow_sorting=cfg.CONF.allow_sorting)

            resource = extensions.ResourceExtension(
                collection_name,
                controller,
                path_prefix=constants.COMMON_PREFIXES[constants.VPN],
                attr_map=params)
            resources.append(resource)
        return resources
开发者ID:CingHu,项目名称:neutron-ustack,代码行数:31,代码来源:vpnuser.py


示例12: get_resources

 def get_resources(cls):
     params = RESOURCE_ATTRIBUTE_MAP.get(COLLECTION_NAME, dict())
     controller = base.create_resource(COLLECTION_NAME,
                                       EXT_ALIAS,
                                       plugin.Plugin.get_instance(),
                                       params, allow_bulk=False)
     return [extensions.ResourceExtension(EXT_ALIAS, controller)]
开发者ID:Blahhhhh,项目名称:neutron,代码行数:7,代码来源:auto_allocated_topology.py


示例13: 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 ['router', 'floatingip']:
            collection_name = resource_name + "s"
            params = RESOURCE_ATTRIBUTE_MAP.get(collection_name, dict())

            member_actions = {}
            if resource_name == 'router':
                member_actions = {'add_router_interface': 'PUT',
                                  'remove_router_interface': 'PUT'}

            quota.QUOTAS.register_resource_by_name(resource_name)

            controller = base.create_resource(
                collection_name, resource_name, plugin, params,
                member_actions=member_actions,
                allow_pagination=cfg.CONF.allow_pagination,
                allow_sorting=cfg.CONF.allow_sorting)

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

        return exts
开发者ID:Brocade-OpenSource,项目名称:OpenStack-DNRM-Neutron,代码行数:30,代码来源:l3.py


示例14: get_resources

    def get_resources(cls):
        """Returns Ext Resources."""
        plural_mappings = resource_helper.build_plural_mappings(
            {}, apidef.RESOURCE_ATTRIBUTE_MAP)
        resources = resource_helper.build_resource_info(
            plural_mappings,
            apidef.RESOURCE_ATTRIBUTE_MAP,
            constants.FLAVORS)
        plugin = directory.get_plugin(constants.FLAVORS)
        for collection_name in apidef.SUB_RESOURCE_ATTRIBUTE_MAP:
            # Special handling needed for sub-resources with 'y' ending
            # (e.g. proxies -> proxy)
            resource_name = collection_name[:-1]
            parent = apidef.SUB_RESOURCE_ATTRIBUTE_MAP[collection_name].get(
                'parent')
            params = apidef.SUB_RESOURCE_ATTRIBUTE_MAP[collection_name].get(
                'parameters')

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

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

        return resources
开发者ID:cubeek,项目名称:neutron,代码行数:31,代码来源:flavors.py


示例15: get_resources

    def get_resources(cls):
        plugin = directory.get_plugin()

        params = pbe_ext.SUB_RESOURCE_ATTRIBUTE_MAP[
            pbe_ext.COLLECTION_NAME]['parameters']
        parent = pbe_ext.SUB_RESOURCE_ATTRIBUTE_MAP[
            pbe_ext.COLLECTION_NAME]['parent']
        controller = base.create_resource(
            pbe_ext.COLLECTION_NAME,
            pbe_ext.RESOURCE_NAME,
            plugin,
            params,
            member_actions=pbe_ext.ACTION_MAP[pbe_ext.RESOURCE_NAME],
            parent=parent,
            allow_pagination=True,
            allow_sorting=True,
        )
        exts = [
            extensions.ResourceExtension(
                pbe_ext.COLLECTION_NAME,
                controller,
                parent,
                member_actions=pbe_ext.ACTION_MAP[pbe_ext.RESOURCE_NAME],
                attr_map=params,
            ),
        ]

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


示例16: get_resources

    def get_resources(cls):
        attr.validators['type:peer_cidr'] = _validate_openvpn_cidr
        plural_mapping = {
            'openvpnconnections': 'openvpnconnection'
        }
        my_plurals = []
        for plural in RESOURCE_ATTRIBUTE_MAP:
            singular = plural_mapping.get(plural, plural[:-1])
            my_plurals.append((plural, singular))
        attr.PLURALS.update(dict(my_plurals))
        resources = []
        plugin = manager.NeutronManager.get_service_plugins()[
            constants.VPN]
        for collection_name in RESOURCE_ATTRIBUTE_MAP:
            resource_name = plural_mapping.get(
                collection_name, collection_name[:-1])
            params = RESOURCE_ATTRIBUTE_MAP[collection_name]
            collection_name = collection_name.replace('_', '-')

            quota.QUOTAS.register_resource_by_name(resource_name)
            member_actions = {
                               'get_client_certificate':'GET',
                             }
            controller = base.create_resource(
                collection_name, resource_name, plugin, params,
                member_actions=member_actions,
                allow_pagination=cfg.CONF.allow_pagination,
                allow_sorting=cfg.CONF.allow_sorting)

            ext = extensions.ResourceExtension(resource_name+'s', controller,
                        path_prefix=constants.COMMON_PREFIXES[constants.VPN],
                        member_actions=member_actions)
            resources.append(ext)
        return resources
开发者ID:CingHu,项目名称:neutron-ustack,代码行数:34,代码来源:openvpn.py


示例17: get_resources

 def get_resources(cls):
     params = RESOURCE_ATTRIBUTE_MAP.get(COLLECTION_NAME, dict())
     controller = base.create_resource(COLLECTION_NAME,
                                       EXT_ALIAS,
                                       manager.NeutronManager.
                                       get_service_plugins()[EXT_ALIAS],
                                       params, allow_bulk=False)
     return [extensions.ResourceExtension(EXT_ALIAS, controller)]
开发者ID:21atlas,项目名称:neutron,代码行数:8,代码来源:auto_allocated_topology.py


示例18: get_resources

 def get_resources(cls):
     """Returns Extended Resources."""
     resource_name = "credential"
     collection_name = resource_name + "s"
     plugin = manager.NeutronManager.get_plugin()
     params = RESOURCE_ATTRIBUTE_MAP.get(collection_name, dict())
     controller = base.create_resource(collection_name, resource_name, plugin, params)
     return [extensions.ResourceExtension(collection_name, controller)]
开发者ID:cisco-openstack,项目名称:neutron,代码行数:8,代码来源:credential.py


示例19: get_resources

 def get_resources(cls):
     """Returns Extended Resource for dummy management."""
     dummy_inst = directory.get_plugin(DUMMY_SERVICE_TYPE)
     controller = base.create_resource(
         COLLECTION_NAME, RESOURCE_NAME, dummy_inst,
         RESOURCE_ATTRIBUTE_MAP[COLLECTION_NAME])
     return [extensions.ResourceExtension(COLLECTION_NAME,
                                          controller)]
开发者ID:eayunstack,项目名称:neutron,代码行数:8,代码来源:dummy_plugin.py


示例20: get_resources

 def get_resources(self):
     exts = list()
     plugin = manager.NeutronManager.get_plugin()
     params = RESOURCE_ATTRIBUTE_MAP.get(attributes.FLOWRULES, dict())
     controller = base.create_resource(attributes.FLOWRULES, attributes.FLOWRULE, plugin, params, allow_bulk=False)
     ex = extensions.ResourceExtension(attributes.FLOWRULES, controller)
     exts.append(ex)
     return exts
开发者ID:netgroup-polito,项目名称:frog3,代码行数:8,代码来源:flowrule.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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