Example #1
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
Example #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
Example #3
0
    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
Example #4
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)]
Example #5
0
 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)
Example #6
0
    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
Example #7
0
File: l3.py Project: 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
Example #8
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 ['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
Example #9
0
File: l3.py Project: 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
Example #10
0
 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)]
Example #11
0
 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)
Example #12
0
 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)]
Example #13
0
 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)]
Example #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)]
 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)]
Example #16
0
 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)
Example #17
0
    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
Example #18
0
 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)
Example #19
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,
                                          attr_map=PACKET_FILTER_ATTR_MAP)]
Example #20
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)

        controller = base.create_resource(COLLECTION_NAME, RESOURCE_NAME, plugin, params, member_actions=member_actions)
        return [extensions.ResourceExtension(COLLECTION_NAME, controller, member_actions=member_actions)]
Example #21
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))
        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]
Example #22
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
Example #23
0
 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)
     ]
Example #24
0
 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)]
Example #25
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))
        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]
Example #26
0
    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
Example #27
0
 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)
Example #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
Example #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)]
Example #30
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)

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

        return exts
    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
Example #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
Example #33
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
Example #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
Example #35
0
 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)
Example #36
0
 def test_resource_creation(self):
     resource = base.create_resource('fakes', 'fake', None, {})
     self.assertIsInstance(resource, webob.dec.wsgify)