コード例 #1
0
ファイル: loadbalancer.py プロジェクト: ayushjain1310/quantum
    def get_resources(cls):
        my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
        attr.PLURALS.update(dict(my_plurals))
        resources = []
        plugin = manager.QuantumManager.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
コード例 #2
0
    def get_resources(cls):
        my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
        attr.PLURALS.update(dict(my_plurals))
        resources = []
        plugin = manager.QuantumManager.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
コード例 #3
0
ファイル: nwservices.py プロジェクト: kumarcv/openstack-nf
    def get_resources(cls):
        #my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
        #attr.PLURALS.update(dict(my_plurals))
        attr.PLURALS.update(NWSERVICES_PLURALS)
        resources = []
        plugin = manager.QuantumManager.get_service_plugins()[
            constants.NWSERVICES]
        for collection_name in RESOURCE_ATTRIBUTE_MAP:
            # Special handling needed for resources with 'y' ending
            # (e.g. proxies -> proxy)
            resource_name = NWSERVICES_PLURALS[collection_name]
            params = RESOURCE_ATTRIBUTE_MAP[collection_name]

            member_actions = {}

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

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

        return resources
コード例 #4
0
ファイル: packetfilter.py プロジェクト: hadib/quantum
 def get_resources(self):
     resource = base.create_resource(
         "packet_filters", "packet_filter", QuantumManager.get_plugin(), PACKET_FILTER_ATTR_MAP
     )
     qresource = quota.CountableResource("packet_filter", quota._count_resource, "quota_packet_filter")
     quota.QUOTAS.register_resource(qresource)
     return [extensions.ResourceExtension("packet_filters", resource)]
コード例 #5
0
ファイル: router.py プロジェクト: hongbin/quantum
 def _map_resource(collection, resource, params):
     controller = base.create_resource(collection, resource, plugin,
                                       params)
     mapper_kwargs = dict(controller=controller,
                          requirements=REQUIREMENTS,
                          **col_kwargs)
     return mapper.collection(collection, resource, **mapper_kwargs)
コード例 #6
0
ファイル: l3.py プロジェクト: redondos/quantum
    def get_resources(cls):
        """ Returns Ext Resources """
        exts = []
        plugin = manager.QuantumManager.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)

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

        return exts
コード例 #7
0
ファイル: l3.py プロジェクト: fmanco/quantum
    def get_resources(cls):
        """ Returns Ext Resources """
        exts = []
        plugin = manager.QuantumManager.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)

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

        return exts
コード例 #8
0
ファイル: l3.py プロジェクト: CiscoAS/quantum
    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.QuantumManager.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
コード例 #9
0
ファイル: l3.py プロジェクト: schatt/quantum
    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.QuantumManager.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
コード例 #10
0
ファイル: servicetype.py プロジェクト: abhiraut/quantum
 def get_resources(cls):
     """ Returns Extended Resource for service type management """
     controller = base.create_resource(
         COLLECTION_NAME,
         RESOURCE_NAME,
         servicetype_db.ServiceTypeManager.get_instance(),
         RESOURCE_ATTRIBUTE_MAP[COLLECTION_NAME])
     return [extensions.ResourceExtension(COLLECTION_NAME, controller)]
コード例 #11
0
ファイル: router.py プロジェクト: codeoedoc/quantum
 def _map_resource(collection, resource, params):
     controller = base.create_resource(collection, resource,
                                       plugin, params)
     mapper_kwargs = dict(controller=controller,
                          requirements=REQUIREMENTS,
                          **col_kwargs)
     return mapper.collection(collection, resource,
                              **mapper_kwargs)
コード例 #12
0
ファイル: dummy_plugin.py プロジェクト: soheilhy/quantum
 def get_resources(cls):
     """Returns Extended Resource for dummy management."""
     q_mgr = manager.QuantumManager.get_instance()
     dummy_inst = q_mgr.get_service_plugins()['DUMMY']
     controller = base.create_resource(
         COLLECTION_NAME, RESOURCE_NAME, dummy_inst,
         RESOURCE_ATTRIBUTE_MAP[COLLECTION_NAME])
     return [extensions.ResourceExtension(COLLECTION_NAME, controller)]
