diff options
| author | Chris Yeoh <cyeoh@au1.ibm.com> | 2013-05-18 12:48:44 +0930 |
|---|---|---|
| committer | Chris Yeoh <cyeoh@au1.ibm.com> | 2013-06-07 10:06:52 +0930 |
| commit | d5ae8d5667fee22ba4df4feea53224874a19d167 (patch) | |
| tree | 8e04a8005d8417460600b43518380854d6653946 /nova/api | |
| parent | 8b632660aff27582c9b8ced3e0642399f3139f81 (diff) | |
| download | nova-d5ae8d5667fee22ba4df4feea53224874a19d167.tar.gz nova-d5ae8d5667fee22ba4df4feea53224874a19d167.tar.xz nova-d5ae8d5667fee22ba4df4feea53224874a19d167.zip | |
Adds check that the core V3 API is loaded
Adds infrastructure to be able to check that the core V3 API
plugins are present and raise an exception and abort if any are missing. The
list is deliberately hard coded though it is not yet complete and
will be expanded as the core APIs are ported and it is decided
exactly what will be considered to be the core API.
Partially implements blueprint v3-api-extension-framework
Change-Id: Ic2c1d5cd6836ee18819106558880682cf4cda487
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/__init__.py | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/nova/api/openstack/__init__.py b/nova/api/openstack/__init__.py index 3687ce111..3455b812d 100644 --- a/nova/api/openstack/__init__.py +++ b/nova/api/openstack/__init__.py @@ -28,6 +28,7 @@ import webob.exc from nova.api.openstack import extensions from nova.api.openstack import wsgi +from nova import exception from nova import notifications from nova.openstack.common import log as logging from nova import utils @@ -55,6 +56,11 @@ CONF = cfg.CONF CONF.register_group(api_opts_group) CONF.register_opts(api_opts, api_opts_group) +# List of v3 API extensions which are considered to form +# the core API and so must be present +# TODO(cyeoh): Expand this list as the core APIs are ported to V3 +API_V3_CORE_EXTENSIONS = set(['servers']) + class FaultWrapper(base_wsgi.Middleware): """Calls down the middleware stack, making exceptions into faults.""" @@ -306,8 +312,22 @@ class APIRouterV3(base_wsgi.Router): mapper=mapper) self.api_extension_manager.map(self._register_controllers) + missing_core_extensions = self.get_missing_core_extensions( + self.loaded_extension_info.get_extensions().keys()) + if missing_core_extensions: + LOG.critical(_("Missing core API extensions: %s"), + missing_core_extensions) + raise exception.CoreAPIMissing( + missing_apis=missing_core_extensions) + super(APIRouterV3, self).__init__(mapper) + @staticmethod + def get_missing_core_extensions(extensions_loaded): + extensions_loaded = set(extensions_loaded) + missing_extensions = API_V3_CORE_EXTENSIONS - extensions_loaded + return missing_extensions + @property def loaded_extension_info(self): raise NotImplementedError() |
