remove os-disk-config part 3

This removes the modification of the images resource. There are no
additional tests or test changes, as existing functional tests cover
these cases and guaruntee correct output.

Part of bp:api-no-more-extensions

Change-Id: I1d5bee3152a3725c5c7303462c5c383900a1e3c7
This commit is contained in:
Sean Dague 2016-06-15 15:22:17 -04:00
parent 4acfd825f5
commit fbc3c5ab3c
2 changed files with 10 additions and 30 deletions

View File

@ -14,11 +14,9 @@
"""Disk Config extension."""
from oslo_utils import strutils
from webob import exc
from nova.api.openstack import extensions
from nova.api.openstack import wsgi
from nova.i18n import _
ALIAS = 'os-disk-config'
@ -41,30 +39,6 @@ def disk_config_from_api(value):
raise exc.HTTPBadRequest(explanation=msg)
class ImageDiskConfigController(wsgi.Controller):
def _add_disk_config(self, context, images):
for image in images:
metadata = image['metadata']
if INTERNAL_DISK_CONFIG in metadata:
raw_value = metadata[INTERNAL_DISK_CONFIG]
value = strutils.bool_from_string(raw_value)
image[API_DISK_CONFIG] = disk_config_to_api(value)
@wsgi.extends
def show(self, req, resp_obj, id):
context = req.environ['nova.context']
if 'image' in resp_obj.obj and authorize(context):
image = resp_obj.obj['image']
self._add_disk_config(context, [image])
@wsgi.extends
def detail(self, req, resp_obj):
context = req.environ['nova.context']
if 'images' in resp_obj.obj and authorize(context):
images = resp_obj.obj['images']
self._add_disk_config(context, images)
class DiskConfig(extensions.V21APIExtensionBase):
"""Disk Management Extension."""
@ -73,10 +47,7 @@ class DiskConfig(extensions.V21APIExtensionBase):
version = 1
def get_controller_extensions(self):
images_extension = extensions.ControllerExtension(
self, 'images', ImageDiskConfigController())
return [images_extension]
return []
def get_resources(self):
return []

View File

@ -14,7 +14,10 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_utils import strutils
from nova.api.openstack import common
from nova.api.openstack.compute import disk_config
from nova.image import glance
from nova import utils
@ -70,6 +73,12 @@ class ViewBuilder(common.ViewBuilder):
}],
}
auto_disk_config = image_dict['metadata'].get("auto_disk_config", None)
if auto_disk_config is not None:
value = strutils.bool_from_string(auto_disk_config)
image_dict["OS-DCF:diskConfig"] = \
disk_config.disk_config_to_api(value)
return dict(image=image_dict)
def detail(self, request, images):