コード例 #13
0
ファイル: dummy_plugin.py プロジェクト: Apsu/quantum
 def get_resources(cls):
     """Returns Extended Resource for dummy management."""
     q_mgr = manager.QuantumManager.get_instance()
     dummy_inst = q_mgr.get_service_plugins()['DUMMY']
     controller = base.create_resource(
         COLLECTION_NAME, RESOURCE_NAME, dummy_inst,
         RESOURCE_ATTRIBUTE_MAP[COLLECTION_NAME])
     return [extensions.ResourceExtension(COLLECTION_NAME,
                                          controller)]
コード例 #14
0
 def get_resources(self):
     resource = base.create_resource('packet_filters', 'packet_filter',
                                     QuantumManager.get_plugin(),
                                     PACKET_FILTER_ATTR_MAP)
     qresource = quota.CountableResource('packet_filter',
                                         quota._count_resource,
                                         'quota_packet_filter')
     quota.QUOTAS.register_resource(qresource)
     return [extensions.ResourceExtension('packet_filters', resource)]
コード例 #15
0
 def get_resources(cls):
     """ Returns Extended Resource for service type management """
     my_plurals = [(key.replace("-", "_"), key[:-1].replace("-", "_")) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
     my_plurals.append(("service_definitions", "service_definition"))
     attributes.PLURALS.update(dict(my_plurals))
     attr_map = RESOURCE_ATTRIBUTE_MAP[COLLECTION_NAME]
     controller = base.create_resource(
         COLLECTION_NAME, RESOURCE_NAME, servicetype_db.ServiceTypeManager.get_instance(), attr_map
     )
     return [extensions.ResourceExtension(COLLECTION_NAME, controller, attr_map=attr_map)]
コード例 #16
0
ファイル: router.py プロジェクト: Blackspan/quantum
 def _map_resource(collection, resource, params):
     allow_bulk = cfg.CONF.allow_bulk
     controller = base.create_resource(collection, resource,
                                       plugin, params,
                                       allow_bulk=allow_bulk)
     mapper_kwargs = dict(controller=controller,
                          requirements=REQUIREMENTS,
                          **col_kwargs)
     return mapper.collection(collection, resource,
                              **mapper_kwargs)
コード例 #17
0
ファイル: loadbalancer.py プロジェクト: polalis/quantum
    def get_resources(cls):
        resources = []
        plugin = manager.QuantumManager.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
            )

            resource = extensions.ResourceExtension(
                collection_name,
                controller,
                path_prefix=constants.COMMON_PREFIXES[constants.LOADBALANCER],
                member_actions=member_actions,
            )
            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]
            )
            resources.append(resource)

        return resources
コード例 #18
0
ファイル: router.py プロジェクト: whitekid/quantum
 def _map_resource(collection, resource, params):
     allow_bulk = cfg.CONF.allow_bulk
     controller = base.create_resource(collection,
                                       resource,
                                       plugin,
                                       params,
                                       allow_bulk=allow_bulk)
     mapper_kwargs = dict(controller=controller,
                          requirements=REQUIREMENTS,
                          **col_kwargs)
     return mapper.collection(collection, resource, **mapper_kwargs)
コード例 #19
0
ファイル: packetfilter.py プロジェクト: DrLeonard/quantum
 def get_resources(self):
     resource = base.create_resource('packet_filters', 'packet_filter',
                                     QuantumManager.get_plugin(),
                                     PACKET_FILTER_ATTR_MAP)
     qresource = quota.CountableResource('packet_filter',
                                         quota._count_resource,
                                         'quota_packet_filter')
     quota.QUOTAS.register_resource(qresource)
     return [extensions.ResourceExtension('packet_filters',
                                          resource,
                                          attr_map=PACKET_FILTER_ATTR_MAP)]
