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
This commit is contained in:
Valeriy Ponomaryov 2016-12-12 19:20:25 +03:00
parent 9afae8e143
commit 3e37cd2e5a
11 changed files with 35 additions and 36 deletions

View File

@ -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"},

View File

@ -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')

View File

@ -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')

View File

@ -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(

View File

@ -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,

View File

@ -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)