diff --git a/docs/changelog.rst b/docs/changelog.rst index 4da08075b6..de6989ecc0 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -1,2 +1,7 @@ Change Logs =========== + +Next Version +------------ + +* The Cinder V2 API now has limited support for the `List volumes with details `_ endpoint. diff --git a/mimic/rest/cinder_api.py b/mimic/rest/cinder_api.py index 8fafb29f43..ef3fa5f1ca 100644 --- a/mimic/rest/cinder_api.py +++ b/mimic/rest/cinder_api.py @@ -3,6 +3,7 @@ Defines a mock for Cinder """ +from __future__ import absolute_import, division, print_function, unicode_literals import json from uuid import uuid4 from six import text_type @@ -31,7 +32,14 @@ def catalog_entries(self, tenant_id): """ return [ Entry( - tenant_id, "volume", "cloudBlockStorage", + tenant_id, "volume", "cinder", + [ + Endpoint(tenant_id, region, text_type(uuid4()), prefix="v2") + for region in self._regions + ] + ), + Entry( + tenant_id, "volumev2", "cinderv2", [ Endpoint(tenant_id, region, text_type(uuid4()), prefix="v2") for region in self._regions @@ -49,7 +57,7 @@ def resource_for_region(self, region, uri_prefix, session_store): class CinderMock(object): """ - DNS Mock + Cinder Mock """ def __init__(self, api_mock, uri_prefix, session_store, name): """ @@ -65,8 +73,19 @@ def __init__(self, api_mock, uri_prefix, session_store, name): @app.route('/v2//volumes', methods=['GET']) def get_volumes(self, request, tenant_id): """ - Lists summary information for all Block Storage volumes that the tenant can access. - http://developer.openstack.org/api-ref-blockstorage-v2.html#getVolumesSimple + Lists summary information for all Block Storage volumes that the tenant + can access. + http://developer.openstack.org/api-ref-blockstorage-v2.html#listVolumes + """ + request.setResponseCode(200) + return json.dumps({'volumes': []}) + + @app.route('/v2//volumes/detail', methods=['GET']) + def get_volumes_detail(self, request, tenant_id): + """ + Lists detailed information for all Block Storage volumes that the + tenant can access. + http://developer.openstack.org/api-ref-blockstorage-v2.html#listVolumesDetail """ request.setResponseCode(200) return json.dumps({'volumes': []}) diff --git a/mimic/test/test_cinder.py b/mimic/test/test_cinder.py index 954df84cc0..fb0042f90b 100644 --- a/mimic/test/test_cinder.py +++ b/mimic/test/test_cinder.py @@ -26,9 +26,20 @@ def test_get_blockstorage_volume_list(self): """ Requesting block storage volumes for a tenant returns 200 and an empty list if no volumes are available for the given tenant - http://developer.openstack.org/api-ref-blockstorage-v2.html#getVolumesSimple + http://developer.openstack.org/api-ref-blockstorage-v2.html#listVolumes """ (response, content) = self.successResultOf(json_request( self, self.root, b"GET", self.uri + '/volumes')) self.assertEqual(200, response.code) self.assertEqual(content, {'volumes': []}) + + def test_get_blockstorage_volume_list_detail(self): + """ + Requesting block storage volume details for a tenant returns 200 and an + empty list if no volumes are available for the given tenant + http://developer.openstack.org/api-ref-blockstorage-v2.html#listVolumesDetail + """ + (response, content) = self.successResultOf(json_request( + self, self.root, b"GET", self.uri + '/volumes/detail')) + self.assertEqual(200, response.code) + self.assertEqual(content, {'volumes': []}) diff --git a/mimic/test/test_core.py b/mimic/test/test_core.py index 287c2fb3aa..3a6f2d3fcc 100644 --- a/mimic/test/test_core.py +++ b/mimic/test/test_core.py @@ -63,7 +63,7 @@ def test_from_plugin_includes_all_plugins(self): dns_plugin.dns, cinder_plugin.cinder )) - # all plugsin should be on the internal listing + # all plugins should be on the internal listing self.assertEqual( plugin_apis, set(core._uuid_to_api_internal.values())) @@ -71,10 +71,6 @@ def test_from_plugin_includes_all_plugins(self): self.assertEqual( set([]), set(core._uuid_to_api_external.values())) - self.assertEqual( - len(plugin_apis), - len(list(core.entries_for_tenant('any_tenant', {}, - 'http://mimic')))) def test_load_domain_plugin_includes_all_domain_plugins(self): """ diff --git a/setup.py b/setup.py index 6f51faa455..96a7a01b79 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ _NAME = "mimic" -_VERSION = "2.1.0" +_VERSION = "2.1.0+chq2" def setup_options(name, version):