Merge v21 view builder for flavor API

Now v2 and v2.1 code is merged and we do not need
to maintain the different set of view builder.
Previously there were different way of building the
complete response for flavor API. v2 used to do with extension
and v2.1 with view builder itself.

Part of bp:api-no-more-extensions

Change-Id: I4f8b6b6270ffc5aa64b5c9b936f61e0e96f7fe5b
This commit is contained in:
ghanshyam 2016-12-05 17:46:10 +09:00
parent 474c2ef282
commit 59a07a152c
3 changed files with 6 additions and 15 deletions

View File

@ -28,7 +28,7 @@ ALIAS = "os-flavor-manage"
class FlavorManageController(wsgi.Controller):
"""The Flavor Lifecycle API controller for the OpenStack API."""
_view_builder_class = flavors_view.ViewBuilderV21
_view_builder_class = flavors_view.ViewBuilder
def __init__(self):
super(FlavorManageController, self).__init__()

View File

@ -32,7 +32,7 @@ ALIAS = 'flavors'
class FlavorsController(wsgi.Controller):
"""Flavor controller for the OpenStack API."""
_view_builder_class = flavors_view.ViewBuilderV21
_view_builder_class = flavors_view.ViewBuilder
@extensions.expected_errors(400)
def index(self, req):

View File

@ -38,7 +38,10 @@ class ViewBuilder(common.ViewBuilder):
"name": flavor["name"],
"ram": flavor["memory_mb"],
"disk": flavor["root_gb"],
"vcpus": flavor.get("vcpus") or "",
"swap": flavor["swap"] or "",
"OS-FLV-EXT-DATA:ephemeral": flavor["ephemeral_gb"],
"OS-FLV-DISABLED:disabled": flavor["disabled"],
"vcpus": flavor["vcpus"],
"links": self._get_links(request,
flavor["flavorid"],
self._collection_name),
@ -79,15 +82,3 @@ class ViewBuilder(common.ViewBuilder):
flavors_dict["flavors_links"] = flavors_links
return flavors_dict
class ViewBuilderV21(ViewBuilder):
def show(self, request, flavor):
flavor_dict = super(ViewBuilderV21, self).show(request, flavor)
flavor_dict['flavor'].update({
"swap": flavor["swap"] or "",
"OS-FLV-EXT-DATA:ephemeral": flavor["ephemeral_gb"],
"OS-FLV-DISABLED:disabled": flavor["disabled"],
"vcpus": flavor["vcpus"],
})
return flavor_dict