コード例 #20
0
ファイル: nvp_networkgw.py プロジェクト: mygoda/openstack
    def get_resources(cls):
        """ Returns Ext Resources """
        plugin = manager.QuantumManager.get_plugin()
        params = RESOURCE_ATTRIBUTE_MAP.get(COLLECTION_NAME, dict())

        member_actions = {"connect_network": "PUT", "disconnect_network": "PUT"}

        # register quotas for network gateways
        quota.QUOTAS.register_resource_by_name(RESOURCE_NAME)

        controller = base.create_resource(COLLECTION_NAME, RESOURCE_NAME, plugin, params, member_actions=member_actions)
        return [extensions.ResourceExtension(COLLECTION_NAME, controller, member_actions=member_actions)]
コード例 #21
0
ファイル: agent.py プロジェクト: zhangheng1442/openstack
    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))
        plugin = manager.QuantumManager.get_plugin()
        params = RESOURCE_ATTRIBUTE_MAP.get(RESOURCE_NAME + 's')
        controller = base.create_resource(RESOURCE_NAME + 's', RESOURCE_NAME,
                                          plugin, params)

        ex = extensions.ResourceExtension(RESOURCE_NAME + 's', controller)

        return [ex]
コード例 #22
0
ファイル: securitygroup.py プロジェクト: wph540/quantum
    def get_resources(cls):
        """ Returns Ext Resources """
        exts = []
        plugin = manager.QuantumManager.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())
            quota.QUOTAS.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
コード例 #23
0
ファイル: servicetype.py プロジェクト: soheilhy/quantum
 def get_resources(cls):
     """Returns Extended Resource for service type management."""
     my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
     my_plurals.append(('service_definitions', 'service_definition'))
     attributes.PLURALS.update(dict(my_plurals))
     attr_map = RESOURCE_ATTRIBUTE_MAP[COLLECTION_NAME]
     collection_name = COLLECTION_NAME.replace('_', '-')
     controller = base.create_resource(
         collection_name, RESOURCE_NAME,
         servicetype_db.ServiceTypeManager.get_instance(), attr_map)
     return [
         extensions.ResourceExtension(collection_name,
                                      controller,
                                      attr_map=attr_map)
     ]
コード例 #24
0
ファイル: servicetype.py プロジェクト: Apsu/quantum
 def get_resources(cls):
     """Returns Extended Resource for service type management."""
     my_plurals = [(key, key[:-1]) for key in RESOURCE_ATTRIBUTE_MAP.keys()]
     my_plurals.append(('service_definitions', 'service_definition'))
     attributes.PLURALS.update(dict(my_plurals))
     attr_map = RESOURCE_ATTRIBUTE_MAP[COLLECTION_NAME]
     collection_name = COLLECTION_NAME.replace('_', '-')
     controller = base.create_resource(
         collection_name,
         RESOURCE_NAME,
         servicetype_db.ServiceTypeManager.get_instance(),
         attr_map)
     return [extensions.ResourceExtension(collection_name,
                                          controller,
                                          attr_map=attr_map)]
コード例 #25
0
ファイル: agent.py プロジェクト: JunPark/quantum
    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))
        plugin = manager.QuantumManager.get_plugin()
        params = RESOURCE_ATTRIBUTE_MAP.get(RESOURCE_NAME + 's')
        controller = base.create_resource(RESOURCE_NAME + 's',
                                          RESOURCE_NAME,
                                          plugin, params
                                          )

        ex = extensions.ResourceExtension(RESOURCE_NAME + 's',
                                          controller)

        return [ex]
コード例 #26
0
ファイル: nvp_qos.py プロジェクト: soheilhy/quantum
    def get_resources(cls):
        """Returns Ext Resources."""
        exts = []
        plugin = manager.QuantumManager.get_plugin()
        resource_name = 'qos_queue'
        collection_name = resource_name.replace('_', '-') + "s"
        params = RESOURCE_ATTRIBUTE_MAP.get(resource_name + "s", dict())
        controller = base.create_resource(collection_name,
                                          resource_name,
                                          plugin, params, allow_bulk=False)

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

        return exts
コード例 #27
0
ファイル: router.py プロジェクト: abhiraut/quantum
 def _map_resource(collection, resource, params, parent=None):
     allow_bulk = cfg.CONF.allow_bulk
     controller = base.create_resource(collection, resource,
                                       plugin, params,
                                       allow_bulk=allow_bulk,
                                       parent=parent)
     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)
