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


Python base.create_resource函数代码示例

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


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


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