Skip to content

Commit

Permalink
Use plain routes list for images instead of stevedore
Browse files Browse the repository at this point in the history
This patch adds images related routes by a plain list,
instead of using stevedore.

After all the Nova API endpoints moves to the plain routes list,
the usage of stevedore for API loading will be removed from Nova.

Partial-implement-blueprint api-no-more-extensions-pike

Change-Id: I884dbfef8032a34d155a7022037f5690d86ef532
  • Loading branch information
soulxu committed Jul 12, 2017
1 parent 156fe42 commit d0093c5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 42 deletions.
19 changes: 0 additions & 19 deletions nova/api/openstack/compute/image_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,9 @@
# License for the specific language governing permissions and limitations
# under the License.

from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.policies import image_size as is_policies

ALIAS = "image-size"


class ImageSizeController(wsgi.Controller):

Expand Down Expand Up @@ -49,19 +46,3 @@ def detail(self, req, resp_obj):
for image in images_resp:
image_cached = req.get_db_item('images', image['id'])
self._extend_image(image, image_cached)


class ImageSize(extensions.V21APIExtensionBase):
"""Adds image size to image listings."""

name = "ImageSize"
alias = ALIAS
version = 1

def get_controller_extensions(self):
controller = ImageSizeController()
extension = extensions.ControllerExtension(self, 'images', controller)
return [extension]

def get_resources(self):
return []
21 changes: 0 additions & 21 deletions nova/api/openstack/compute/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
import nova.utils


ALIAS = 'images'

SUPPORTED_FILTERS = {
'name': 'name',
'status': 'status',
Expand Down Expand Up @@ -154,22 +152,3 @@ def detail(self, req):

req.cache_db_items('images', images, 'id')
return self._view_builder.detail(req, images)


class Images(extensions.V21APIExtensionBase):
"""Proxying API for Images."""

name = "Images"
alias = ALIAS
version = 1

def get_resources(self):
coll_actions = {'detail': 'GET'}
resource = extensions.ResourceExtension(ALIAS,
ImagesController(),
collection_actions=coll_actions)

return [resource]

def get_controller_extensions(self):
return []
17 changes: 17 additions & 0 deletions nova/api/openstack/compute/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@
from nova.api.openstack.compute import hide_server_addresses
from nova.api.openstack.compute import hosts
from nova.api.openstack.compute import hypervisors
from nova.api.openstack.compute import image_size
from nova.api.openstack.compute import images
from nova.api.openstack.compute import instance_actions
from nova.api.openstack.compute import instance_usage_audit_log
from nova.api.openstack.compute import ips
Expand Down Expand Up @@ -195,6 +197,11 @@ def _create_controller(main_controller, controller_list,
_create_controller, hypervisors.HypervisorsController, [], [])


images_controller = functools.partial(
_create_controller, images.ImagesController,
[image_size.ImageSizeController], [])


instance_actions_controller = functools.partial(_create_controller,
instance_actions.InstanceActionsController, [], [])

Expand Down Expand Up @@ -374,6 +381,16 @@ def _create_controller(main_controller, controller_list,
('/flavors/{flavor_id}/os-flavor-access', {
'GET': [flavor_access_controller, 'index']
}),
('/images', {
'GET': [images_controller, 'index']
}),
('/images/detail', {
'GET': [images_controller, 'detail'],
}),
('/images/{id}', {
'GET': [images_controller, 'show'],
'DELETE': [images_controller, 'delete']
}),
('/limits', {
'GET': [limits_controller, 'index']
}),
Expand Down
2 changes: 0 additions & 2 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ wsgi_scripts =
nova.api.v21.extensions =
baremetal_nodes = nova.api.openstack.compute.baremetal_nodes:BareMetalNodes
extension_info = nova.api.openstack.compute.extension_info:ExtensionInfo
images = nova.api.openstack.compute.images:Images
image_metadata = nova.api.openstack.compute.image_metadata:ImageMetadata
image_size = nova.api.openstack.compute.image_size:ImageSize
security_group_default_rules = nova.api.openstack.compute.security_group_default_rules:SecurityGroupDefaultRules
security_groups = nova.api.openstack.compute.security_groups:SecurityGroups
versions = nova.api.openstack.compute.versionsV21:Versions
Expand Down

0 comments on commit d0093c5

Please sign in to comment.