In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
How to parse the nova.api.openstack.APIRouterV21 module, for this problem, this article introduces the corresponding analysis and solution in detail, hoping to help more friends who want to solve this problem find a simpler and easier way.
Analysis of nova.api.openstack.APIRouterV21 module:
from nova import wsgi as base_wsgi class APIRouterV21(base_wsgi.Router):"""Routes requests on the OpenStack v2.1 API to the appropriate controllers and methods. """ @classmethod def factory(cls, global_config, **local_config):"""paste factory method, call""" in [app:osapi_compute_app_v21] in/etc/nova/api-paste.ini return cls()@staticmethod def api_extension_namespace(): """Define Plugin Namespace""" return 'nova.api.v21.extensions' def __init__(self):def _check_load_extension(ext):return self._ register_extension(ext) #Dynamically load plugins via stevedore self.api_extension_manager = stevedore.enabled.EnabledExtensionManager(namespace=self.api_extension_namespace(),check_func=_check_load_extension,invoke_on_load=True,invoke_kwds={"extension_info": self.loaded_extension_info}) mapper = ProjectMapper()#Routes Mapper, this class is an inheritance overload of nova to routes. Mapperself.resources = {}#Core API support rewritten as an extension, but still conceptually central if list(self.api_extension_manager):#Stevedore throws an exception if no plugins are detected. self._ register_resources_check_inherits(mapper)self.api_extension_manager.map(self._ register_controllers) LOG.info(_LI("Loaded extensions: %s"), sorted(self.loaded_extension_info.get_extensions().keys()))super(APIRouterV21, self).__ init__(mapper)def _register_resources_list(self, ext_list, mapper):for ext in ext_list:self._ register_resources(ext, mapper)def _register_resources_check_inherits(self, mapper): ext_has_inherits = [] ext_no_inherits = []for ext in self.api_extension_manager:for resource in ext.obj.get_resources():if resource.inherits: ext_has_inherits.append(ext)break else: ext_no_inherits.append(ext)self._ register_resources_list(ext_no_inherits, mapper)self._ register_resources_list(ext_has_inherits, mapper)@property def loaded_extension_info(self):raise NotImplementedError()def _register_extension(self, ext):raise NotImplementedError()def _register_resources(self, ext, mapper):"""Register resources defined by extensions Extensions Define the resources to add with the get_resources function "" handler = ext.obj LOG.debug("Running _register_resources on %s", ext.obj)for resource in handler.get_resources(): LOG.debug('Extended resource: %s', resource.collection) inherits = None if resource.inherits: inherits = self.resources.get(resource.inherits)if not resource.controller: resource.controller = inherits.controller wsgi_resource = wsgi.ResourceV21(resource.controller, inherits=inherits)self.resources[resource.collection] = wsgi_resource kargs = dict(controller=wsgi_resource,collection=resource.collection_actions,member=resource.member_actions)if resource.parent: kargs ['parent_resource'] = resource.parent#Non-core API plugins use collection names as member names,#but core-API plugins use singular and plural conventions for member/collection names if resource.member_name: member_name = resource.member_nameelse: member_name = resource.collection mapper.resource(member_name, resource.collection, **kargs)if resource.custom_routes_fn: resource.custom_routes_fn(mapper, wsgi_resource)def _register_controllers(self, ext):"" Register controllers defined by extensions Define the resources to be added via the get_controller_extensions function "" handler = ext.obj LOG.debug("Running _register_controllers on %s", ext.obj)for extension in handler.get_controller_extensions(): ext_name = extension.extension.name collection = extension.collection controller = extension.controllerif collection not in self.resources: LOG.warning(_LW('Extension %(ext_name)s: Cannot extend ' 'resource %(collection)s: No such resource'), {'ext_name': ext_name, 'collection': collection})continue LOG.debug('Extension %(ext_name)s extending resource: ' '%(collection)s', {'ext_name': ext_name, 'collection': collection}) resource = self.resources[collection] resource.register_actions(controller) resource.register_extensions(controller) The answer to the problem of how to resolve the nova.api.openstack.APIRouterV21 module is shared here. I hope the above content can help you to some extent. If you still have a lot of doubts, you can pay attention to the industry information channel to learn more.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.