From 3e37cd2e5a73c8fe5cc7e5227eb949eb0db654e4 Mon Sep 17 00:00:00 2001 From: Valeriy Ponomaryov Date: Mon, 12 Dec 2016 19:20:25 +0300 Subject: [PATCH] Rename consistency group modules to share groups Port of consistency groups to share groups consists of not only change of logic but also renames of several modules. So, rename modules first to reduce amount of changes that will be done in scope of main change. Partially-Implements BP manila-share-groups Change-Id: Ie93fa5680c29e2c208ca77f871817abb4cbd9f72 --- manila/api/v2/router.py | 9 ++--- ...gsnapshots.py => share_group_snapshots.py} | 8 ++-- ...{consistency_groups.py => share_groups.py} | 8 ++-- ...gsnapshots.py => share_group_snapshots.py} | 0 ...{consistency_groups.py => share_groups.py} | 0 .../__init__.py | 0 .../{consistency_group => share_group}/api.py | 0 ...shots.py => test_share_group_snapshots.py} | 4 +- ...istency_groups.py => test_share_groups.py} | 38 +++++++++---------- .../__init__.py | 0 .../test_api.py | 4 +- 11 files changed, 35 insertions(+), 36 deletions(-) rename manila/api/v2/{cgsnapshots.py => share_group_snapshots.py} (97%) rename manila/api/v2/{consistency_groups.py => share_groups.py} (98%) rename manila/api/views/{cgsnapshots.py => share_group_snapshots.py} (100%) rename manila/api/views/{consistency_groups.py => share_groups.py} (100%) rename manila/{consistency_group => share_group}/__init__.py (100%) rename manila/{consistency_group => share_group}/api.py (100%) rename manila/tests/api/v2/{test_cgsnapshots.py => test_share_group_snapshots.py} (99%) rename manila/tests/api/v2/{test_consistency_groups.py => test_share_groups.py} (97%) rename manila/tests/{consistency_group => share_group}/__init__.py (100%) rename manila/tests/{consistency_group => share_group}/test_api.py (99%) diff --git a/manila/api/v2/router.py b/manila/api/v2/router.py index 49932314ca..5e3c1bc125 100644 --- a/manila/api/v2/router.py +++ b/manila/api/v2/router.py @@ -31,12 +31,12 @@ from manila.api.v1 import share_servers from manila.api.v1 import share_types_extra_specs from manila.api.v1 import share_unmanage from manila.api.v2 import availability_zones -from manila.api.v2 import cgsnapshots -from manila.api.v2 import consistency_groups from manila.api.v2 import quota_class_sets from manila.api.v2 import quota_sets from manila.api.v2 import services from manila.api.v2 import share_export_locations +from manila.api.v2 import share_group_snapshots +from manila.api.v2 import share_groups from manila.api.v2 import share_instance_export_locations from manila.api.v2 import share_instances from manila.api.v2 import share_networks @@ -280,8 +280,7 @@ class APIRouter(manila.api.openstack.APIRouter): action="pools_detail", conditions={"method": ["GET"]}) - self.resources["consistency-groups"] = ( - consistency_groups.create_resource()) + self.resources["consistency-groups"] = share_groups.create_resource() mapper.resource("consistency-group", "consistency-groups", controller=self.resources["consistency-groups"], collection={"detail": "GET"}) @@ -291,7 +290,7 @@ class APIRouter(manila.api.openstack.APIRouter): action="action", conditions={"action": ["POST"]}) - self.resources["cgsnapshots"] = cgsnapshots.create_resource() + self.resources["cgsnapshots"] = share_group_snapshots.create_resource() mapper.resource("cgsnapshot", "cgsnapshots", controller=self.resources["cgsnapshots"], collection={"detail": "GET"}, diff --git a/manila/api/v2/cgsnapshots.py b/manila/api/v2/share_group_snapshots.py similarity index 97% rename from manila/api/v2/cgsnapshots.py rename to manila/api/v2/share_group_snapshots.py index 3178714915..2af9bcc0d7 100644 --- a/manila/api/v2/cgsnapshots.py +++ b/manila/api/v2/share_group_snapshots.py @@ -23,11 +23,11 @@ from webob import exc from manila.api import common from manila.api.openstack import wsgi -import manila.api.views.cgsnapshots as cg_views -import manila.consistency_group.api as cg_api +import manila.api.views.share_group_snapshots as sgs_views from manila import db from manila import exception from manila.i18n import _, _LI +import manila.share_group.api as sg_api LOG = log.getLogger(__name__) @@ -36,11 +36,11 @@ class CGSnapshotController(wsgi.Controller, wsgi.AdminActionsMixin): """The Consistency Group Snapshots API controller for the OpenStack API.""" resource_name = 'cgsnapshot' - _view_builder_class = cg_views.CGSnapshotViewBuilder + _view_builder_class = sgs_views.CGSnapshotViewBuilder def __init__(self): super(CGSnapshotController, self).__init__() - self.cg_api = cg_api.API() + self.cg_api = sg_api.API() @wsgi.Controller.api_version('2.4', experimental=True) @wsgi.Controller.authorize('get_cgsnapshot') diff --git a/manila/api/v2/consistency_groups.py b/manila/api/v2/share_groups.py similarity index 98% rename from manila/api/v2/consistency_groups.py rename to manila/api/v2/share_groups.py index cdb78cecf7..77302fea24 100644 --- a/manila/api/v2/consistency_groups.py +++ b/manila/api/v2/share_groups.py @@ -23,12 +23,12 @@ from webob import exc from manila.api import common from manila.api.openstack import wsgi -import manila.api.views.consistency_groups as cg_views -import manila.consistency_group.api as cg_api +import manila.api.views.share_groups as share_group_views from manila import db from manila import exception from manila.i18n import _, _LI from manila.share import share_types +import manila.share_group.api as sg_api LOG = log.getLogger(__name__) @@ -37,12 +37,12 @@ class CGController(wsgi.Controller, wsgi.AdminActionsMixin): """The Consistency Groups API controller for the OpenStack API.""" resource_name = 'consistency_group' - _view_builder_class = cg_views.CGViewBuilder + _view_builder_class = share_group_views.CGViewBuilder resource_name = 'consistency_group' def __init__(self): super(CGController, self).__init__() - self.cg_api = cg_api.API() + self.cg_api = sg_api.API() @wsgi.Controller.api_version('2.4', experimental=True) @wsgi.Controller.authorize('get') diff --git a/manila/api/views/cgsnapshots.py b/manila/api/views/share_group_snapshots.py similarity index 100% rename from manila/api/views/cgsnapshots.py rename to manila/api/views/share_group_snapshots.py diff --git a/manila/api/views/consistency_groups.py b/manila/api/views/share_groups.py similarity index 100% rename from manila/api/views/consistency_groups.py rename to manila/api/views/share_groups.py diff --git a/manila/consistency_group/__init__.py b/manila/share_group/__init__.py similarity index 100% rename from manila/consistency_group/__init__.py rename to manila/share_group/__init__.py diff --git a/manila/consistency_group/api.py b/manila/share_group/api.py similarity index 100% rename from manila/consistency_group/api.py rename to manila/share_group/api.py diff --git a/manila/tests/api/v2/test_cgsnapshots.py b/manila/tests/api/v2/test_share_group_snapshots.py similarity index 99% rename from manila/tests/api/v2/test_cgsnapshots.py rename to manila/tests/api/v2/test_share_group_snapshots.py index 79bb8c5441..13d9849c10 100644 --- a/manila/tests/api/v2/test_cgsnapshots.py +++ b/manila/tests/api/v2/test_share_group_snapshots.py @@ -25,7 +25,7 @@ import six import webob from manila.api.openstack import wsgi -import manila.api.v2.cgsnapshots as cgs +from manila.api.v2 import share_group_snapshots from manila.common import constants from manila import context from manila import db @@ -43,7 +43,7 @@ class CGSnapshotApiTest(test.TestCase): def setUp(self): super(self.__class__, self).setUp() - self.controller = cgs.CGSnapshotController() + self.controller = share_group_snapshots.CGSnapshotController() self.resource_name = self.controller.resource_name self.api_version = '2.4' self.mock_policy_check = self.mock_object( diff --git a/manila/tests/api/v2/test_consistency_groups.py b/manila/tests/api/v2/test_share_groups.py similarity index 97% rename from manila/tests/api/v2/test_consistency_groups.py rename to manila/tests/api/v2/test_share_groups.py index 5f1169a6f3..73df6d0275 100644 --- a/manila/tests/api/v2/test_consistency_groups.py +++ b/manila/tests/api/v2/test_share_groups.py @@ -25,14 +25,14 @@ import six import webob from manila.api.openstack import wsgi -import manila.api.v2.consistency_groups as cgs +from manila.api.v2 import share_groups from manila.common import constants -import manila.consistency_group.api as cg_api from manila import context from manila import db from manila import exception from manila import policy from manila.share import share_types +import manila.share_group.api as sg_api from manila import test from manila.tests.api import fakes from manila.tests import db_utils @@ -47,7 +47,7 @@ class CGApiTest(test.TestCase): def setUp(self): super(self.__class__, self).setUp() - self.controller = cgs.CGController() + self.controller = share_groups.CGController() self.resource_name = self.controller.resource_name self.fake_share_type = {'id': six.text_type(uuidutils.generate_uuid())} self.api_version = '2.4' @@ -467,7 +467,7 @@ class CGApiTest(test.TestCase): def test_cg_list_index(self): fake_cg, expected_cg = self._get_fake_simple_cg() - self.mock_object(cg_api.API, 'get_all', + self.mock_object(sg_api.API, 'get_all', mock.Mock(return_value=[fake_cg])) res_dict = self.controller.index(self.request) self.assertEqual([expected_cg], res_dict['consistency_groups']) @@ -475,7 +475,7 @@ class CGApiTest(test.TestCase): self.context, self.resource_name, 'get_all') def test_cg_list_index_no_cgs(self): - self.mock_object(cg_api.API, 'get_all', + self.mock_object(sg_api.API, 'get_all', mock.Mock(return_value=[])) res_dict = self.controller.index(self.request) self.assertEqual([], res_dict['consistency_groups']) @@ -485,7 +485,7 @@ class CGApiTest(test.TestCase): def test_cg_list_index_with_limit(self): fake_cg, expected_cg = self._get_fake_simple_cg() fake_cg2, expected_cg2 = self._get_fake_simple_cg(id="fake_id2") - self.mock_object(cg_api.API, 'get_all', + self.mock_object(sg_api.API, 'get_all', mock.Mock(return_value=[fake_cg, fake_cg2])) req = fakes.HTTPRequest.blank('/consistency_groups?limit=1', version=self.api_version, @@ -502,7 +502,7 @@ class CGApiTest(test.TestCase): def test_cg_list_index_with_limit_and_offset(self): fake_cg, expected_cg = self._get_fake_simple_cg() fake_cg2, expected_cg2 = self._get_fake_simple_cg(id="fake_id2") - self.mock_object(cg_api.API, 'get_all', + self.mock_object(sg_api.API, 'get_all', mock.Mock(return_value=[fake_cg, fake_cg2])) req = fakes.HTTPRequest.blank('/consistency_groups?limit=1&offset=1', version=self.api_version, @@ -518,7 +518,7 @@ class CGApiTest(test.TestCase): def test_cg_list_detail(self): fake_cg, expected_cg = self._get_fake_cg() - self.mock_object(cg_api.API, 'get_all', + self.mock_object(sg_api.API, 'get_all', mock.Mock(return_value=[fake_cg])) res_dict = self.controller.detail(self.request) @@ -528,7 +528,7 @@ class CGApiTest(test.TestCase): self.context, self.resource_name, 'get_all') def test_cg_list_detail_no_cgs(self): - self.mock_object(cg_api.API, 'get_all', + self.mock_object(sg_api.API, 'get_all', mock.Mock(return_value=[])) res_dict = self.controller.detail(self.request) @@ -545,7 +545,7 @@ class CGApiTest(test.TestCase): fake_cg, expected_cg = self._get_fake_cg(ctxt=req_context) fake_cg2, expected_cg2 = self._get_fake_cg(ctxt=req_context, id="fake_id2") - self.mock_object(cg_api.API, 'get_all', + self.mock_object(sg_api.API, 'get_all', mock.Mock(return_value=[fake_cg, fake_cg2])) res_dict = self.controller.detail(req) @@ -563,7 +563,7 @@ class CGApiTest(test.TestCase): fake_cg, expected_cg = self._get_fake_cg(ctxt=req_context) fake_cg2, expected_cg2 = self._get_fake_cg( id="fake_id2", ctxt=req_context) - self.mock_object(cg_api.API, 'get_all', + self.mock_object(sg_api.API, 'get_all', mock.Mock(return_value=[fake_cg, fake_cg2])) res_dict = self.controller.detail(req) @@ -575,9 +575,9 @@ class CGApiTest(test.TestCase): def test_cg_delete(self): fake_cg, expected_cg = self._get_fake_cg() - self.mock_object(cg_api.API, 'get', + self.mock_object(sg_api.API, 'get', mock.Mock(return_value=fake_cg)) - self.mock_object(cg_api.API, 'delete') + self.mock_object(sg_api.API, 'delete') res = self.controller.delete(self.request, fake_cg['id']) @@ -587,7 +587,7 @@ class CGApiTest(test.TestCase): def test_cg_delete_cg_not_found(self): fake_cg, expected_cg = self._get_fake_cg() - self.mock_object(cg_api.API, 'get', + self.mock_object(sg_api.API, 'get', mock.Mock(side_effect=exception.NotFound)) self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete, @@ -597,9 +597,9 @@ class CGApiTest(test.TestCase): def test_cg_delete_in_conflicting_status(self): fake_cg, expected_cg = self._get_fake_cg() - self.mock_object(cg_api.API, 'get', + self.mock_object(sg_api.API, 'get', mock.Mock(return_value=fake_cg)) - self.mock_object(cg_api.API, 'delete', mock.Mock( + self.mock_object(sg_api.API, 'delete', mock.Mock( side_effect=exception.InvalidConsistencyGroup(reason='blah'))) self.assertRaises(webob.exc.HTTPConflict, self.controller.delete, @@ -609,7 +609,7 @@ class CGApiTest(test.TestCase): def test_cg_show(self): fake_cg, expected_cg = self._get_fake_cg() - self.mock_object(cg_api.API, 'get', + self.mock_object(sg_api.API, 'get', mock.Mock(return_value=fake_cg)) req = fakes.HTTPRequest.blank( '/consistency_groups/%s' % fake_cg['id'], @@ -630,7 +630,7 @@ class CGApiTest(test.TestCase): req.environ['manila.context'] = admin_context fake_cg, expected_cg = self._get_fake_cg( ctxt=admin_context, id='my_cg_id') - self.mock_object(cg_api.API, 'get', + self.mock_object(sg_api.API, 'get', mock.Mock(return_value=fake_cg)) res_dict = self.controller.show(req, fake_cg['id']) @@ -647,7 +647,7 @@ class CGApiTest(test.TestCase): req_context = req.environ['manila.context'] fake_cg, expected_cg = self._get_fake_cg( ctxt=req_context, id='myfakecg') - self.mock_object(cg_api.API, 'get', + self.mock_object(sg_api.API, 'get', mock.Mock(side_effect=exception.NotFound)) self.assertRaises(webob.exc.HTTPNotFound, self.controller.show, diff --git a/manila/tests/consistency_group/__init__.py b/manila/tests/share_group/__init__.py similarity index 100% rename from manila/tests/consistency_group/__init__.py rename to manila/tests/share_group/__init__.py diff --git a/manila/tests/consistency_group/test_api.py b/manila/tests/share_group/test_api.py similarity index 99% rename from manila/tests/consistency_group/test_api.py rename to manila/tests/share_group/test_api.py index b6c00d20e2..24cf5899c0 100644 --- a/manila/tests/consistency_group/test_api.py +++ b/manila/tests/share_group/test_api.py @@ -23,11 +23,11 @@ from oslo_config import cfg from oslo_utils import timeutils from manila.common import constants -import manila.consistency_group.api as cg_api from manila import context from manila import db as db_driver from manila import exception from manila.share import share_types +import manila.share_group.api as sg_api from manila import test from manila.tests.api.contrib import stubs @@ -82,7 +82,7 @@ class CGAPITestCase(test.TestCase): self.scheduler_rpcapi = mock.Mock() self.share_rpcapi = mock.Mock() self.share_api = mock.Mock() - self.api = cg_api.API() + self.api = sg_api.API() self.mock_object(self.api, 'share_rpcapi', self.share_rpcapi) self.mock_object(self.api, 'share_api', self.share_api) self.mock_object(self.api, 'scheduler_rpcapi', self.scheduler_rpcapi)