コード例 #28
0
    def get_resources(cls):
        """ Returns Ext Resources """
        exts = []
        plugin = manager.QuantumManager.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())
            quota.QUOTAS.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
コード例 #29
0
    def get_resources(cls):
        """Returns Ext Resources."""
        plugin = manager.QuantumManager.get_plugin()
        params = RESOURCE_ATTRIBUTE_MAP.get(COLLECTION_NAME, dict())

        member_actions = {'connect_network': 'PUT',
                          'disconnect_network': 'PUT'}

        # register quotas for network gateways
        quota.QUOTAS.register_resource_by_name(RESOURCE_NAME)
        collection_name = COLLECTION_NAME.replace('_', '-')
        controller = base.create_resource(collection_name,
                                          RESOURCE_NAME,
                                          plugin, params,
                                          member_actions=member_actions)
        return [extensions.ResourceExtension(COLLECTION_NAME,
                                             controller,
                                             member_actions=member_actions)]
コード例 #30
0
ファイル: securitygroup.py プロジェクト: bbrahmbhatt/quantum
    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.QuantumManager.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())
            quota.QUOTAS.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
コード例 #31
0
    def get_resources(self):
        """ Returns Ext Resources """
        resources = []
        plugin = manager.QuantumManager.get_plugin()
        for resource_name in ['vn', 'vc', 'site', 'vnsite', 'vnlink', 'user']:
            collection_name = resource_name + "s"
            params = RESOURCE_ATTRIBUTE_MAP.get(collection_name, dict())
            parent_resource=None
            member_actions = {}
            if resource_name == 'site':
                member_actions = {'show_site_attachment':'GET',
                                  'unplug_attach_from_site': 'PUT',
                                  'plug_attach_for_site': 'PUT'}
            if resource_name == 'vnsite':
                parent_resource={}
                parent_resource['member_name']='vn'
                parent_resource['collection_name']='vns'
                member_actions={'add_site_to_vn':'PUT',
                                'delete_site_from_vn':'PUT'}
            if resource_name == 'vnlink':
                parent_resource={}
                parent_resource['member_name']='vn'
                parent_resource['collection_name']='vns'
            if resource_name == 'user':
                member_actions={'add_site_to_user':'******',
                                'delete_site_from_user':'******',
                                'authorize_user':'******'}
            quota.QUOTAS.register_resource_by_name(resource_name)

            controller = base.create_resource(collection_name,
                                              resource_name,
                                              plugin, params,
                                              member_actions=member_actions,
                                              parent=parent_resource)

            resource = extensions.ResourceExtension(collection_name,
                                              controller,
                                              member_actions=member_actions,
                                              parent=parent_resource)
            resources.append(resource)

        return resources
コード例 #32
0
    def get_resources(cls):
        """Returns Ext Resources."""
        exts = []
        plugin = manager.QuantumManager.get_plugin()
        resource_name = 'ext_test_resource'
        collection_name = resource_name + "s"
        params = RESOURCE_ATTRIBUTE_MAP.get(collection_name, dict())

        quota.QUOTAS.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
コード例 #33
0
ファイル: extensionattribute.py プロジェクト: wdec/quantum
    def get_resources(cls):
        """ Returns Ext Resources """
        exts = []
        plugin = manager.QuantumManager.get_plugin()
        resource_name = 'ext_test_resource'
        collection_name = resource_name + "s"
        params = RESOURCE_ATTRIBUTE_MAP.get(collection_name, dict())

        quota.QUOTAS.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
コード例 #34
0
    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.QuantumManager.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())
            quota.QUOTAS.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
コード例 #35
0
ファイル: router.py プロジェクト: zhangheng1442/openstack
 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)
コード例 #36
0
ファイル: test_api_v2.py プロジェクト: abhiraut/quantum
 def test_resource_creation(self):
     resource = base.create_resource('fakes', 'fake', None, {})
     self.assertIsInstance(resource, webob.dec.wsgify)