Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLOC-4489] Add limited support for detailed volume list #1

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
Change Logs
===========

Next Version
------------

* The Cinder V2 API now has limited support for the `List volumes with details <http://developer.openstack.org/api-ref-blockstorage-v2.html#listVolumesDetail>`_ endpoint.
27 changes: 23 additions & 4 deletions mimic/rest/cinder_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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):
"""
Expand All @@ -65,8 +73,19 @@ def __init__(self, api_mock, uri_prefix, session_store, name):
@app.route('/v2/<string:tenant_id>/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/<string:tenant_id>/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': []})
13 changes: 12 additions & 1 deletion mimic/test/test_cinder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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': []})
6 changes: 1 addition & 5 deletions mimic/test/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,14 @@ 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()))
# the external listing should still be empty
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):
"""
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@


_NAME = "mimic"
_VERSION = "2.1.0"
_VERSION = "2.1.0+chq2"


def setup_options(name, version):
Expand Down