Add ConsistencyGroupStatus enum field
This change adds a new enum and field, ConsistencyGroupStatus and ConsistencyGroupStatusField, that will hold the constants for the 'status' field of the ConsistencyGroup object. This enum and field are based off the base oslo.versionedobjects enum and field. This also changes over the ConsistencyGroup object to use the new field (and bumps the version so newer versions know to enforce valid values). Finally, all uses of strings for comparison and assignment to this field are changed over to use the constants defined within the enum. Change-Id: Icee2727f0a550541876c63b6e7340acf3de553c8 Implements: bp cinder-object-fields
This commit is contained in:
parent
81f7986c16
commit
14ef9330b1
@ -29,6 +29,7 @@ from cinder.db import base
|
|||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _, _LE, _LW
|
from cinder.i18n import _, _LE, _LW
|
||||||
from cinder import objects
|
from cinder import objects
|
||||||
|
from cinder.objects import fields as c_fields
|
||||||
import cinder.policy
|
import cinder.policy
|
||||||
from cinder import quota
|
from cinder import quota
|
||||||
from cinder.scheduler import rpcapi as scheduler_rpcapi
|
from cinder.scheduler import rpcapi as scheduler_rpcapi
|
||||||
@ -42,7 +43,8 @@ CONF = cfg.CONF
|
|||||||
|
|
||||||
LOG = logging.getLogger(__name__)
|
LOG = logging.getLogger(__name__)
|
||||||
CGQUOTAS = quota.CGQUOTAS
|
CGQUOTAS = quota.CGQUOTAS
|
||||||
VALID_REMOVE_VOL_FROM_CG_STATUS = ('available', 'in-use',)
|
VALID_REMOVE_VOL_FROM_CG_STATUS = (c_fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
|
c_fields.ConsistencyGroupStatus.IN_USE)
|
||||||
|
|
||||||
|
|
||||||
def wrap_check_policy(func):
|
def wrap_check_policy(func):
|
||||||
@ -130,7 +132,7 @@ class API(base.Base):
|
|||||||
kwargs = {'user_id': context.user_id,
|
kwargs = {'user_id': context.user_id,
|
||||||
'project_id': context.project_id,
|
'project_id': context.project_id,
|
||||||
'availability_zone': availability_zone,
|
'availability_zone': availability_zone,
|
||||||
'status': "creating",
|
'status': c_fields.ConsistencyGroupStatus.CREATING,
|
||||||
'name': name,
|
'name': name,
|
||||||
'description': description,
|
'description': description,
|
||||||
'volume_type_id': req_volume_type_ids}
|
'volume_type_id': req_volume_type_ids}
|
||||||
@ -194,7 +196,7 @@ class API(base.Base):
|
|||||||
kwargs = {
|
kwargs = {
|
||||||
'user_id': context.user_id,
|
'user_id': context.user_id,
|
||||||
'project_id': context.project_id,
|
'project_id': context.project_id,
|
||||||
'status': "creating",
|
'status': c_fields.ConsistencyGroupStatus.CREATING,
|
||||||
'name': name,
|
'name': name,
|
||||||
'description': description,
|
'description': description,
|
||||||
'cgsnapshot_id': cgsnapshot_id,
|
'cgsnapshot_id': cgsnapshot_id,
|
||||||
@ -440,7 +442,9 @@ class API(base.Base):
|
|||||||
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if not force and group.status not in ["available", "error"]:
|
if not force and group.status not in (
|
||||||
|
[c_fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
|
c_fields.ConsistencyGroupStatus.ERROR]):
|
||||||
msg = _("Consistency group status must be available or error, "
|
msg = _("Consistency group status must be available or error, "
|
||||||
"but current status is: %s") % group.status
|
"but current status is: %s") % group.status
|
||||||
raise exception.InvalidConsistencyGroup(reason=msg)
|
raise exception.InvalidConsistencyGroup(reason=msg)
|
||||||
@ -477,7 +481,7 @@ class API(base.Base):
|
|||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exception.InvalidConsistencyGroup(reason=msg)
|
raise exception.InvalidConsistencyGroup(reason=msg)
|
||||||
|
|
||||||
group.status = 'deleting'
|
group.status = c_fields.ConsistencyGroupStatus.DELETING
|
||||||
group.terminated_at = timeutils.utcnow()
|
group.terminated_at = timeutils.utcnow()
|
||||||
group.save()
|
group.save()
|
||||||
|
|
||||||
@ -486,7 +490,7 @@ class API(base.Base):
|
|||||||
def update(self, context, group, name, description,
|
def update(self, context, group, name, description,
|
||||||
add_volumes, remove_volumes):
|
add_volumes, remove_volumes):
|
||||||
"""Update consistency group."""
|
"""Update consistency group."""
|
||||||
if group.status != 'available':
|
if group.status != c_fields.ConsistencyGroupStatus.AVAILABLE:
|
||||||
msg = _("Consistency group status must be available, "
|
msg = _("Consistency group status must be available, "
|
||||||
"but current status is: %s.") % group.status
|
"but current status is: %s.") % group.status
|
||||||
raise exception.InvalidConsistencyGroup(reason=msg)
|
raise exception.InvalidConsistencyGroup(reason=msg)
|
||||||
|
@ -3883,7 +3883,7 @@ def consistencygroup_destroy(context, consistencygroup_id):
|
|||||||
with session.begin():
|
with session.begin():
|
||||||
model_query(context, models.ConsistencyGroup, session=session).\
|
model_query(context, models.ConsistencyGroup, session=session).\
|
||||||
filter_by(id=consistencygroup_id).\
|
filter_by(id=consistencygroup_id).\
|
||||||
update({'status': 'deleted',
|
update({'status': fields.ConsistencyGroupStatus.DELETED,
|
||||||
'deleted': True,
|
'deleted': True,
|
||||||
'deleted_at': timeutils.utcnow(),
|
'deleted_at': timeutils.utcnow(),
|
||||||
'updated_at': literal_column('updated_at')})
|
'updated_at': literal_column('updated_at')})
|
||||||
|
@ -17,6 +17,7 @@ from cinder import exception
|
|||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import objects
|
from cinder import objects
|
||||||
from cinder.objects import base
|
from cinder.objects import base
|
||||||
|
from cinder.objects import fields as c_fields
|
||||||
from oslo_versionedobjects import fields
|
from oslo_versionedobjects import fields
|
||||||
|
|
||||||
OPTIONAL_FIELDS = ['cgsnapshots', 'volumes']
|
OPTIONAL_FIELDS = ['cgsnapshots', 'volumes']
|
||||||
@ -27,7 +28,8 @@ class ConsistencyGroup(base.CinderPersistentObject, base.CinderObject,
|
|||||||
base.CinderObjectDictCompat):
|
base.CinderObjectDictCompat):
|
||||||
# Version 1.0: Initial version
|
# Version 1.0: Initial version
|
||||||
# Version 1.1: Added cgsnapshots and volumes relationships
|
# Version 1.1: Added cgsnapshots and volumes relationships
|
||||||
VERSION = '1.1'
|
# Version 1.2: Changed 'status' field to use ConsistencyGroupStatusField
|
||||||
|
VERSION = '1.2'
|
||||||
|
|
||||||
fields = {
|
fields = {
|
||||||
'id': fields.UUIDField(),
|
'id': fields.UUIDField(),
|
||||||
@ -38,7 +40,7 @@ class ConsistencyGroup(base.CinderPersistentObject, base.CinderObject,
|
|||||||
'name': fields.StringField(nullable=True),
|
'name': fields.StringField(nullable=True),
|
||||||
'description': fields.StringField(nullable=True),
|
'description': fields.StringField(nullable=True),
|
||||||
'volume_type_id': fields.UUIDField(nullable=True),
|
'volume_type_id': fields.UUIDField(nullable=True),
|
||||||
'status': fields.StringField(nullable=True),
|
'status': c_fields.ConsistencyGroupStatusField(nullable=True),
|
||||||
'cgsnapshot_id': fields.UUIDField(nullable=True),
|
'cgsnapshot_id': fields.UUIDField(nullable=True),
|
||||||
'source_cgid': fields.UUIDField(nullable=True),
|
'source_cgid': fields.UUIDField(nullable=True),
|
||||||
'cgsnapshots': fields.ObjectField('CGSnapshotList', nullable=True),
|
'cgsnapshots': fields.ObjectField('CGSnapshotList', nullable=True),
|
||||||
|
@ -41,3 +41,25 @@ class BackupStatus(Enum):
|
|||||||
|
|
||||||
class BackupStatusField(BaseEnumField):
|
class BackupStatusField(BaseEnumField):
|
||||||
AUTO_TYPE = BackupStatus()
|
AUTO_TYPE = BackupStatus()
|
||||||
|
|
||||||
|
|
||||||
|
class ConsistencyGroupStatus(Enum):
|
||||||
|
ERROR = 'error'
|
||||||
|
AVAILABLE = 'available'
|
||||||
|
CREATING = 'creating'
|
||||||
|
DELETING = 'deleting'
|
||||||
|
DELETED = 'deleted'
|
||||||
|
UPDATING = 'updating'
|
||||||
|
IN_USE = 'in-use'
|
||||||
|
ERROR_DELETING = 'error_deleting'
|
||||||
|
|
||||||
|
ALL = (ERROR, AVAILABLE, CREATING, DELETING, DELETED,
|
||||||
|
UPDATING, IN_USE, ERROR_DELETING)
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
super(ConsistencyGroupStatus, self).__init__(
|
||||||
|
valid_values=ConsistencyGroupStatus.ALL)
|
||||||
|
|
||||||
|
|
||||||
|
class ConsistencyGroupStatusField(BaseEnumField):
|
||||||
|
AUTO_TYPE = ConsistencyGroupStatus()
|
||||||
|
@ -29,6 +29,7 @@ from cinder import db
|
|||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
from cinder import objects
|
from cinder import objects
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import test
|
from cinder import test
|
||||||
from cinder.tests.unit.api import fakes
|
from cinder.tests.unit.api import fakes
|
||||||
from cinder.tests.unit.api.v2 import stubs
|
from cinder.tests.unit.api.v2 import stubs
|
||||||
@ -53,7 +54,7 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
volume_type_id='123456',
|
volume_type_id='123456',
|
||||||
availability_zone='az1',
|
availability_zone='az1',
|
||||||
host='fakehost',
|
host='fakehost',
|
||||||
status='creating'):
|
status=fields.ConsistencyGroupStatus.CREATING):
|
||||||
"""Create a consistency group object."""
|
"""Create a consistency group object."""
|
||||||
ctxt = ctxt or self.ctxt
|
ctxt = ctxt or self.ctxt
|
||||||
consistencygroup = objects.ConsistencyGroup(ctxt)
|
consistencygroup = objects.ConsistencyGroup(ctxt)
|
||||||
@ -366,7 +367,8 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
res_dict['badRequest']['message'])
|
res_dict['badRequest']['message'])
|
||||||
|
|
||||||
def test_delete_consistencygroup_available(self):
|
def test_delete_consistencygroup_available(self):
|
||||||
consistencygroup = self._create_consistencygroup(status='available')
|
consistencygroup = self._create_consistencygroup(
|
||||||
|
status=fields.ConsistencyGroupStatus.AVAILABLE)
|
||||||
req = webob.Request.blank('/v2/fake/consistencygroups/%s/delete' %
|
req = webob.Request.blank('/v2/fake/consistencygroups/%s/delete' %
|
||||||
consistencygroup.id)
|
consistencygroup.id)
|
||||||
req.method = 'POST'
|
req.method = 'POST'
|
||||||
@ -378,7 +380,8 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
consistencygroup = objects.ConsistencyGroup.get_by_id(
|
consistencygroup = objects.ConsistencyGroup.get_by_id(
|
||||||
self.ctxt, consistencygroup.id)
|
self.ctxt, consistencygroup.id)
|
||||||
self.assertEqual(202, res.status_int)
|
self.assertEqual(202, res.status_int)
|
||||||
self.assertEqual('deleting', consistencygroup.status)
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETING,
|
||||||
|
consistencygroup.status)
|
||||||
|
|
||||||
consistencygroup.destroy()
|
consistencygroup.destroy()
|
||||||
|
|
||||||
@ -396,7 +399,8 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
res_dict['itemNotFound']['message'])
|
res_dict['itemNotFound']['message'])
|
||||||
|
|
||||||
def test_delete_consistencygroup_with_Invalidconsistencygroup(self):
|
def test_delete_consistencygroup_with_Invalidconsistencygroup(self):
|
||||||
consistencygroup = self._create_consistencygroup(status='invalid')
|
consistencygroup = self._create_consistencygroup(
|
||||||
|
status=fields.ConsistencyGroupStatus.IN_USE)
|
||||||
req = webob.Request.blank('/v2/fake/consistencygroups/%s/delete' %
|
req = webob.Request.blank('/v2/fake/consistencygroups/%s/delete' %
|
||||||
consistencygroup.id)
|
consistencygroup.id)
|
||||||
req.method = 'POST'
|
req.method = 'POST'
|
||||||
@ -409,7 +413,7 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
self.assertEqual(400, res.status_int)
|
self.assertEqual(400, res.status_int)
|
||||||
self.assertEqual(400, res_dict['badRequest']['code'])
|
self.assertEqual(400, res_dict['badRequest']['code'])
|
||||||
msg = (_('Invalid ConsistencyGroup: Consistency group status must be '
|
msg = (_('Invalid ConsistencyGroup: Consistency group status must be '
|
||||||
'available or error, but current status is: invalid'))
|
'available or error, but current status is: in-use'))
|
||||||
self.assertEqual(msg, res_dict['badRequest']['message'])
|
self.assertEqual(msg, res_dict['badRequest']['message'])
|
||||||
|
|
||||||
consistencygroup.destroy()
|
consistencygroup.destroy()
|
||||||
@ -417,7 +421,7 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
def test_delete_consistencygroup_no_host(self):
|
def test_delete_consistencygroup_no_host(self):
|
||||||
consistencygroup = self._create_consistencygroup(
|
consistencygroup = self._create_consistencygroup(
|
||||||
host=None,
|
host=None,
|
||||||
status='error')
|
status=fields.ConsistencyGroupStatus.ERROR)
|
||||||
req = webob.Request.blank('/v2/fake/consistencygroups/%s/delete' %
|
req = webob.Request.blank('/v2/fake/consistencygroups/%s/delete' %
|
||||||
consistencygroup.id)
|
consistencygroup.id)
|
||||||
req.method = 'POST'
|
req.method = 'POST'
|
||||||
@ -430,7 +434,7 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
cg = objects.ConsistencyGroup.get_by_id(
|
cg = objects.ConsistencyGroup.get_by_id(
|
||||||
context.get_admin_context(read_deleted='yes'),
|
context.get_admin_context(read_deleted='yes'),
|
||||||
consistencygroup.id)
|
consistencygroup.id)
|
||||||
self.assertEqual('deleted', cg.status)
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETED, cg.status)
|
||||||
self.assertIsNone(cg.host)
|
self.assertIsNone(cg.host)
|
||||||
|
|
||||||
def test_create_delete_consistencygroup_update_quota(self):
|
def test_create_delete_consistencygroup_update_quota(self):
|
||||||
@ -449,20 +453,21 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
fake_type['name'])
|
fake_type['name'])
|
||||||
self.cg_api.update_quota.assert_called_once_with(
|
self.cg_api.update_quota.assert_called_once_with(
|
||||||
self.ctxt, cg, 1)
|
self.ctxt, cg, 1)
|
||||||
self.assertEqual('creating', cg.status)
|
self.assertEqual(fields.ConsistencyGroupStatus.CREATING, cg.status)
|
||||||
self.assertIsNone(cg.host)
|
self.assertIsNone(cg.host)
|
||||||
self.cg_api.update_quota.reset_mock()
|
self.cg_api.update_quota.reset_mock()
|
||||||
cg.status = 'error'
|
cg.status = fields.ConsistencyGroupStatus.ERROR
|
||||||
self.cg_api.delete(self.ctxt, cg)
|
self.cg_api.delete(self.ctxt, cg)
|
||||||
self.cg_api.update_quota.assert_called_once_with(
|
self.cg_api.update_quota.assert_called_once_with(
|
||||||
self.ctxt, cg, -1, self.ctxt.project_id)
|
self.ctxt, cg, -1, self.ctxt.project_id)
|
||||||
cg = objects.ConsistencyGroup.get_by_id(
|
cg = objects.ConsistencyGroup.get_by_id(
|
||||||
context.get_admin_context(read_deleted='yes'),
|
context.get_admin_context(read_deleted='yes'),
|
||||||
cg.id)
|
cg.id)
|
||||||
self.assertEqual('deleted', cg.status)
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETED, cg.status)
|
||||||
|
|
||||||
def test_delete_consistencygroup_with_invalid_body(self):
|
def test_delete_consistencygroup_with_invalid_body(self):
|
||||||
consistencygroup = self._create_consistencygroup(status='available')
|
consistencygroup = self._create_consistencygroup(
|
||||||
|
status=fields.ConsistencyGroupStatus.AVAILABLE)
|
||||||
req = webob.Request.blank('/v2/fake/consistencygroups/%s/delete' %
|
req = webob.Request.blank('/v2/fake/consistencygroups/%s/delete' %
|
||||||
consistencygroup.id)
|
consistencygroup.id)
|
||||||
req.method = 'POST'
|
req.method = 'POST'
|
||||||
@ -474,7 +479,8 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
self.assertEqual(400, res.status_int)
|
self.assertEqual(400, res.status_int)
|
||||||
|
|
||||||
def test_delete_consistencygroup_with_invalid_force_value_in_body(self):
|
def test_delete_consistencygroup_with_invalid_force_value_in_body(self):
|
||||||
consistencygroup = self._create_consistencygroup(status='available')
|
consistencygroup = self._create_consistencygroup(
|
||||||
|
status=fields.ConsistencyGroupStatus.AVAILABLE)
|
||||||
req = webob.Request.blank('/v2/fake/consistencygroups/%s/delete' %
|
req = webob.Request.blank('/v2/fake/consistencygroups/%s/delete' %
|
||||||
consistencygroup.id)
|
consistencygroup.id)
|
||||||
req.method = 'POST'
|
req.method = 'POST'
|
||||||
@ -486,7 +492,8 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
self.assertEqual(400, res.status_int)
|
self.assertEqual(400, res.status_int)
|
||||||
|
|
||||||
def test_delete_consistencygroup_with_empty_force_value_in_body(self):
|
def test_delete_consistencygroup_with_empty_force_value_in_body(self):
|
||||||
consistencygroup = self._create_consistencygroup(status='available')
|
consistencygroup = self._create_consistencygroup(
|
||||||
|
status=fields.ConsistencyGroupStatus.AVAILABLE)
|
||||||
req = webob.Request.blank('/v2/fake/consistencygroups/%s/delete' %
|
req = webob.Request.blank('/v2/fake/consistencygroups/%s/delete' %
|
||||||
consistencygroup.id)
|
consistencygroup.id)
|
||||||
req.method = 'POST'
|
req.method = 'POST'
|
||||||
@ -519,8 +526,9 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
'cinder.api.openstack.wsgi.Controller.validate_name_and_description')
|
'cinder.api.openstack.wsgi.Controller.validate_name_and_description')
|
||||||
def test_update_consistencygroup_success(self, mock_validate):
|
def test_update_consistencygroup_success(self, mock_validate):
|
||||||
volume_type_id = '123456'
|
volume_type_id = '123456'
|
||||||
consistencygroup = self._create_consistencygroup(status='available',
|
consistencygroup = self._create_consistencygroup(
|
||||||
host='test_host')
|
status=fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
|
host='test_host')
|
||||||
|
|
||||||
remove_volume_id = utils.create_volume(
|
remove_volume_id = utils.create_volume(
|
||||||
self.ctxt,
|
self.ctxt,
|
||||||
@ -531,7 +539,8 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
volume_type_id=volume_type_id,
|
volume_type_id=volume_type_id,
|
||||||
consistencygroup_id=consistencygroup.id)['id']
|
consistencygroup_id=consistencygroup.id)['id']
|
||||||
|
|
||||||
self.assertEqual('available', consistencygroup.status)
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
|
consistencygroup.status)
|
||||||
|
|
||||||
cg_volumes = db.volume_get_all_by_group(self.ctxt.elevated(),
|
cg_volumes = db.volume_get_all_by_group(self.ctxt.elevated(),
|
||||||
consistencygroup.id)
|
consistencygroup.id)
|
||||||
@ -564,13 +573,15 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
self.ctxt, consistencygroup.id)
|
self.ctxt, consistencygroup.id)
|
||||||
self.assertEqual(202, res.status_int)
|
self.assertEqual(202, res.status_int)
|
||||||
self.assertTrue(mock_validate.called)
|
self.assertTrue(mock_validate.called)
|
||||||
self.assertEqual('updating', consistencygroup.status)
|
self.assertEqual(fields.ConsistencyGroupStatus.UPDATING,
|
||||||
|
consistencygroup.status)
|
||||||
|
|
||||||
consistencygroup.destroy()
|
consistencygroup.destroy()
|
||||||
|
|
||||||
def test_update_consistencygroup_add_volume_not_found(self):
|
def test_update_consistencygroup_add_volume_not_found(self):
|
||||||
consistencygroup = self._create_consistencygroup(ctxt=self.ctxt,
|
consistencygroup = self._create_consistencygroup(
|
||||||
status='available')
|
ctxt=self.ctxt,
|
||||||
|
status=fields.ConsistencyGroupStatus.AVAILABLE)
|
||||||
req = webob.Request.blank('/v2/fake/consistencygroups/%s/update' %
|
req = webob.Request.blank('/v2/fake/consistencygroups/%s/update' %
|
||||||
consistencygroup.id)
|
consistencygroup.id)
|
||||||
req.method = 'PUT'
|
req.method = 'PUT'
|
||||||
@ -594,8 +605,9 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
consistencygroup.destroy()
|
consistencygroup.destroy()
|
||||||
|
|
||||||
def test_update_consistencygroup_remove_volume_not_found(self):
|
def test_update_consistencygroup_remove_volume_not_found(self):
|
||||||
consistencygroup = self._create_consistencygroup(ctxt=self.ctxt,
|
consistencygroup = self._create_consistencygroup(
|
||||||
status='available')
|
ctxt=self.ctxt,
|
||||||
|
status=fields.ConsistencyGroupStatus.AVAILABLE)
|
||||||
req = webob.Request.blank('/v2/fake/consistencygroups/%s/update' %
|
req = webob.Request.blank('/v2/fake/consistencygroups/%s/update' %
|
||||||
consistencygroup.id)
|
consistencygroup.id)
|
||||||
req.method = 'PUT'
|
req.method = 'PUT'
|
||||||
@ -619,8 +631,9 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
consistencygroup.destroy()
|
consistencygroup.destroy()
|
||||||
|
|
||||||
def test_update_consistencygroup_empty_parameters(self):
|
def test_update_consistencygroup_empty_parameters(self):
|
||||||
consistencygroup = self._create_consistencygroup(ctxt=self.ctxt,
|
consistencygroup = self._create_consistencygroup(
|
||||||
status='available')
|
ctxt=self.ctxt,
|
||||||
|
status=fields.ConsistencyGroupStatus.AVAILABLE)
|
||||||
req = webob.Request.blank('/v2/fake/consistencygroups/%s/update' %
|
req = webob.Request.blank('/v2/fake/consistencygroups/%s/update' %
|
||||||
consistencygroup.id)
|
consistencygroup.id)
|
||||||
req.method = 'PUT'
|
req.method = 'PUT'
|
||||||
@ -640,8 +653,9 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
|
|
||||||
def test_update_consistencygroup_add_volume_invalid_state(self):
|
def test_update_consistencygroup_add_volume_invalid_state(self):
|
||||||
volume_type_id = '123456'
|
volume_type_id = '123456'
|
||||||
consistencygroup = self._create_consistencygroup(ctxt=self.ctxt,
|
consistencygroup = self._create_consistencygroup(
|
||||||
status='available')
|
ctxt=self.ctxt,
|
||||||
|
status=fields.ConsistencyGroupStatus.AVAILABLE)
|
||||||
add_volume_id = utils.create_volume(
|
add_volume_id = utils.create_volume(
|
||||||
self.ctxt,
|
self.ctxt,
|
||||||
volume_type_id=volume_type_id,
|
volume_type_id=volume_type_id,
|
||||||
@ -673,8 +687,9 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
consistencygroup.destroy()
|
consistencygroup.destroy()
|
||||||
|
|
||||||
def test_update_consistencygroup_add_volume_invalid_volume_type(self):
|
def test_update_consistencygroup_add_volume_invalid_volume_type(self):
|
||||||
consistencygroup = self._create_consistencygroup(ctxt=self.ctxt,
|
consistencygroup = self._create_consistencygroup(
|
||||||
status='available')
|
ctxt=self.ctxt,
|
||||||
|
status=fields.ConsistencyGroupStatus.AVAILABLE)
|
||||||
wrong_type = 'wrong-volume-type-id'
|
wrong_type = 'wrong-volume-type-id'
|
||||||
add_volume_id = utils.create_volume(
|
add_volume_id = utils.create_volume(
|
||||||
self.ctxt,
|
self.ctxt,
|
||||||
@ -705,8 +720,9 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
consistencygroup.destroy()
|
consistencygroup.destroy()
|
||||||
|
|
||||||
def test_update_consistencygroup_add_volume_already_in_cg(self):
|
def test_update_consistencygroup_add_volume_already_in_cg(self):
|
||||||
consistencygroup = self._create_consistencygroup(ctxt=self.ctxt,
|
consistencygroup = self._create_consistencygroup(
|
||||||
status='available')
|
ctxt=self.ctxt,
|
||||||
|
status=fields.ConsistencyGroupStatus.AVAILABLE)
|
||||||
add_volume_id = utils.create_volume(
|
add_volume_id = utils.create_volume(
|
||||||
self.ctxt,
|
self.ctxt,
|
||||||
consistencygroup_id='some_other_cg')['id']
|
consistencygroup_id='some_other_cg')['id']
|
||||||
@ -730,9 +746,9 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
consistencygroup.destroy()
|
consistencygroup.destroy()
|
||||||
|
|
||||||
def test_update_consistencygroup_invalid_state(self):
|
def test_update_consistencygroup_invalid_state(self):
|
||||||
wrong_status = 'wrong_status'
|
consistencygroup = self._create_consistencygroup(
|
||||||
consistencygroup = self._create_consistencygroup(status=wrong_status,
|
status=fields.ConsistencyGroupStatus.IN_USE,
|
||||||
ctxt=self.ctxt)
|
ctxt=self.ctxt)
|
||||||
req = webob.Request.blank('/v2/fake/consistencygroups/%s/update' %
|
req = webob.Request.blank('/v2/fake/consistencygroups/%s/update' %
|
||||||
consistencygroup.id)
|
consistencygroup.id)
|
||||||
req.method = 'PUT'
|
req.method = 'PUT'
|
||||||
@ -748,7 +764,8 @@ class ConsistencyGroupsAPITestCase(test.TestCase):
|
|||||||
self.assertEqual(400, res.status_int)
|
self.assertEqual(400, res.status_int)
|
||||||
self.assertEqual(400, res_dict['badRequest']['code'])
|
self.assertEqual(400, res_dict['badRequest']['code'])
|
||||||
msg = _("Invalid ConsistencyGroup: Consistency group status must be "
|
msg = _("Invalid ConsistencyGroup: Consistency group status must be "
|
||||||
"available, but current status is: %s.") % wrong_status
|
"available, but current status is: %s.") % (
|
||||||
|
fields.ConsistencyGroupStatus.IN_USE)
|
||||||
self.assertEqual(msg, res_dict['badRequest']['message'])
|
self.assertEqual(msg, res_dict['badRequest']['message'])
|
||||||
|
|
||||||
consistencygroup.destroy()
|
consistencygroup.destroy()
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
from oslo_utils import timeutils
|
from oslo_utils import timeutils
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder.tests.unit.brick import fake_lvm
|
from cinder.tests.unit.brick import fake_lvm
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume.drivers import lvm
|
from cinder.volume.drivers import lvm
|
||||||
@ -227,7 +228,8 @@ class FakeGateDriver(lvm.LVMVolumeDriver):
|
|||||||
# A consistencygroup entry is already created in db
|
# A consistencygroup entry is already created in db
|
||||||
# This driver just returns a status
|
# This driver just returns a status
|
||||||
now = timeutils.utcnow()
|
now = timeutils.utcnow()
|
||||||
model_update = {'status': 'available', 'updated_at': now}
|
model_update = {'status': fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
|
'updated_at': now}
|
||||||
|
|
||||||
return model_update
|
return model_update
|
||||||
|
|
||||||
@ -268,7 +270,7 @@ class FakeGateDriver(lvm.LVMVolumeDriver):
|
|||||||
volume_model_update['status'] = 'available'
|
volume_model_update['status'] = 'available'
|
||||||
except Exception:
|
except Exception:
|
||||||
volume_model_update['status'] = 'error'
|
volume_model_update['status'] = 'error'
|
||||||
model_update['status'] = 'error'
|
model_update['status'] = fields.ConsistencyGroupStatus.ERROR
|
||||||
volume_model_updates.append(volume_model_update)
|
volume_model_updates.append(volume_model_update)
|
||||||
|
|
||||||
return model_update, volume_model_updates
|
return model_update, volume_model_updates
|
||||||
|
@ -16,6 +16,7 @@ import mock
|
|||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import objects
|
from cinder import objects
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder.tests.unit import objects as test_objects
|
from cinder.tests.unit import objects as test_objects
|
||||||
|
|
||||||
fake_consistencygroup = {
|
fake_consistencygroup = {
|
||||||
@ -27,7 +28,7 @@ fake_consistencygroup = {
|
|||||||
'name': 'fake_name',
|
'name': 'fake_name',
|
||||||
'description': 'fake_description',
|
'description': 'fake_description',
|
||||||
'volume_type_id': 'fake_volume_type_id',
|
'volume_type_id': 'fake_volume_type_id',
|
||||||
'status': 'creating',
|
'status': fields.ConsistencyGroupStatus.CREATING,
|
||||||
'cgsnapshot_id': 'fake_id',
|
'cgsnapshot_id': 'fake_id',
|
||||||
'source_cgid': None,
|
'source_cgid': None,
|
||||||
}
|
}
|
||||||
@ -78,11 +79,12 @@ class TestConsistencyGroup(test_objects.BaseObjectsTestCase):
|
|||||||
def test_save(self, consistencygroup_update):
|
def test_save(self, consistencygroup_update):
|
||||||
consistencygroup = objects.ConsistencyGroup._from_db_object(
|
consistencygroup = objects.ConsistencyGroup._from_db_object(
|
||||||
self.context, objects.ConsistencyGroup(), fake_consistencygroup)
|
self.context, objects.ConsistencyGroup(), fake_consistencygroup)
|
||||||
consistencygroup.status = 'active'
|
consistencygroup.status = fields.ConsistencyGroupStatus.AVAILABLE
|
||||||
consistencygroup.save()
|
consistencygroup.save()
|
||||||
consistencygroup_update.assert_called_once_with(self.context,
|
consistencygroup_update.assert_called_once_with(
|
||||||
consistencygroup.id,
|
self.context,
|
||||||
{'status': 'active'})
|
consistencygroup.id,
|
||||||
|
{'status': fields.ConsistencyGroupStatus.AVAILABLE})
|
||||||
|
|
||||||
def test_save_with_cgsnapshots(self):
|
def test_save_with_cgsnapshots(self):
|
||||||
consistencygroup = objects.ConsistencyGroup._from_db_object(
|
consistencygroup = objects.ConsistencyGroup._from_db_object(
|
||||||
|
@ -82,3 +82,26 @@ class TestBackupStatus(TestField):
|
|||||||
|
|
||||||
def test_stringify_invalid(self):
|
def test_stringify_invalid(self):
|
||||||
self.assertRaises(ValueError, self.field.stringify, 'not_a_status')
|
self.assertRaises(ValueError, self.field.stringify, 'not_a_status')
|
||||||
|
|
||||||
|
|
||||||
|
class TestConsistencyGroupStatus(TestField):
|
||||||
|
def setUp(self):
|
||||||
|
super(TestConsistencyGroupStatus, self).setUp()
|
||||||
|
self.field = fields.ConsistencyGroupStatusField()
|
||||||
|
self.coerce_good_values = [('error', 'error'),
|
||||||
|
('available', 'available'),
|
||||||
|
('creating', 'creating'),
|
||||||
|
('deleting', 'deleting'),
|
||||||
|
('deleted', 'deleted'),
|
||||||
|
('updating', 'updating'),
|
||||||
|
('in-use', 'in-use'),
|
||||||
|
('error_deleting', 'error_deleting')]
|
||||||
|
self.coerce_bad_values = ['acme']
|
||||||
|
self.to_primitive_values = self.coerce_good_values[0:1]
|
||||||
|
self.from_primitive_values = self.coerce_good_values[0:1]
|
||||||
|
|
||||||
|
def test_stringify(self):
|
||||||
|
self.assertEqual("'error'", self.field.stringify('error'))
|
||||||
|
|
||||||
|
def test_stringify_invalid(self):
|
||||||
|
self.assertRaises(ValueError, self.field.stringify, 'not_a_status')
|
||||||
|
@ -26,7 +26,7 @@ object_data = {
|
|||||||
'BackupList': '1.0-24591dabe26d920ce0756fe64cd5f3aa',
|
'BackupList': '1.0-24591dabe26d920ce0756fe64cd5f3aa',
|
||||||
'CGSnapshot': '1.0-190da2a2aa9457edc771d888f7d225c4',
|
'CGSnapshot': '1.0-190da2a2aa9457edc771d888f7d225c4',
|
||||||
'CGSnapshotList': '1.0-e8c3f4078cd0ee23487b34d173eec776',
|
'CGSnapshotList': '1.0-e8c3f4078cd0ee23487b34d173eec776',
|
||||||
'ConsistencyGroup': '1.1-8d8b867a67c1bd6e9f840bcf5e375dbb',
|
'ConsistencyGroup': '1.2-ed7f90a6871991a19af716ade7337fc9',
|
||||||
'ConsistencyGroupList': '1.0-09d0aad5491e762ecfdf66bef02ceb8d',
|
'ConsistencyGroupList': '1.0-09d0aad5491e762ecfdf66bef02ceb8d',
|
||||||
'Service': '1.0-64baeb4911dbab1153064dd1c87edb9f',
|
'Service': '1.0-64baeb4911dbab1153064dd1c87edb9f',
|
||||||
'ServiceList': '1.0-d242d3384b68e5a5a534e090ff1d5161',
|
'ServiceList': '1.0-d242d3384b68e5a5a534e090ff1d5161',
|
||||||
|
@ -23,6 +23,7 @@ from oslo_config import cfg
|
|||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import db
|
from cinder import db
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder.scheduler import driver
|
from cinder.scheduler import driver
|
||||||
from cinder.scheduler import filter_scheduler
|
from cinder.scheduler import filter_scheduler
|
||||||
from cinder.scheduler import manager
|
from cinder.scheduler import manager
|
||||||
@ -279,7 +280,8 @@ class SchedulerManagerTestCase(test.TestCase):
|
|||||||
consistencygroup_obj)
|
consistencygroup_obj)
|
||||||
self.assertTrue(LOG.exception.call_count > 0)
|
self.assertTrue(LOG.exception.call_count > 0)
|
||||||
db.consistencygroup_update.assert_called_once_with(
|
db.consistencygroup_update.assert_called_once_with(
|
||||||
self.context, group_id, {'status': 'error'})
|
self.context, group_id, {'status': (
|
||||||
|
fields.ConsistencyGroupStatus.ERROR)})
|
||||||
|
|
||||||
mock_cg.reset_mock()
|
mock_cg.reset_mock()
|
||||||
LOG.exception.reset_mock()
|
LOG.exception.reset_mock()
|
||||||
@ -291,7 +293,8 @@ class SchedulerManagerTestCase(test.TestCase):
|
|||||||
self.context, 'volume', consistencygroup_obj)
|
self.context, 'volume', consistencygroup_obj)
|
||||||
self.assertTrue(LOG.error.call_count > 0)
|
self.assertTrue(LOG.error.call_count > 0)
|
||||||
db.consistencygroup_update.assert_called_once_with(
|
db.consistencygroup_update.assert_called_once_with(
|
||||||
self.context, group_id, {'status': 'error'})
|
self.context, group_id, {'status': (
|
||||||
|
fields.ConsistencyGroupStatus.ERROR)})
|
||||||
|
|
||||||
self.manager.driver = original_driver
|
self.manager.driver = original_driver
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ import uuid
|
|||||||
|
|
||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import test
|
from cinder import test
|
||||||
from cinder.volume.drivers.dell import dell_storagecenter_api
|
from cinder.volume.drivers.dell import dell_storagecenter_api
|
||||||
from cinder.volume.drivers.dell import dell_storagecenter_common
|
from cinder.volume.drivers.dell import dell_storagecenter_common
|
||||||
@ -1279,7 +1280,7 @@ class DellSCSanISCSIDriverTestCase(test.TestCase):
|
|||||||
self.driver.db.volume_get_all_by_group.return_value = expected_volumes
|
self.driver.db.volume_get_all_by_group.return_value = expected_volumes
|
||||||
context = {}
|
context = {}
|
||||||
group = {'id': 'fc8f2fec-fab2-4e34-9148-c094c913b9a3',
|
group = {'id': 'fc8f2fec-fab2-4e34-9148-c094c913b9a3',
|
||||||
'status': 'deleted'}
|
'status': fields.ConsistencyGroupStatus.DELETED}
|
||||||
model_update, volumes = self.driver.delete_consistencygroup(context,
|
model_update, volumes = self.driver.delete_consistencygroup(context,
|
||||||
group,
|
group,
|
||||||
[])
|
[])
|
||||||
@ -1309,7 +1310,7 @@ class DellSCSanISCSIDriverTestCase(test.TestCase):
|
|||||||
self.driver.db.volume_get_all_by_group.return_value = expected_volumes
|
self.driver.db.volume_get_all_by_group.return_value = expected_volumes
|
||||||
context = {}
|
context = {}
|
||||||
group = {'id': 'fc8f2fec-fab2-4e34-9148-c094c913b9a3',
|
group = {'id': 'fc8f2fec-fab2-4e34-9148-c094c913b9a3',
|
||||||
'status': 'deleted'}
|
'status': fields.ConsistencyGroupStatus.DELETED}
|
||||||
model_update, volumes = self.driver.delete_consistencygroup(context,
|
model_update, volumes = self.driver.delete_consistencygroup(context,
|
||||||
group,
|
group,
|
||||||
[])
|
[])
|
||||||
|
@ -26,6 +26,7 @@ import six
|
|||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import test
|
from cinder import test
|
||||||
from cinder.volume.drivers.emc import emc_vmax_common
|
from cinder.volume.drivers.emc import emc_vmax_common
|
||||||
from cinder.volume.drivers.emc import emc_vmax_fast
|
from cinder.volume.drivers.emc import emc_vmax_fast
|
||||||
@ -459,7 +460,7 @@ class EMCVMAXCommonData(object):
|
|||||||
test_CG = {'name': 'myCG1',
|
test_CG = {'name': 'myCG1',
|
||||||
'id': '12345abcde',
|
'id': '12345abcde',
|
||||||
'volume_type_id': 'abc',
|
'volume_type_id': 'abc',
|
||||||
'status': 'available'
|
'status': fields.ConsistencyGroupStatus.AVAILABLE
|
||||||
}
|
}
|
||||||
test_snapshot = {'name': 'myCG1',
|
test_snapshot = {'name': 'myCG1',
|
||||||
'id': '12345abcde',
|
'id': '12345abcde',
|
||||||
@ -3600,7 +3601,8 @@ class EMCVMAXISCSIDriverNoFastTestCase(test.TestCase):
|
|||||||
self.driver.create_consistencygroup_from_src(
|
self.driver.create_consistencygroup_from_src(
|
||||||
self.data.test_ctxt, self.data.test_CG, volumes,
|
self.data.test_ctxt, self.data.test_CG, volumes,
|
||||||
self.data.test_CG_snapshot, snapshots))
|
self.data.test_CG_snapshot, snapshots))
|
||||||
self.assertEqual({'status': 'available'}, model_update)
|
self.assertEqual({'status': fields.ConsistencyGroupStatus.AVAILABLE},
|
||||||
|
model_update)
|
||||||
self.assertEqual([{'status': 'available', 'id': '2'}],
|
self.assertEqual([{'status': 'available', 'id': '2'}],
|
||||||
volumes_model_update)
|
volumes_model_update)
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ import six
|
|||||||
|
|
||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import test
|
from cinder import test
|
||||||
from cinder.tests.unit import fake_consistencygroup
|
from cinder.tests.unit import fake_consistencygroup
|
||||||
from cinder.tests.unit import fake_snapshot
|
from cinder.tests.unit import fake_snapshot
|
||||||
@ -373,11 +374,11 @@ class EMCVNXCLIDriverTestData(object):
|
|||||||
|
|
||||||
test_cg = {'id': 'consistencygroup_id',
|
test_cg = {'id': 'consistencygroup_id',
|
||||||
'name': 'group_name',
|
'name': 'group_name',
|
||||||
'status': 'deleting'}
|
'status': fields.ConsistencyGroupStatus.DELETING}
|
||||||
|
|
||||||
test_cg_with_type = {'id': 'consistencygroup_id',
|
test_cg_with_type = {'id': 'consistencygroup_id',
|
||||||
'name': 'group_name',
|
'name': 'group_name',
|
||||||
'status': 'creating',
|
'status': fields.ConsistencyGroupStatus.CREATING,
|
||||||
'volume_type_id':
|
'volume_type_id':
|
||||||
'abc1-2320-9013-8813-8941-1374-8112-1231,'
|
'abc1-2320-9013-8813-8941-1374-8112-1231,'
|
||||||
'19fdd0dd-03b3-4d7c-b541-f4df46f308c8,'}
|
'19fdd0dd-03b3-4d7c-b541-f4df46f308c8,'}
|
||||||
@ -3952,7 +3953,8 @@ Time Remaining: 0 second(s)
|
|||||||
|
|
||||||
model_update = self.driver.create_consistencygroup(
|
model_update = self.driver.create_consistencygroup(
|
||||||
None, self.testData.test_cg)
|
None, self.testData.test_cg)
|
||||||
self.assertDictMatch({'status': 'available'}, model_update)
|
self.assertDictMatch({'status': (
|
||||||
|
fields.ConsistencyGroupStatus.AVAILABLE)}, model_update)
|
||||||
expect_cmd = [
|
expect_cmd = [
|
||||||
mock.call(
|
mock.call(
|
||||||
*self.testData.CREATE_CONSISTENCYGROUP_CMD(
|
*self.testData.CREATE_CONSISTENCYGROUP_CMD(
|
||||||
@ -3971,7 +3973,8 @@ Time Remaining: 0 second(s)
|
|||||||
fake_cli = self.driverSetup(commands, results)
|
fake_cli = self.driverSetup(commands, results)
|
||||||
model_update = self.driver.create_consistencygroup(
|
model_update = self.driver.create_consistencygroup(
|
||||||
None, self.testData.test_cg)
|
None, self.testData.test_cg)
|
||||||
self.assertDictMatch({'status': 'available'}, model_update)
|
self.assertDictMatch({'status': (
|
||||||
|
fields.ConsistencyGroupStatus.AVAILABLE)}, model_update)
|
||||||
expect_cmd = [
|
expect_cmd = [
|
||||||
mock.call(
|
mock.call(
|
||||||
*self.testData.CREATE_CONSISTENCYGROUP_CMD(
|
*self.testData.CREATE_CONSISTENCYGROUP_CMD(
|
||||||
@ -4211,7 +4214,8 @@ Time Remaining: 0 second(s)
|
|||||||
mock.call(*self.testData.REPLACE_LUNS_IN_CG_CMD(
|
mock.call(*self.testData.REPLACE_LUNS_IN_CG_CMD(
|
||||||
cg_name, ['4', '5']), poll=False)]
|
cg_name, ['4', '5']), poll=False)]
|
||||||
fake_cli.assert_has_calls(expect_cmd)
|
fake_cli.assert_has_calls(expect_cmd)
|
||||||
self.assertEqual('available', model_update['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
|
model_update['status'])
|
||||||
|
|
||||||
def test_update_consistencygroup_remove_all(self):
|
def test_update_consistencygroup_remove_all(self):
|
||||||
cg_name = self.testData.test_cg['id']
|
cg_name = self.testData.test_cg['id']
|
||||||
@ -4227,7 +4231,8 @@ Time Remaining: 0 second(s)
|
|||||||
mock.call(*self.testData.REMOVE_LUNS_FROM_CG_CMD(
|
mock.call(*self.testData.REMOVE_LUNS_FROM_CG_CMD(
|
||||||
cg_name, ['1', '3']), poll=False)]
|
cg_name, ['1', '3']), poll=False)]
|
||||||
fake_cli.assert_has_calls(expect_cmd)
|
fake_cli.assert_has_calls(expect_cmd)
|
||||||
self.assertEqual('available', model_update['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
|
model_update['status'])
|
||||||
|
|
||||||
def test_update_consistencygroup_remove_not_in_cg(self):
|
def test_update_consistencygroup_remove_not_in_cg(self):
|
||||||
cg_name = self.testData.test_cg['id']
|
cg_name = self.testData.test_cg['id']
|
||||||
@ -4244,7 +4249,8 @@ Time Remaining: 0 second(s)
|
|||||||
mock.call(*self.testData.REPLACE_LUNS_IN_CG_CMD(
|
mock.call(*self.testData.REPLACE_LUNS_IN_CG_CMD(
|
||||||
cg_name, ['1', '3']), poll=False)]
|
cg_name, ['1', '3']), poll=False)]
|
||||||
fake_cli.assert_has_calls(expect_cmd)
|
fake_cli.assert_has_calls(expect_cmd)
|
||||||
self.assertEqual('available', model_update['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
|
model_update['status'])
|
||||||
|
|
||||||
def test_update_consistencygroup_error(self):
|
def test_update_consistencygroup_error(self):
|
||||||
cg_name = self.testData.test_cg['id']
|
cg_name = self.testData.test_cg['id']
|
||||||
|
@ -23,6 +23,7 @@ from oslo_utils import units
|
|||||||
|
|
||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import test
|
from cinder import test
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
from cinder.volume import configuration as conf
|
from cinder.volume import configuration as conf
|
||||||
@ -1682,7 +1683,7 @@ class GPFSDriverTestCase(test.TestCase):
|
|||||||
def test_delete_consistencygroup(self, mock_exec):
|
def test_delete_consistencygroup(self, mock_exec):
|
||||||
ctxt = self.context
|
ctxt = self.context
|
||||||
group = self._fake_group()
|
group = self._fake_group()
|
||||||
group['status'] = 'available'
|
group['status'] = fields.ConsistencyGroupStatus.AVAILABLE
|
||||||
volume = self._fake_volume()
|
volume = self._fake_volume()
|
||||||
volume['status'] = 'available'
|
volume['status'] = 'available'
|
||||||
volumes = []
|
volumes = []
|
||||||
@ -1703,7 +1704,7 @@ class GPFSDriverTestCase(test.TestCase):
|
|||||||
def test_delete_consistencygroup_fail(self, mock_exec):
|
def test_delete_consistencygroup_fail(self, mock_exec):
|
||||||
ctxt = self.context
|
ctxt = self.context
|
||||||
group = self._fake_group()
|
group = self._fake_group()
|
||||||
group['status'] = 'available'
|
group['status'] = fields.ConsistencyGroupStatus.AVAILABLE
|
||||||
self.driver.db = mock.Mock()
|
self.driver.db = mock.Mock()
|
||||||
self.driver.db.volume_get_all_by_group = mock.Mock()
|
self.driver.db.volume_get_all_by_group = mock.Mock()
|
||||||
self.driver.db.volume_get_all_by_group.return_value = []
|
self.driver.db.volume_get_all_by_group.return_value = []
|
||||||
|
@ -23,6 +23,7 @@ from oslo_utils import units
|
|||||||
|
|
||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import test
|
from cinder import test
|
||||||
from cinder.tests.unit import fake_hpe_3par_client as hpe3parclient
|
from cinder.tests.unit import fake_hpe_3par_client as hpe3parclient
|
||||||
from cinder.volume.drivers.hpe import hpe_3par_common as hpecommon
|
from cinder.volume.drivers.hpe import hpe_3par_common as hpecommon
|
||||||
@ -3893,7 +3894,7 @@ class HPE3PARBaseDriver(object):
|
|||||||
mock_client.reset_mock()
|
mock_client.reset_mock()
|
||||||
|
|
||||||
# remove the consistency group
|
# remove the consistency group
|
||||||
group.status = 'deleting'
|
group.status = fields.ConsistencyGroupStatus.DELETING
|
||||||
self.driver.delete_consistencygroup(context.get_admin_context(),
|
self.driver.delete_consistencygroup(context.get_admin_context(),
|
||||||
group, [])
|
group, [])
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ from oslo_utils import units
|
|||||||
|
|
||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import test
|
from cinder import test
|
||||||
from cinder.tests.unit import fake_hpe_lefthand_client as hpelefthandclient
|
from cinder.tests.unit import fake_hpe_lefthand_client as hpelefthandclient
|
||||||
from cinder.volume.drivers.hpe import hpe_lefthand_iscsi
|
from cinder.volume.drivers.hpe import hpe_lefthand_iscsi
|
||||||
@ -1628,7 +1629,8 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
|
|||||||
group = self.fake_consistencygroup_object()
|
group = self.fake_consistencygroup_object()
|
||||||
cg = self.driver.create_consistencygroup(ctxt, group)
|
cg = self.driver.create_consistencygroup(ctxt, group)
|
||||||
|
|
||||||
self.assertEqual('available', cg['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
|
cg['status'])
|
||||||
|
|
||||||
def test_delete_consistencygroup(self):
|
def test_delete_consistencygroup(self):
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
@ -1645,13 +1647,15 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
|
|||||||
# create a consistency group
|
# create a consistency group
|
||||||
group = self.fake_consistencygroup_object()
|
group = self.fake_consistencygroup_object()
|
||||||
cg = self.driver.create_consistencygroup(ctxt, group)
|
cg = self.driver.create_consistencygroup(ctxt, group)
|
||||||
self.assertEqual('available', cg['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
|
cg['status'])
|
||||||
|
|
||||||
# delete the consistency group
|
# delete the consistency group
|
||||||
group.status = 'deleting'
|
group.status = fields.ConsistencyGroupStatus.DELETING
|
||||||
cg, vols = self.driver.delete_consistencygroup(ctxt, group,
|
cg, vols = self.driver.delete_consistencygroup(ctxt, group,
|
||||||
volumes)
|
volumes)
|
||||||
self.assertEqual('deleting', cg['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETING,
|
||||||
|
cg['status'])
|
||||||
|
|
||||||
def test_update_consistencygroup_add_vol_delete_cg(self):
|
def test_update_consistencygroup_add_vol_delete_cg(self):
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
@ -1675,17 +1679,19 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
|
|||||||
# create a consistency group
|
# create a consistency group
|
||||||
group = self.fake_consistencygroup_object()
|
group = self.fake_consistencygroup_object()
|
||||||
cg = self.driver.create_consistencygroup(ctxt, group)
|
cg = self.driver.create_consistencygroup(ctxt, group)
|
||||||
self.assertEqual('available', cg['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
|
cg['status'])
|
||||||
|
|
||||||
# add volume to consistency group
|
# add volume to consistency group
|
||||||
cg = self.driver.update_consistencygroup(
|
cg = self.driver.update_consistencygroup(
|
||||||
ctxt, group, add_volumes=[self.volume], remove_volumes=None)
|
ctxt, group, add_volumes=[self.volume], remove_volumes=None)
|
||||||
|
|
||||||
# delete the consistency group
|
# delete the consistency group
|
||||||
group.status = 'deleting'
|
group.status = fields.ConsistencyGroupStatus.DELETING
|
||||||
cg, vols = self.driver.delete_consistencygroup(ctxt, group,
|
cg, vols = self.driver.delete_consistencygroup(ctxt, group,
|
||||||
volumes)
|
volumes)
|
||||||
self.assertEqual('deleting', cg['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETING,
|
||||||
|
cg['status'])
|
||||||
|
|
||||||
def test_update_consistencygroup_remove_vol_delete_cg(self):
|
def test_update_consistencygroup_remove_vol_delete_cg(self):
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
@ -1709,7 +1715,8 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
|
|||||||
# create a consistency group
|
# create a consistency group
|
||||||
group = self.fake_consistencygroup_object()
|
group = self.fake_consistencygroup_object()
|
||||||
cg = self.driver.create_consistencygroup(ctxt, group)
|
cg = self.driver.create_consistencygroup(ctxt, group)
|
||||||
self.assertEqual('available', cg['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
|
cg['status'])
|
||||||
|
|
||||||
# add volume to consistency group
|
# add volume to consistency group
|
||||||
cg = self.driver.update_consistencygroup(
|
cg = self.driver.update_consistencygroup(
|
||||||
@ -1720,10 +1727,11 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
|
|||||||
ctxt, group, add_volumes=None, remove_volumes=[self.volume])
|
ctxt, group, add_volumes=None, remove_volumes=[self.volume])
|
||||||
|
|
||||||
# delete the consistency group
|
# delete the consistency group
|
||||||
group.status = 'deleting'
|
group.status = fields.ConsistencyGroupStatus.DELETING
|
||||||
cg, vols = self.driver.delete_consistencygroup(ctxt, group,
|
cg, vols = self.driver.delete_consistencygroup(ctxt, group,
|
||||||
volumes)
|
volumes)
|
||||||
self.assertEqual('deleting', cg['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETING,
|
||||||
|
cg['status'])
|
||||||
|
|
||||||
def test_create_cgsnapshot(self):
|
def test_create_cgsnapshot(self):
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
@ -1745,7 +1753,8 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
|
|||||||
# create a consistency group
|
# create a consistency group
|
||||||
group = self.fake_consistencygroup_object()
|
group = self.fake_consistencygroup_object()
|
||||||
cg = self.driver.create_consistencygroup(ctxt, group)
|
cg = self.driver.create_consistencygroup(ctxt, group)
|
||||||
self.assertEqual('available', cg['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
|
cg['status'])
|
||||||
|
|
||||||
# create volume and add it to the consistency group
|
# create volume and add it to the consistency group
|
||||||
self.driver.update_consistencygroup(
|
self.driver.update_consistencygroup(
|
||||||
@ -1777,7 +1786,8 @@ class TestHPELeftHandISCSIDriver(HPELeftHandBaseDriver, test.TestCase):
|
|||||||
# create a consistency group
|
# create a consistency group
|
||||||
group = self.fake_consistencygroup_object()
|
group = self.fake_consistencygroup_object()
|
||||||
cg = self.driver.create_consistencygroup(ctxt, group)
|
cg = self.driver.create_consistencygroup(ctxt, group)
|
||||||
self.assertEqual('available', cg['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
|
cg['status'])
|
||||||
|
|
||||||
# create volume and add it to the consistency group
|
# create volume and add it to the consistency group
|
||||||
self.driver.update_consistencygroup(
|
self.driver.update_consistencygroup(
|
||||||
|
@ -27,6 +27,7 @@ from oslo_config import cfg
|
|||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import test
|
from cinder import test
|
||||||
from cinder.volume import configuration as conf
|
from cinder.volume import configuration as conf
|
||||||
from cinder.volume.drivers.ibm import xiv_ds8k
|
from cinder.volume.drivers.ibm import xiv_ds8k
|
||||||
@ -204,7 +205,7 @@ class XIVDS8KFakeProxyDriver(object):
|
|||||||
raise exception.CinderException(
|
raise exception.CinderException(
|
||||||
message='The consistency group id of volume may be wrong.')
|
message='The consistency group id of volume may be wrong.')
|
||||||
|
|
||||||
return {'status': 'available'}
|
return {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
|
|
||||||
def delete_consistencygroup(self, ctxt, group, volumes):
|
def delete_consistencygroup(self, ctxt, group, volumes):
|
||||||
for volume in self.volumes.values():
|
for volume in self.volumes.values():
|
||||||
@ -233,7 +234,7 @@ class XIVDS8KFakeProxyDriver(object):
|
|||||||
self, context, group,
|
self, context, group,
|
||||||
add_volumes, remove_volumes):
|
add_volumes, remove_volumes):
|
||||||
|
|
||||||
model_update = {'status': 'available'}
|
model_update = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
return model_update, None, None
|
return model_update, None, None
|
||||||
|
|
||||||
def create_consistencygroup_from_src(
|
def create_consistencygroup_from_src(
|
||||||
@ -685,7 +686,7 @@ class XIVDS8KVolumeDriverTest(test.TestCase):
|
|||||||
# Create consistency group
|
# Create consistency group
|
||||||
model_update = self.driver.create_consistencygroup(ctxt, CONSISTGROUP)
|
model_update = self.driver.create_consistencygroup(ctxt, CONSISTGROUP)
|
||||||
|
|
||||||
self.assertEqual('available',
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
model_update['status'],
|
model_update['status'],
|
||||||
"Consistency Group created failed")
|
"Consistency Group created failed")
|
||||||
|
|
||||||
@ -723,7 +724,7 @@ class XIVDS8KVolumeDriverTest(test.TestCase):
|
|||||||
ctxt, CONSISTGROUP, [CG_VOLUME])
|
ctxt, CONSISTGROUP, [CG_VOLUME])
|
||||||
|
|
||||||
# Verify the result
|
# Verify the result
|
||||||
self.assertEqual('deleted',
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETED,
|
||||||
model_update['status'],
|
model_update['status'],
|
||||||
'Consistency Group deleted failed')
|
'Consistency Group deleted failed')
|
||||||
for volume in volumes:
|
for volume in volumes:
|
||||||
@ -872,7 +873,7 @@ class XIVDS8KVolumeDriverTest(test.TestCase):
|
|||||||
model_update, added, removed = self.driver.update_consistencygroup(
|
model_update, added, removed = self.driver.update_consistencygroup(
|
||||||
ctxt, CONSISTGROUP, [], [])
|
ctxt, CONSISTGROUP, [], [])
|
||||||
|
|
||||||
self.assertEqual('available',
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
model_update['status'],
|
model_update['status'],
|
||||||
"Consistency Group update failed")
|
"Consistency Group update failed")
|
||||||
self.assertFalse(added,
|
self.assertFalse(added,
|
||||||
@ -891,7 +892,7 @@ class XIVDS8KVolumeDriverTest(test.TestCase):
|
|||||||
model_update, added, removed = self.driver.update_consistencygroup(
|
model_update, added, removed = self.driver.update_consistencygroup(
|
||||||
ctxt, CONSISTGROUP, [VOLUME], [VOLUME2])
|
ctxt, CONSISTGROUP, [VOLUME], [VOLUME2])
|
||||||
|
|
||||||
self.assertEqual('available',
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
model_update['status'],
|
model_update['status'],
|
||||||
"Consistency Group update failed")
|
"Consistency Group update failed")
|
||||||
self.assertFalse(added,
|
self.assertFalse(added,
|
||||||
@ -913,7 +914,7 @@ class XIVDS8KVolumeDriverTest(test.TestCase):
|
|||||||
|
|
||||||
# model_update can be None or return available in status
|
# model_update can be None or return available in status
|
||||||
if model_update:
|
if model_update:
|
||||||
self.assertEqual('available',
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
model_update['status'],
|
model_update['status'],
|
||||||
"Consistency Group create from source failed")
|
"Consistency Group create from source failed")
|
||||||
# volumes_model_update can be None or return available in status
|
# volumes_model_update can be None or return available in status
|
||||||
@ -935,7 +936,7 @@ class XIVDS8KVolumeDriverTest(test.TestCase):
|
|||||||
|
|
||||||
# model_update can be None or return available in status
|
# model_update can be None or return available in status
|
||||||
if model_update:
|
if model_update:
|
||||||
self.assertEqual('available',
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
model_update['status'],
|
model_update['status'],
|
||||||
"Consistency Group create from source failed")
|
"Consistency Group create from source failed")
|
||||||
# volumes_model_update can be None or return available in status
|
# volumes_model_update can be None or return available in status
|
||||||
|
@ -21,6 +21,7 @@ from oslo_utils import units
|
|||||||
from six.moves import http_client
|
from six.moves import http_client
|
||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import test
|
from cinder import test
|
||||||
from cinder.tests.unit import fake_snapshot
|
from cinder.tests.unit import fake_snapshot
|
||||||
from cinder.volume import configuration as conf
|
from cinder.volume import configuration as conf
|
||||||
@ -683,7 +684,8 @@ class TestProphetStorDPLDriver(test.TestCase):
|
|||||||
self.DPL_MOCK.create_vg.assert_called_once_with(
|
self.DPL_MOCK.create_vg.assert_called_once_with(
|
||||||
self._conver_uuid2hex(DATA_IN_GROUP['id']), DATA_IN_GROUP['name'],
|
self._conver_uuid2hex(DATA_IN_GROUP['id']), DATA_IN_GROUP['name'],
|
||||||
DATA_IN_GROUP['description'])
|
DATA_IN_GROUP['description'])
|
||||||
self.assertDictMatch({'status': 'available'}, model_update)
|
self.assertDictMatch({'status': (
|
||||||
|
fields.ConsistencyGroupStatus.AVAILABLE)}, model_update)
|
||||||
|
|
||||||
def test_delete_consistency_group(self):
|
def test_delete_consistency_group(self):
|
||||||
self.DB_MOCK.volume_get_all_by_group.return_value = (
|
self.DB_MOCK.volume_get_all_by_group.return_value = (
|
||||||
@ -696,7 +698,8 @@ class TestProphetStorDPLDriver(test.TestCase):
|
|||||||
self._conver_uuid2hex(DATA_IN_GROUP['id']))
|
self._conver_uuid2hex(DATA_IN_GROUP['id']))
|
||||||
self.DPL_MOCK.delete_vdev.assert_called_once_with(
|
self.DPL_MOCK.delete_vdev.assert_called_once_with(
|
||||||
self._conver_uuid2hex((DATA_IN_VOLUME_VG['id'])))
|
self._conver_uuid2hex((DATA_IN_VOLUME_VG['id'])))
|
||||||
self.assertDictMatch({'status': 'deleted'}, model_update)
|
self.assertDictMatch({'status': (
|
||||||
|
fields.ConsistencyGroupStatus.DELETED)}, model_update)
|
||||||
|
|
||||||
def test_update_consistencygroup(self):
|
def test_update_consistencygroup(self):
|
||||||
self.DPL_MOCK.get_vg.return_value = (0, DATA_OUT_CG)
|
self.DPL_MOCK.get_vg.return_value = (0, DATA_OUT_CG)
|
||||||
@ -715,7 +718,8 @@ class TestProphetStorDPLDriver(test.TestCase):
|
|||||||
self.DPL_MOCK.leave_vg.assert_called_once_with(
|
self.DPL_MOCK.leave_vg.assert_called_once_with(
|
||||||
self._conver_uuid2hex(remove_vol['id']),
|
self._conver_uuid2hex(remove_vol['id']),
|
||||||
self._conver_uuid2hex(DATA_IN_GROUP['id']))
|
self._conver_uuid2hex(DATA_IN_GROUP['id']))
|
||||||
self.assertDictMatch({'status': 'available'}, model_update)
|
self.assertDictMatch({'status': (
|
||||||
|
fields.ConsistencyGroupStatus.AVAILABLE)}, model_update)
|
||||||
|
|
||||||
def test_update_consistencygroup_exception_join(self):
|
def test_update_consistencygroup_exception_join(self):
|
||||||
self.DPL_MOCK.get_vg.return_value = (0, DATA_OUT_CG)
|
self.DPL_MOCK.get_vg.return_value = (0, DATA_OUT_CG)
|
||||||
|
@ -22,6 +22,7 @@ from oslo_utils import units
|
|||||||
|
|
||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import test
|
from cinder import test
|
||||||
from cinder.volume import configuration as conf
|
from cinder.volume import configuration as conf
|
||||||
from cinder.volume.drivers import solidfire
|
from cinder.volume.drivers import solidfire
|
||||||
@ -1668,7 +1669,8 @@ class SolidFireVolumeTestCase(test.TestCase):
|
|||||||
cgsnapshot, snapshots,
|
cgsnapshot, snapshots,
|
||||||
source_cg, source_vols)
|
source_cg, source_vols)
|
||||||
get_snap.assert_called_with(name)
|
get_snap.assert_called_with(name)
|
||||||
self.assertEqual({'status': 'available'}, model)
|
self.assertEqual(
|
||||||
|
{'status': fields.ConsistencyGroupStatus.AVAILABLE}, model)
|
||||||
|
|
||||||
def test_create_consisgroup_from_src_source_cg(self):
|
def test_create_consisgroup_from_src_source_cg(self):
|
||||||
sfv = solidfire.SolidFireDriver(configuration=self.configuration)
|
sfv = solidfire.SolidFireDriver(configuration=self.configuration)
|
||||||
@ -1704,7 +1706,8 @@ class SolidFireVolumeTestCase(test.TestCase):
|
|||||||
source_cg,
|
source_cg,
|
||||||
source_vols)
|
source_vols)
|
||||||
get_snap.assert_called_with(source_cg['id'])
|
get_snap.assert_called_with(source_cg['id'])
|
||||||
self.assertEqual({'status': 'available'}, model)
|
self.assertEqual(
|
||||||
|
{'status': fields.ConsistencyGroupStatus.AVAILABLE}, model)
|
||||||
|
|
||||||
def test_create_cgsnapshot(self):
|
def test_create_cgsnapshot(self):
|
||||||
sfv = solidfire.SolidFireDriver(configuration=self.configuration)
|
sfv = solidfire.SolidFireDriver(configuration=self.configuration)
|
||||||
|
@ -31,6 +31,7 @@ import six
|
|||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _
|
from cinder.i18n import _
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import test
|
from cinder import test
|
||||||
from cinder.tests.unit import utils as testutils
|
from cinder.tests.unit import utils as testutils
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
@ -2650,7 +2651,7 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
|
|||||||
cg = self._create_consistencygroup_in_db(**kwargs)
|
cg = self._create_consistencygroup_in_db(**kwargs)
|
||||||
|
|
||||||
model_update = self.driver.create_consistencygroup(self.ctxt, cg)
|
model_update = self.driver.create_consistencygroup(self.ctxt, cg)
|
||||||
self.assertEqual('available',
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
model_update['status'],
|
model_update['status'],
|
||||||
"CG created failed")
|
"CG created failed")
|
||||||
return cg
|
return cg
|
||||||
@ -3806,7 +3807,7 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
|
|||||||
|
|
||||||
model_update = self.driver.create_consistencygroup(self.ctxt, cg)
|
model_update = self.driver.create_consistencygroup(self.ctxt, cg)
|
||||||
|
|
||||||
self.assertEqual('available',
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
model_update['status'],
|
model_update['status'],
|
||||||
"CG created failed")
|
"CG created failed")
|
||||||
# Add volumes to CG
|
# Add volumes to CG
|
||||||
@ -3829,7 +3830,8 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
|
|||||||
|
|
||||||
model_update = self.driver.delete_consistencygroup(self.ctxt, cg, [])
|
model_update = self.driver.delete_consistencygroup(self.ctxt, cg, [])
|
||||||
|
|
||||||
self.assertEqual('deleted', model_update[0]['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETED,
|
||||||
|
model_update[0]['status'])
|
||||||
for volume in model_update[1]:
|
for volume in model_update[1]:
|
||||||
self.assertEqual('deleted', volume['status'])
|
self.assertEqual('deleted', volume['status'])
|
||||||
|
|
||||||
@ -3890,21 +3892,24 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
|
|||||||
|
|
||||||
model_update = self.driver.delete_consistencygroup(self.ctxt, cg, [])
|
model_update = self.driver.delete_consistencygroup(self.ctxt, cg, [])
|
||||||
|
|
||||||
self.assertEqual('deleted', model_update[0]['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETED,
|
||||||
|
model_update[0]['status'])
|
||||||
for volume in model_update[1]:
|
for volume in model_update[1]:
|
||||||
self.assertEqual('deleted', volume['status'])
|
self.assertEqual('deleted', volume['status'])
|
||||||
|
|
||||||
model_update = (
|
model_update = (
|
||||||
self.driver.delete_consistencygroup(self.ctxt, source_cg, []))
|
self.driver.delete_consistencygroup(self.ctxt, source_cg, []))
|
||||||
|
|
||||||
self.assertEqual('deleted', model_update[0]['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETED,
|
||||||
|
model_update[0]['status'])
|
||||||
for volume in model_update[1]:
|
for volume in model_update[1]:
|
||||||
self.assertEqual('deleted', volume['status'])
|
self.assertEqual('deleted', volume['status'])
|
||||||
|
|
||||||
model_update = (
|
model_update = (
|
||||||
self.driver.delete_consistencygroup(self.ctxt, cgsnapshot, []))
|
self.driver.delete_consistencygroup(self.ctxt, cgsnapshot, []))
|
||||||
|
|
||||||
self.assertEqual('deleted', model_update[0]['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETED,
|
||||||
|
model_update[0]['status'])
|
||||||
for volume in model_update[1]:
|
for volume in model_update[1]:
|
||||||
self.assertEqual('deleted', volume['status'])
|
self.assertEqual('deleted', volume['status'])
|
||||||
|
|
||||||
@ -3945,7 +3950,7 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
|
|||||||
None, None,
|
None, None,
|
||||||
source_cg,
|
source_cg,
|
||||||
source_vols))
|
source_vols))
|
||||||
self.assertEqual('available',
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
model_update['status'],
|
model_update['status'],
|
||||||
"CG create from src created failed")
|
"CG create from src created failed")
|
||||||
|
|
||||||
@ -3955,7 +3960,8 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
|
|||||||
cg,
|
cg,
|
||||||
[])
|
[])
|
||||||
|
|
||||||
self.assertEqual('deleted', model_update[0]['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETED,
|
||||||
|
model_update[0]['status'])
|
||||||
for each_vol in model_update[1]:
|
for each_vol in model_update[1]:
|
||||||
self.assertEqual('deleted', each_vol['status'])
|
self.assertEqual('deleted', each_vol['status'])
|
||||||
|
|
||||||
@ -3967,7 +3973,7 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
|
|||||||
cgsnapshot,
|
cgsnapshot,
|
||||||
snapshots,
|
snapshots,
|
||||||
None, None))
|
None, None))
|
||||||
self.assertEqual('available',
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
model_update['status'],
|
model_update['status'],
|
||||||
"CG create from src created failed")
|
"CG create from src created failed")
|
||||||
|
|
||||||
@ -3977,7 +3983,8 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
|
|||||||
model_update = self.driver.delete_consistencygroup(self.ctxt,
|
model_update = self.driver.delete_consistencygroup(self.ctxt,
|
||||||
cg, [])
|
cg, [])
|
||||||
|
|
||||||
self.assertEqual('deleted', model_update[0]['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETED,
|
||||||
|
model_update[0]['status'])
|
||||||
for each_vol in model_update[1]:
|
for each_vol in model_update[1]:
|
||||||
self.assertEqual('deleted', each_vol['status'])
|
self.assertEqual('deleted', each_vol['status'])
|
||||||
|
|
||||||
@ -3985,7 +3992,8 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
|
|||||||
cgsnapshot,
|
cgsnapshot,
|
||||||
[])
|
[])
|
||||||
|
|
||||||
self.assertEqual('deleted', model_update[0]['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETED,
|
||||||
|
model_update[0]['status'])
|
||||||
for volume in model_update[1]:
|
for volume in model_update[1]:
|
||||||
self.assertEqual('deleted', volume['status'])
|
self.assertEqual('deleted', volume['status'])
|
||||||
|
|
||||||
@ -3993,7 +4001,8 @@ class StorwizeSVCCommonDriverTestCase(test.TestCase):
|
|||||||
source_cg,
|
source_cg,
|
||||||
[])
|
[])
|
||||||
|
|
||||||
self.assertEqual('deleted', model_update[0]['status'])
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETED,
|
||||||
|
model_update[0]['status'])
|
||||||
for each_vol in model_update[1]:
|
for each_vol in model_update[1]:
|
||||||
self.assertEqual('deleted', each_vol['status'])
|
self.assertEqual('deleted', each_vol['status'])
|
||||||
|
|
||||||
|
@ -4969,7 +4969,8 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
|||||||
@mock.patch.object(CGQUOTAS, "rollback")
|
@mock.patch.object(CGQUOTAS, "rollback")
|
||||||
@mock.patch.object(driver.VolumeDriver,
|
@mock.patch.object(driver.VolumeDriver,
|
||||||
"delete_consistencygroup",
|
"delete_consistencygroup",
|
||||||
return_value=({'status': 'deleted'}, []))
|
return_value=({'status': (
|
||||||
|
fields.ConsistencyGroupStatus.DELETED)}, []))
|
||||||
def test_create_delete_consistencygroup(self, fake_delete_cg,
|
def test_create_delete_consistencygroup(self, fake_delete_cg,
|
||||||
fake_rollback,
|
fake_rollback,
|
||||||
fake_commit, fake_reserve):
|
fake_commit, fake_reserve):
|
||||||
@ -5000,7 +5001,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
|||||||
msg = self.notifier.notifications[0]
|
msg = self.notifier.notifications[0]
|
||||||
self.assertEqual('consistencygroup.create.start', msg['event_type'])
|
self.assertEqual('consistencygroup.create.start', msg['event_type'])
|
||||||
expected = {
|
expected = {
|
||||||
'status': 'available',
|
'status': fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
'name': 'test_cg',
|
'name': 'test_cg',
|
||||||
'availability_zone': 'nova',
|
'availability_zone': 'nova',
|
||||||
'tenant_id': self.context.project_id,
|
'tenant_id': self.context.project_id,
|
||||||
@ -5020,7 +5021,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
|||||||
self.volume.delete_consistencygroup(self.context, group)
|
self.volume.delete_consistencygroup(self.context, group)
|
||||||
cg = objects.ConsistencyGroup.get_by_id(
|
cg = objects.ConsistencyGroup.get_by_id(
|
||||||
context.get_admin_context(read_deleted='yes'), group.id)
|
context.get_admin_context(read_deleted='yes'), group.id)
|
||||||
self.assertEqual('deleted', cg.status)
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETED, cg.status)
|
||||||
self.assertEqual(4, len(self.notifier.notifications),
|
self.assertEqual(4, len(self.notifier.notifications),
|
||||||
self.notifier.notifications)
|
self.notifier.notifications)
|
||||||
msg = self.notifier.notifications[2]
|
msg = self.notifier.notifications[2]
|
||||||
@ -5028,7 +5029,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
|||||||
self.assertDictMatch(expected, msg['payload'])
|
self.assertDictMatch(expected, msg['payload'])
|
||||||
msg = self.notifier.notifications[3]
|
msg = self.notifier.notifications[3]
|
||||||
self.assertEqual('consistencygroup.delete.end', msg['event_type'])
|
self.assertEqual('consistencygroup.delete.end', msg['event_type'])
|
||||||
expected['status'] = 'deleted'
|
expected['status'] = fields.ConsistencyGroupStatus.DELETED
|
||||||
self.assertDictMatch(expected, msg['payload'])
|
self.assertDictMatch(expected, msg['payload'])
|
||||||
self.assertRaises(exception.NotFound,
|
self.assertRaises(exception.NotFound,
|
||||||
objects.ConsistencyGroup.get_by_id,
|
objects.ConsistencyGroup.get_by_id,
|
||||||
@ -5069,7 +5070,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
|||||||
self.volume.create_volume(self.context, volume_id2)
|
self.volume.create_volume(self.context, volume_id2)
|
||||||
|
|
||||||
fake_update_cg.return_value = (
|
fake_update_cg.return_value = (
|
||||||
{'status': 'available'},
|
{'status': fields.ConsistencyGroupStatus.AVAILABLE},
|
||||||
[{'id': volume_id2, 'status': 'available'}],
|
[{'id': volume_id2, 'status': 'available'}],
|
||||||
[{'id': volume_id, 'status': 'available'}])
|
[{'id': volume_id, 'status': 'available'}])
|
||||||
|
|
||||||
@ -5078,7 +5079,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
|||||||
remove_volumes=volume_id)
|
remove_volumes=volume_id)
|
||||||
cg = objects.ConsistencyGroup.get_by_id(self.context, group.id)
|
cg = objects.ConsistencyGroup.get_by_id(self.context, group.id)
|
||||||
expected = {
|
expected = {
|
||||||
'status': 'available',
|
'status': fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
'name': 'test_cg',
|
'name': 'test_cg',
|
||||||
'availability_zone': 'nova',
|
'availability_zone': 'nova',
|
||||||
'tenant_id': self.context.project_id,
|
'tenant_id': self.context.project_id,
|
||||||
@ -5086,7 +5087,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
|||||||
'user_id': 'fake',
|
'user_id': 'fake',
|
||||||
'consistencygroup_id': group.id
|
'consistencygroup_id': group.id
|
||||||
}
|
}
|
||||||
self.assertEqual('available', cg.status)
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE, cg.status)
|
||||||
self.assertEqual(10, len(self.notifier.notifications),
|
self.assertEqual(10, len(self.notifier.notifications),
|
||||||
self.notifier.notifications)
|
self.notifier.notifications)
|
||||||
msg = self.notifier.notifications[6]
|
msg = self.notifier.notifications[6]
|
||||||
@ -5155,7 +5156,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
|||||||
self.context,
|
self.context,
|
||||||
availability_zone=CONF.storage_availability_zone,
|
availability_zone=CONF.storage_availability_zone,
|
||||||
volume_type='type1,type2',
|
volume_type='type1,type2',
|
||||||
status='available')
|
status=fields.ConsistencyGroupStatus.AVAILABLE)
|
||||||
volume = tests_utils.create_volume(
|
volume = tests_utils.create_volume(
|
||||||
self.context,
|
self.context,
|
||||||
consistencygroup_id=group.id,
|
consistencygroup_id=group.id,
|
||||||
@ -5184,7 +5185,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
|||||||
self.context, group2, cgsnapshot=cgsnapshot)
|
self.context, group2, cgsnapshot=cgsnapshot)
|
||||||
cg2 = objects.ConsistencyGroup.get_by_id(self.context, group2.id)
|
cg2 = objects.ConsistencyGroup.get_by_id(self.context, group2.id)
|
||||||
expected = {
|
expected = {
|
||||||
'status': 'available',
|
'status': fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
'name': 'test_cg',
|
'name': 'test_cg',
|
||||||
'availability_zone': 'nova',
|
'availability_zone': 'nova',
|
||||||
'tenant_id': self.context.project_id,
|
'tenant_id': self.context.project_id,
|
||||||
@ -5192,7 +5193,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
|||||||
'user_id': 'fake',
|
'user_id': 'fake',
|
||||||
'consistencygroup_id': group2.id,
|
'consistencygroup_id': group2.id,
|
||||||
}
|
}
|
||||||
self.assertEqual('available', cg2.status)
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE, cg2.status)
|
||||||
self.assertEqual(group2.id, cg2['id'])
|
self.assertEqual(group2.id, cg2['id'])
|
||||||
self.assertEqual(cgsnapshot.id, cg2['cgsnapshot_id'])
|
self.assertEqual(cgsnapshot.id, cg2['cgsnapshot_id'])
|
||||||
self.assertIsNone(cg2['source_cgid'])
|
self.assertIsNone(cg2['source_cgid'])
|
||||||
@ -5220,16 +5221,16 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
|||||||
|
|
||||||
msg = self.notifier.notifications[6]
|
msg = self.notifier.notifications[6]
|
||||||
self.assertEqual('consistencygroup.delete.start', msg['event_type'])
|
self.assertEqual('consistencygroup.delete.start', msg['event_type'])
|
||||||
expected['status'] = 'available'
|
expected['status'] = fields.ConsistencyGroupStatus.AVAILABLE
|
||||||
self.assertDictMatch(expected, msg['payload'])
|
self.assertDictMatch(expected, msg['payload'])
|
||||||
msg = self.notifier.notifications[8]
|
msg = self.notifier.notifications[8]
|
||||||
self.assertEqual('consistencygroup.delete.end', msg['event_type'])
|
self.assertEqual('consistencygroup.delete.end', msg['event_type'])
|
||||||
expected['status'] = 'deleted'
|
expected['status'] = fields.ConsistencyGroupStatus.DELETED
|
||||||
self.assertDictMatch(expected, msg['payload'])
|
self.assertDictMatch(expected, msg['payload'])
|
||||||
|
|
||||||
cg2 = objects.ConsistencyGroup.get_by_id(
|
cg2 = objects.ConsistencyGroup.get_by_id(
|
||||||
context.get_admin_context(read_deleted='yes'), group2.id)
|
context.get_admin_context(read_deleted='yes'), group2.id)
|
||||||
self.assertEqual('deleted', cg2.status)
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETED, cg2.status)
|
||||||
self.assertRaises(exception.NotFound,
|
self.assertRaises(exception.NotFound,
|
||||||
objects.ConsistencyGroup.get_by_id,
|
objects.ConsistencyGroup.get_by_id,
|
||||||
self.context,
|
self.context,
|
||||||
@ -5252,7 +5253,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
|||||||
|
|
||||||
cg3 = objects.ConsistencyGroup.get_by_id(self.context, group3.id)
|
cg3 = objects.ConsistencyGroup.get_by_id(self.context, group3.id)
|
||||||
|
|
||||||
self.assertEqual('available', cg3.status)
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE, cg3.status)
|
||||||
self.assertEqual(group3.id, cg3.id)
|
self.assertEqual(group3.id, cg3.id)
|
||||||
self.assertEqual(group.id, cg3.source_cgid)
|
self.assertEqual(group.id, cg3.source_cgid)
|
||||||
self.assertIsNone(cg3.cgsnapshot_id)
|
self.assertIsNone(cg3.cgsnapshot_id)
|
||||||
@ -5509,7 +5510,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
|||||||
cg = objects.ConsistencyGroup.get_by_id(
|
cg = objects.ConsistencyGroup.get_by_id(
|
||||||
context.get_admin_context(read_deleted='yes'),
|
context.get_admin_context(read_deleted='yes'),
|
||||||
group.id)
|
group.id)
|
||||||
self.assertEqual('deleted', cg.status)
|
self.assertEqual(fields.ConsistencyGroupStatus.DELETED, cg.status)
|
||||||
self.assertRaises(exception.NotFound,
|
self.assertRaises(exception.NotFound,
|
||||||
objects.ConsistencyGroup.get_by_id,
|
objects.ConsistencyGroup.get_by_id,
|
||||||
self.context,
|
self.context,
|
||||||
@ -5546,7 +5547,7 @@ class ConsistencyGroupTestCase(BaseVolumeTestCase):
|
|||||||
group)
|
group)
|
||||||
cg = objects.ConsistencyGroup.get_by_id(self.context, group.id)
|
cg = objects.ConsistencyGroup.get_by_id(self.context, group.id)
|
||||||
# Group is not deleted
|
# Group is not deleted
|
||||||
self.assertEqual('available', cg.status)
|
self.assertEqual(fields.ConsistencyGroupStatus.AVAILABLE, cg.status)
|
||||||
|
|
||||||
def test_create_volume_with_consistencygroup_invalid_type(self):
|
def test_create_volume_with_consistencygroup_invalid_type(self):
|
||||||
"""Test volume creation with ConsistencyGroup & invalid volume type."""
|
"""Test volume creation with ConsistencyGroup & invalid volume type."""
|
||||||
|
@ -118,7 +118,7 @@ def create_consistencygroup(ctxt,
|
|||||||
host='test_host@fakedrv#fakepool',
|
host='test_host@fakedrv#fakepool',
|
||||||
name='test_cg',
|
name='test_cg',
|
||||||
description='this is a test cg',
|
description='this is a test cg',
|
||||||
status='available',
|
status=fields.ConsistencyGroupStatus.AVAILABLE,
|
||||||
availability_zone='fake_az',
|
availability_zone='fake_az',
|
||||||
volume_type_id=None,
|
volume_type_id=None,
|
||||||
cgsnapshot_id=None,
|
cgsnapshot_id=None,
|
||||||
|
@ -23,6 +23,7 @@ import six
|
|||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _, _LE, _LI, _LW
|
from cinder.i18n import _, _LE, _LI, _LW
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder.volume.drivers.emc import emc_vmax_fast
|
from cinder.volume.drivers.emc import emc_vmax_fast
|
||||||
from cinder.volume.drivers.emc import emc_vmax_https
|
from cinder.volume.drivers.emc import emc_vmax_https
|
||||||
from cinder.volume.drivers.emc import emc_vmax_masking
|
from cinder.volume.drivers.emc import emc_vmax_masking
|
||||||
@ -2362,7 +2363,7 @@ class EMCVMAXCommon(object):
|
|||||||
LOG.info(_LI("Create Consistency Group: %(group)s."),
|
LOG.info(_LI("Create Consistency Group: %(group)s."),
|
||||||
{'group': group['id']})
|
{'group': group['id']})
|
||||||
|
|
||||||
modelUpdate = {'status': 'available'}
|
modelUpdate = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
volumeTypeId = group['volume_type_id'].replace(",", "")
|
volumeTypeId = group['volume_type_id'].replace(",", "")
|
||||||
|
|
||||||
cgName = self.utils.truncate_string(group['id'], 8)
|
cgName = self.utils.truncate_string(group['id'], 8)
|
||||||
@ -4128,7 +4129,7 @@ class EMCVMAXCommon(object):
|
|||||||
"This adds and/or removes volumes from a CG."),
|
"This adds and/or removes volumes from a CG."),
|
||||||
{'group': group['id']})
|
{'group': group['id']})
|
||||||
|
|
||||||
modelUpdate = {'status': 'available'}
|
modelUpdate = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
volumeTypeId = group['volume_type_id'].replace(",", "")
|
volumeTypeId = group['volume_type_id'].replace(",", "")
|
||||||
|
|
||||||
cg_name = self.utils.truncate_string(group['id'], 8)
|
cg_name = self.utils.truncate_string(group['id'], 8)
|
||||||
@ -4226,7 +4227,7 @@ class EMCVMAXCommon(object):
|
|||||||
raise exception.VolumeBackendAPIException(
|
raise exception.VolumeBackendAPIException(
|
||||||
data=exceptionMessage)
|
data=exceptionMessage)
|
||||||
|
|
||||||
modelUpdate = {'status': 'available'}
|
modelUpdate = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
|
|
||||||
_poolInstanceName, storageSystem = (
|
_poolInstanceName, storageSystem = (
|
||||||
self._get_pool_and_storage_system(extraSpecs))
|
self._get_pool_and_storage_system(extraSpecs))
|
||||||
|
@ -40,6 +40,7 @@ from taskflow.types import failure
|
|||||||
|
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _, _LE, _LI, _LW
|
from cinder.i18n import _, _LE, _LI, _LW
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
from cinder.volume import configuration as config
|
from cinder.volume import configuration as config
|
||||||
from cinder.volume.drivers.san import san
|
from cinder.volume.drivers.san import san
|
||||||
@ -3055,7 +3056,7 @@ class EMCVnxCliBase(object):
|
|||||||
|
|
||||||
self._consistencygroup_creation_check(group)
|
self._consistencygroup_creation_check(group)
|
||||||
|
|
||||||
model_update = {'status': 'available'}
|
model_update = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
try:
|
try:
|
||||||
self._client.create_consistencygroup(group['id'])
|
self._client.create_consistencygroup(group['id'])
|
||||||
except Exception:
|
except Exception:
|
||||||
@ -3096,7 +3097,7 @@ class EMCVnxCliBase(object):
|
|||||||
add_volumes,
|
add_volumes,
|
||||||
remove_volumes):
|
remove_volumes):
|
||||||
"""Adds or removes LUN(s) to/from an existing consistency group"""
|
"""Adds or removes LUN(s) to/from an existing consistency group"""
|
||||||
model_update = {'status': 'available'}
|
model_update = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
cg_name = group['id']
|
cg_name = group['id']
|
||||||
add_ids = [six.text_type(self.get_lun_id(vol))
|
add_ids = [six.text_type(self.get_lun_id(vol))
|
||||||
for vol in add_volumes] if add_volumes else []
|
for vol in add_volumes] if add_volumes else []
|
||||||
|
@ -42,6 +42,7 @@ from cinder import context
|
|||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _, _LE, _LI, _LW
|
from cinder.i18n import _, _LE, _LI, _LW
|
||||||
from cinder import objects
|
from cinder import objects
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume.drivers.san import san
|
from cinder.volume.drivers.san import san
|
||||||
@ -599,7 +600,7 @@ class XtremIOVolumeDriver(san.SanDriver):
|
|||||||
create_data = {'consistency-group-name': group['id']}
|
create_data = {'consistency-group-name': group['id']}
|
||||||
self.client.req('consistency-groups', 'POST', data=create_data,
|
self.client.req('consistency-groups', 'POST', data=create_data,
|
||||||
ver='v2')
|
ver='v2')
|
||||||
return {'status': 'available'}
|
return {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
|
|
||||||
def delete_consistencygroup(self, context, group, volumes):
|
def delete_consistencygroup(self, context, group, volumes):
|
||||||
"""Deletes a consistency group."""
|
"""Deletes a consistency group."""
|
||||||
|
@ -61,6 +61,7 @@ from cinder import context
|
|||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder import flow_utils
|
from cinder import flow_utils
|
||||||
from cinder.i18n import _, _LE, _LI, _LW
|
from cinder.i18n import _, _LE, _LI, _LW
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder.volume import qos_specs
|
from cinder.volume import qos_specs
|
||||||
from cinder.volume import utils as volume_utils
|
from cinder.volume import utils as volume_utils
|
||||||
from cinder.volume import volume_types
|
from cinder.volume import volume_types
|
||||||
@ -519,7 +520,7 @@ class HPE3PARCommon(object):
|
|||||||
self.client.createVolumeSet(cg_name, domain=domain,
|
self.client.createVolumeSet(cg_name, domain=domain,
|
||||||
comment=six.text_type(extra))
|
comment=six.text_type(extra))
|
||||||
|
|
||||||
model_update = {'status': 'available'}
|
model_update = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
return model_update
|
return model_update
|
||||||
|
|
||||||
def create_consistencygroup_from_src(self, context, group, volumes,
|
def create_consistencygroup_from_src(self, context, group, volumes,
|
||||||
|
@ -43,6 +43,7 @@ from oslo_utils import units
|
|||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _, _LE, _LI, _LW
|
from cinder.i18n import _, _LE, _LI, _LW
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume import utils
|
from cinder.volume import utils
|
||||||
from cinder.volume import volume_types
|
from cinder.volume import volume_types
|
||||||
@ -291,7 +292,7 @@ class HPELeftHandISCSIDriver(driver.ISCSIDriver):
|
|||||||
|
|
||||||
def create_consistencygroup(self, context, group):
|
def create_consistencygroup(self, context, group):
|
||||||
"""Creates a consistencygroup."""
|
"""Creates a consistencygroup."""
|
||||||
model_update = {'status': 'available'}
|
model_update = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
return model_update
|
return model_update
|
||||||
|
|
||||||
def create_consistencygroup_from_src(self, context, group, volumes,
|
def create_consistencygroup_from_src(self, context, group, volumes,
|
||||||
|
@ -31,6 +31,7 @@ from cinder import context
|
|||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _, _LE, _LI
|
from cinder.i18n import _, _LE, _LI
|
||||||
from cinder.image import image_utils
|
from cinder.image import image_utils
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume.drivers import nfs
|
from cinder.volume.drivers import nfs
|
||||||
@ -1162,7 +1163,7 @@ class GPFSDriver(driver.ConsistencyGroupVD, driver.ExtendVD,
|
|||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
raise exception.VolumeBackendAPIException(data=msg)
|
raise exception.VolumeBackendAPIException(data=msg)
|
||||||
|
|
||||||
model_update = {'status': 'available'}
|
model_update = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
return model_update
|
return model_update
|
||||||
|
|
||||||
def delete_consistencygroup(self, context, group, volumes):
|
def delete_consistencygroup(self, context, group, volumes):
|
||||||
|
@ -33,6 +33,7 @@ import six
|
|||||||
from cinder import context
|
from cinder import context
|
||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _, _LE, _LI, _LW
|
from cinder.i18n import _, _LE, _LI, _LW
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume.drivers.ibm.storwize_svc import (
|
from cinder.volume.drivers.ibm.storwize_svc import (
|
||||||
replication as storwize_rep)
|
replication as storwize_rep)
|
||||||
@ -1216,7 +1217,7 @@ class StorwizeHelpers(object):
|
|||||||
LOG.debug('Enter: create_cg_from_source: cg %(cg)s'
|
LOG.debug('Enter: create_cg_from_source: cg %(cg)s'
|
||||||
' source %(source)s, target %(target)s',
|
' source %(source)s, target %(target)s',
|
||||||
{'cg': fc_consistgrp, 'source': sources, 'target': targets})
|
{'cg': fc_consistgrp, 'source': sources, 'target': targets})
|
||||||
model_update = {'status': 'available'}
|
model_update = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
ctxt = context.get_admin_context()
|
ctxt = context.get_admin_context()
|
||||||
try:
|
try:
|
||||||
for source, target in zip(sources, targets):
|
for source, target in zip(sources, targets):
|
||||||
@ -1233,7 +1234,7 @@ class StorwizeHelpers(object):
|
|||||||
volumes_model_update = self._get_volume_model_updates(
|
volumes_model_update = self._get_volume_model_updates(
|
||||||
ctxt, targets, group['id'], model_update['status'])
|
ctxt, targets, group['id'], model_update['status'])
|
||||||
except exception.VolumeBackendAPIException as err:
|
except exception.VolumeBackendAPIException as err:
|
||||||
model_update['status'] = 'error'
|
model_update['status'] = fields.ConsistencyGroupStatus.ERROR
|
||||||
volumes_model_update = self._get_volume_model_updates(
|
volumes_model_update = self._get_volume_model_updates(
|
||||||
ctxt, targets, group['id'], model_update['status'])
|
ctxt, targets, group['id'], model_update['status'])
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
@ -2325,7 +2326,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
|
|||||||
db will maintain the volumes and CG relationship.
|
db will maintain the volumes and CG relationship.
|
||||||
"""
|
"""
|
||||||
LOG.debug("Creating consistency group.")
|
LOG.debug("Creating consistency group.")
|
||||||
model_update = {'status': 'available'}
|
model_update = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
return model_update
|
return model_update
|
||||||
|
|
||||||
def delete_consistencygroup(self, context, group, volumes):
|
def delete_consistencygroup(self, context, group, volumes):
|
||||||
@ -2335,7 +2336,7 @@ class StorwizeSVCCommonDriver(san.SanDriver,
|
|||||||
"""
|
"""
|
||||||
LOG.debug("Deleting consistency group.")
|
LOG.debug("Deleting consistency group.")
|
||||||
model_update = {}
|
model_update = {}
|
||||||
model_update['status'] = 'deleted'
|
model_update['status'] = fields.ConsistencyGroupStatus.DELETED
|
||||||
volumes = self.db.volume_get_all_by_group(context, group['id'])
|
volumes = self.db.volume_get_all_by_group(context, group['id'])
|
||||||
|
|
||||||
for volume in volumes:
|
for volume in volumes:
|
||||||
|
@ -35,6 +35,7 @@ from six.moves import http_client
|
|||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _, _LI, _LW, _LE
|
from cinder.i18n import _, _LI, _LW, _LE
|
||||||
from cinder import objects
|
from cinder import objects
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume.drivers.prophetstor import options
|
from cinder.volume.drivers.prophetstor import options
|
||||||
from cinder.volume.drivers.san import san
|
from cinder.volume.drivers.san import san
|
||||||
@ -868,7 +869,7 @@ class DPLCOMMONDriver(driver.ConsistencyGroupVD, driver.ExtendVD,
|
|||||||
LOG.info(_LI('Start to create consistency group: %(group_name)s '
|
LOG.info(_LI('Start to create consistency group: %(group_name)s '
|
||||||
'id: %(id)s'),
|
'id: %(id)s'),
|
||||||
{'group_name': group['name'], 'id': group['id']})
|
{'group_name': group['name'], 'id': group['id']})
|
||||||
model_update = {'status': 'available'}
|
model_update = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
try:
|
try:
|
||||||
ret, output = self.dpl.create_vg(
|
ret, output = self.dpl.create_vg(
|
||||||
self._conver_uuid2hex(group['id']),
|
self._conver_uuid2hex(group['id']),
|
||||||
@ -911,9 +912,10 @@ class DPLCOMMONDriver(driver.ConsistencyGroupVD, driver.ExtendVD,
|
|||||||
except Exception:
|
except Exception:
|
||||||
ret = errno.EFAULT
|
ret = errno.EFAULT
|
||||||
volume_ref['status'] = 'error_deleting'
|
volume_ref['status'] = 'error_deleting'
|
||||||
model_update['status'] = 'error_deleting'
|
model_update['status'] = (
|
||||||
|
fields.ConsistencyGroupStatus.ERROR_DELETING)
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
model_update['status'] = 'deleted'
|
model_update['status'] = fields.ConsistencyGroupStatus.DELETED
|
||||||
return model_update, volumes
|
return model_update, volumes
|
||||||
|
|
||||||
def create_cgsnapshot(self, context, cgsnapshot, snapshots):
|
def create_cgsnapshot(self, context, cgsnapshot, snapshots):
|
||||||
@ -974,7 +976,7 @@ class DPLCOMMONDriver(driver.ConsistencyGroupVD, driver.ExtendVD,
|
|||||||
removevollist = []
|
removevollist = []
|
||||||
cgid = group['id']
|
cgid = group['id']
|
||||||
vid = ''
|
vid = ''
|
||||||
model_update = {'status': 'available'}
|
model_update = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
# Get current group info in backend storage.
|
# Get current group info in backend storage.
|
||||||
ret, output = self.dpl.get_vg(self._conver_uuid2hex(cgid))
|
ret, output = self.dpl.get_vg(self._conver_uuid2hex(cgid))
|
||||||
if ret == 0:
|
if ret == 0:
|
||||||
|
@ -31,6 +31,7 @@ from cinder import context
|
|||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _, _LE, _LI, _LW
|
from cinder.i18n import _, _LE, _LI, _LW
|
||||||
from cinder import objects
|
from cinder import objects
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
from cinder.volume import driver
|
from cinder.volume import driver
|
||||||
from cinder.volume.drivers.san import san
|
from cinder.volume.drivers.san import san
|
||||||
@ -408,7 +409,7 @@ class PureBaseVolumeDriver(san.SanDriver):
|
|||||||
|
|
||||||
self._array.create_pgroup(self._get_pgroup_name_from_id(group.id))
|
self._array.create_pgroup(self._get_pgroup_name_from_id(group.id))
|
||||||
|
|
||||||
model_update = {'status': 'available'}
|
model_update = {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
return model_update
|
return model_update
|
||||||
|
|
||||||
def _create_cg_from_cgsnap(self, volumes, snapshots):
|
def _create_cg_from_cgsnap(self, volumes, snapshots):
|
||||||
|
@ -34,6 +34,7 @@ from cinder import context
|
|||||||
from cinder import exception
|
from cinder import exception
|
||||||
from cinder.i18n import _, _LE, _LW
|
from cinder.i18n import _, _LE, _LW
|
||||||
from cinder.image import image_utils
|
from cinder.image import image_utils
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder.volume.drivers.san import san
|
from cinder.volume.drivers.san import san
|
||||||
from cinder.volume import qos_specs
|
from cinder.volume import qos_specs
|
||||||
from cinder.volume.targets import iscsi as iscsi_driver
|
from cinder.volume.targets import iscsi as iscsi_driver
|
||||||
@ -1277,7 +1278,7 @@ class SolidFireDriver(san.SanISCSIDriver):
|
|||||||
# volume associations. So, we're just going to play along with the
|
# volume associations. So, we're just going to play along with the
|
||||||
# consistency group song and dance. There will be a lot of no-ops
|
# consistency group song and dance. There will be a lot of no-ops
|
||||||
# because of this.
|
# because of this.
|
||||||
return {'status': 'available'}
|
return {'status': fields.ConsistencyGroupStatus.AVAILABLE}
|
||||||
|
|
||||||
def create_consistencygroup_from_src(self, ctxt, group, volumes,
|
def create_consistencygroup_from_src(self, ctxt, group, volumes,
|
||||||
cgsnapshot, snapshots,
|
cgsnapshot, snapshots,
|
||||||
@ -1294,7 +1295,8 @@ class SolidFireDriver(san.SanISCSIDriver):
|
|||||||
snap['id'],
|
snap['id'],
|
||||||
sf_group_snap,
|
sf_group_snap,
|
||||||
vol))
|
vol))
|
||||||
return {'status': 'available'}, vol_models
|
return ({'status': fields.ConsistencyGroupStatus.AVAILABLE},
|
||||||
|
vol_models)
|
||||||
|
|
||||||
elif source_cg and source_vols:
|
elif source_cg and source_vols:
|
||||||
# Create temporary group snapshot.
|
# Create temporary group snapshot.
|
||||||
|
@ -62,6 +62,7 @@ from cinder.image import cache as image_cache
|
|||||||
from cinder.image import glance
|
from cinder.image import glance
|
||||||
from cinder import manager
|
from cinder import manager
|
||||||
from cinder import objects
|
from cinder import objects
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder import quota
|
from cinder import quota
|
||||||
from cinder import utils
|
from cinder import utils
|
||||||
from cinder import volume as cinder_volume
|
from cinder import volume as cinder_volume
|
||||||
@ -2371,7 +2372,7 @@ class VolumeManager(manager.SchedulerDependentManager):
|
|||||||
"""Creates the consistency group."""
|
"""Creates the consistency group."""
|
||||||
context = context.elevated()
|
context = context.elevated()
|
||||||
|
|
||||||
status = 'available'
|
status = fields.ConsistencyGroupStatus.AVAILABLE
|
||||||
model_update = None
|
model_update = None
|
||||||
|
|
||||||
self._notify_about_consistencygroup_usage(
|
self._notify_about_consistencygroup_usage(
|
||||||
@ -2385,7 +2386,8 @@ class VolumeManager(manager.SchedulerDependentManager):
|
|||||||
group)
|
group)
|
||||||
|
|
||||||
if model_update:
|
if model_update:
|
||||||
if model_update['status'] == 'error':
|
if (model_update['status'] ==
|
||||||
|
fields.ConsistencyGroupStatus.ERROR):
|
||||||
msg = (_('Create consistency group failed.'))
|
msg = (_('Create consistency group failed.'))
|
||||||
LOG.error(msg,
|
LOG.error(msg,
|
||||||
resource={'type': 'consistency_group',
|
resource={'type': 'consistency_group',
|
||||||
@ -2396,7 +2398,7 @@ class VolumeManager(manager.SchedulerDependentManager):
|
|||||||
group.save()
|
group.save()
|
||||||
except Exception:
|
except Exception:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
group.status = 'error'
|
group.status = fields.ConsistencyGroupStatus.ERROR
|
||||||
group.save()
|
group.save()
|
||||||
LOG.error(_LE("Consistency group %s: create failed"),
|
LOG.error(_LE("Consistency group %s: create failed"),
|
||||||
group.name)
|
group.name)
|
||||||
@ -2864,7 +2866,8 @@ class VolumeManager(manager.SchedulerDependentManager):
|
|||||||
self.db.volume_update(context, update['id'], update)
|
self.db.volume_update(context, update['id'], update)
|
||||||
|
|
||||||
if model_update:
|
if model_update:
|
||||||
if model_update['status'] in ['error']:
|
if model_update['status'] in (
|
||||||
|
[fields.ConsistencyGroupStatus.ERROR]):
|
||||||
msg = (_('Error occurred when updating consistency group '
|
msg = (_('Error occurred when updating consistency group '
|
||||||
'%s.') % group.id)
|
'%s.') % group.id)
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user