diff --git a/etc/manila/api-paste.ini b/etc/manila/api-paste.ini index 92a5a75903..22948b2a62 100644 --- a/etc/manila/api-paste.ini +++ b/etc/manila/api-paste.ini @@ -26,9 +26,9 @@ paste.filter_factory = manila.api.middleware.sizelimit:RequestBodySizeLimiter.fa paste.app_factory = manila.api.v1.router:APIRouter.factory [pipeline:apiversions] -pipeline = faultwrap osvolumeversionapp +pipeline = faultwrap osshareversionapp -[app:osvolumeversionapp] +[app:osshareversionapp] paste.app_factory = manila.api.versions:Versions.factory ########## diff --git a/manila/api/extensions.py b/manila/api/extensions.py index f1d7b5b580..af3a078f6f 100644 --- a/manila/api/extensions.py +++ b/manila/api/extensions.py @@ -184,6 +184,7 @@ class ExtensionManager(object): LOG.audit(_('Initializing extension manager.')) self.cls_list = FLAGS.osapi_share_extension + self.extensions = {} self._load_extensions() diff --git a/manila/api/v1/router.py b/manila/api/v1/router.py index b11f6b193b..9a5a050b9f 100644 --- a/manila/api/v1/router.py +++ b/manila/api/v1/router.py @@ -58,7 +58,7 @@ class APIRouter(manila.api.openstack.APIRouter): self.resources['snapshots'] = share_snapshots.create_resource() mapper.resource("snapshot", "snapshots", - controller=self.resources['share-snapshots'], + controller=self.resources['snapshots'], collection={'detail': 'GET'}, member={'action': 'POST'}) diff --git a/manila/api/v1/share_snapshots.py b/manila/api/v1/share_snapshots.py index ddacef681b..9bc9b742e4 100644 --- a/manila/api/v1/share_snapshots.py +++ b/manila/api/v1/share_snapshots.py @@ -44,17 +44,17 @@ def make_snapshot(elem): class SnapshotTemplate(xmlutil.TemplateBuilder): def construct(self): - root = xmlutil.TemplateElement('share-snapshot', - selector='share-snapshot') + root = xmlutil.TemplateElement('snapshot', + selector='snapshot') make_snapshot(root) return xmlutil.MasterTemplate(root, 1) class SnapshotsTemplate(xmlutil.TemplateBuilder): def construct(self): - root = xmlutil.TemplateElement('share-snapshots') - elem = xmlutil.SubTemplateElement(root, 'share-snapshot', - selector='share-snapshots') + root = xmlutil.TemplateElement('snapshots') + elem = xmlutil.SubTemplateElement(root, 'snapshot', + selector='snapshots') make_snapshot(elem) return xmlutil.MasterTemplate(root, 1) @@ -137,10 +137,10 @@ class ShareSnapshotsController(wsgi.Controller): """Creates a new snapshot.""" context = req.environ['manila.context'] - if not self.is_valid_body(body, 'share-snapshot'): + if not self.is_valid_body(body, 'snapshot'): raise exc.HTTPUnprocessableEntity() - snapshot = body['share-snapshot'] + snapshot = body['snapshot'] share_id = snapshot['share_id'] share = self.share_api.get(context, share_id) @@ -173,13 +173,13 @@ def create_resource(): # class Share_snapshots(extensions.ExtensionDescriptor): # """Enable share snapshtos API.""" # name = 'ShareSnapshots' -# alias = 'share-snapshots' +# alias = 'snapshots' # namespace = '' # updated = '2013-03-01T00:00:00+00:00' # # def get_resources(self): # controller = ShareSnapshotsController() # resource = extensions.ResourceExtension( -# 'share-snapshots', controller, +# 'snapshots', controller, # collection_actions={'detail': 'GET'}) # return [resource] diff --git a/manila/api/views/share_snapshots.py b/manila/api/views/share_snapshots.py index ec69737287..fc2411d799 100644 --- a/manila/api/views/share_snapshots.py +++ b/manila/api/views/share_snapshots.py @@ -22,7 +22,7 @@ from manila.openstack.common import log as logging class ViewBuilder(common.ViewBuilder): """Model a server API response as a python dictionary.""" - _collection_name = 'share-snapshots' + _collection_name = 'snapshots' def summary_list(self, request, snapshots): """Show a list of share snapshots without many details.""" @@ -35,7 +35,7 @@ class ViewBuilder(common.ViewBuilder): def summary(self, request, snapshot): """Generic, non-detailed view of an share snapshot.""" return { - 'share-snapshot': { + 'snapshot': { 'id': snapshot.get('id'), 'name': snapshot.get('display_name'), 'links': self._get_links(request, snapshot['id']) @@ -45,7 +45,7 @@ class ViewBuilder(common.ViewBuilder): def detail(self, request, snapshot): """Detailed view of a single share snapshot.""" return { - 'share-snapshot': { + 'snapshot': { 'id': snapshot.get('id'), 'share_id': snapshot.get('share_id'), 'share_size': snapshot.get('share_size'), @@ -61,7 +61,7 @@ class ViewBuilder(common.ViewBuilder): def _list_view(self, func, request, snapshots): """Provide a view for a list of share snapshots.""" - snapshots_list = [func(request, snapshot)['share-snapshot'] + snapshots_list = [func(request, snapshot)['snapshot'] for snapshot in snapshots] snapshots_links = self._get_collection_links(request, snapshots, diff --git a/manila/db/api.py b/manila/db/api.py index 2e6f5e1c77..01ba33643c 100644 --- a/manila/db/api.py +++ b/manila/db/api.py @@ -60,7 +60,7 @@ db_opts = [ default='share-%s', help='Template string to be used to generate share names'), cfg.StrOpt('share_snapshot_name_template', - default='share-snapshot-%s', + default='snapshot-%s', help='Template string to be used to generate share snapshot ' 'names'), cfg.StrOpt('snapshot_name_template', diff --git a/manila/tests/api/v1/test_share_snapshots.py b/manila/tests/api/v1/test_share_snapshots.py index d84cb31051..231cacbf94 100644 --- a/manila/tests/api/v1/test_share_snapshots.py +++ b/manila/tests/api/v1/test_share_snapshots.py @@ -44,26 +44,26 @@ class ShareSnapshotApiTest(test.TestCase): self.stubs.Set(share_api.API, 'create_snapshot', stubs.stub_snapshot_create) body = { - 'share-snapshot': { + 'snapshot': { 'share_id': 100, 'force': False, 'name': 'fake_share_name', 'description': 'fake_share_description', } } - req = fakes.HTTPRequest.blank('/share-snapshots') + req = fakes.HTTPRequest.blank('/snapshots') res_dict = self.controller.create(req, body) expected = { - 'share-snapshot': { + 'snapshot': { 'id': 200, 'name': 'fake_share_name', 'links': [ { - 'href': 'http://localhost/v1/fake/share-snapshots/200', + 'href': 'http://localhost/v1/fake/snapshots/200', 'rel': 'self' }, { - 'href': 'http://localhost/fake/share-snapshots/200', + 'href': 'http://localhost/fake/snapshots/200', 'rel': 'bookmark' } ], @@ -73,7 +73,7 @@ class ShareSnapshotApiTest(test.TestCase): def test_snapshot_create_no_body(self): body = {} - req = fakes.HTTPRequest.blank('/share-snapshots') + req = fakes.HTTPRequest.blank('/snapshots') self.assertRaises(webob.exc.HTTPUnprocessableEntity, self.controller.create, req, @@ -82,24 +82,24 @@ class ShareSnapshotApiTest(test.TestCase): def test_snapshot_delete(self): self.stubs.Set(share_api.API, 'delete_snapshot', stubs.stub_snapshot_delete) - req = fakes.HTTPRequest.blank('/share-snapshots/200') + req = fakes.HTTPRequest.blank('/snapshots/200') resp = self.controller.delete(req, 200) self.assertEqual(resp.status_int, 202) def test_snapshot_delete_nofound(self): self.stubs.Set(share_api.API, 'get_snapshot', stubs.stub_snapshot_get_notfound) - req = fakes.HTTPRequest.blank('/share-snapshots/200') + req = fakes.HTTPRequest.blank('/snapshots/200') self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete, req, 200) def test_snapshot_show(self): - req = fakes.HTTPRequest.blank('/share-snapshots/200') + req = fakes.HTTPRequest.blank('/snapshots/200') res_dict = self.controller.show(req, 200) expected = { - 'share-snapshot': { + 'snapshot': { 'id': 200, 'share_id': 'fakeshareid', 'share_size': 1, @@ -111,11 +111,11 @@ class ShareSnapshotApiTest(test.TestCase): 'export_location': 'fakesnaplocation', 'links': [ { - 'href': 'http://localhost/v1/fake/share-snapshots/200', + 'href': 'http://localhost/v1/fake/snapshots/200', 'rel': 'self', }, { - 'href': 'http://localhost/fake/share-snapshots/200', + 'href': 'http://localhost/fake/snapshots/200', 'rel': 'bookmark', }, ], @@ -126,7 +126,7 @@ class ShareSnapshotApiTest(test.TestCase): def test_snapshot_show_nofound(self): self.stubs.Set(share_api.API, 'get_snapshot', stubs.stub_snapshot_get_notfound) - req = fakes.HTTPRequest.blank('/share-snapshots/200') + req = fakes.HTTPRequest.blank('/snapshots/200') self.assertRaises(webob.exc.HTTPNotFound, self.controller.show, req, '200') @@ -134,21 +134,21 @@ class ShareSnapshotApiTest(test.TestCase): def test_snapshot_list_summary(self): self.stubs.Set(share_api.API, 'get_all_snapshots', stubs.stub_snapshot_get_all_by_project) - req = fakes.HTTPRequest.blank('/share-snapshots') + req = fakes.HTTPRequest.blank('/snapshots') res_dict = self.controller.index(req) expected = { - 'share-snapshots': [ + 'snapshots': [ { 'name': 'displaysnapname', 'id': 2, 'links': [ { 'href': 'http://localhost/v1/fake/' - 'share-snapshots/2', + 'snapshots/2', 'rel': 'self' }, { - 'href': 'http://localhost/fake/share-snapshots/2', + 'href': 'http://localhost/fake/snapshots/2', 'rel': 'bookmark' } ], @@ -162,7 +162,7 @@ class ShareSnapshotApiTest(test.TestCase): req = fakes.HTTPRequest.blank('/shares/detail', environ=env) res_dict = self.controller.detail(req) expected = { - 'share-snapshots': [ + 'snapshots': [ { 'id': 2, 'share_id': 'fakeshareid', @@ -175,12 +175,12 @@ class ShareSnapshotApiTest(test.TestCase): 'export_location': 'fakesnaplocation', 'links': [ { - 'href': 'http://localhost/v1/fake/share-snapshots/' + 'href': 'http://localhost/v1/fake/snapshots/' '2', 'rel': 'self', }, { - 'href': 'http://localhost/fake/share-snapshots/2', + 'href': 'http://localhost/fake/snapshots/2', 'rel': 'bookmark', }, ],