Merge "Use GroupSnapshotStatus enum field"
This commit is contained in:
commit
fb89d06dd4
@ -15,6 +15,7 @@
|
|||||||
|
|
||||||
from oslo_utils import uuidutils
|
from oslo_utils import uuidutils
|
||||||
|
|
||||||
|
from cinder.objects import fields
|
||||||
from cinder.tests.functional import functional_helpers
|
from cinder.tests.functional import functional_helpers
|
||||||
from cinder.volume import configuration
|
from cinder.volume import configuration
|
||||||
|
|
||||||
@ -94,18 +95,19 @@ class GroupSnapshotsTest(functional_helpers._FunctionalTestBase):
|
|||||||
|
|
||||||
# Check it's there
|
# Check it's there
|
||||||
found_group_snapshot = self._poll_group_snapshot_while(
|
found_group_snapshot = self._poll_group_snapshot_while(
|
||||||
created_group_snapshot_id, ['creating'])
|
created_group_snapshot_id, [fields.GroupSnapshotStatus.CREATING])
|
||||||
self.assertEqual(created_group_snapshot_id, found_group_snapshot['id'])
|
self.assertEqual(created_group_snapshot_id, found_group_snapshot['id'])
|
||||||
self.assertEqual(created_group_id,
|
self.assertEqual(created_group_id,
|
||||||
found_group_snapshot['group_id'])
|
found_group_snapshot['group_id'])
|
||||||
self.assertEqual('available', found_group_snapshot['status'])
|
self.assertEqual(fields.GroupSnapshotStatus.AVAILABLE,
|
||||||
|
found_group_snapshot['status'])
|
||||||
|
|
||||||
# Delete the group snapshot
|
# Delete the group snapshot
|
||||||
self.api.delete_group_snapshot(created_group_snapshot_id)
|
self.api.delete_group_snapshot(created_group_snapshot_id)
|
||||||
|
|
||||||
# Wait (briefly) for deletion. Delay is due to the 'message queue'
|
# Wait (briefly) for deletion. Delay is due to the 'message queue'
|
||||||
found_group_snapshot = self._poll_group_snapshot_while(
|
found_group_snapshot = self._poll_group_snapshot_while(
|
||||||
created_group_snapshot_id, ['deleting'])
|
created_group_snapshot_id, [fields.GroupSnapshotStatus.DELETING])
|
||||||
|
|
||||||
# Delete the original group
|
# Delete the original group
|
||||||
self.api.delete_group(created_group_id,
|
self.api.delete_group(created_group_id,
|
||||||
@ -205,7 +207,7 @@ class GroupSnapshotsTest(functional_helpers._FunctionalTestBase):
|
|||||||
|
|
||||||
# Wait (briefly) for deletion. Delay is due to the 'message queue'
|
# Wait (briefly) for deletion. Delay is due to the 'message queue'
|
||||||
found_group_snapshot = self._poll_group_snapshot_while(
|
found_group_snapshot = self._poll_group_snapshot_while(
|
||||||
created_group_snapshot_id, ['deleting'])
|
created_group_snapshot_id, [fields.GroupSnapshotStatus.DELETING])
|
||||||
|
|
||||||
# Delete the original group
|
# Delete the original group
|
||||||
self.api.delete_group(created_group_id,
|
self.api.delete_group(created_group_id,
|
||||||
@ -324,22 +326,25 @@ class GroupSnapshotsTest(functional_helpers._FunctionalTestBase):
|
|||||||
self.assertTrue(uuidutils.is_uuid_like(group_snapshot1['id']))
|
self.assertTrue(uuidutils.is_uuid_like(group_snapshot1['id']))
|
||||||
group_snapshot_id = group_snapshot1['id']
|
group_snapshot_id = group_snapshot1['id']
|
||||||
|
|
||||||
self._poll_group_snapshot_while(group_snapshot_id, 'creating')
|
self._poll_group_snapshot_while(group_snapshot_id,
|
||||||
|
fields.GroupSnapshotStatus.CREATING)
|
||||||
|
|
||||||
group_snapshot1 = self.api.get_group_snapshot(group_snapshot_id)
|
group_snapshot1 = self.api.get_group_snapshot(group_snapshot_id)
|
||||||
self.assertEqual("available", group_snapshot1['status'])
|
self.assertEqual(fields.GroupSnapshotStatus.AVAILABLE,
|
||||||
|
group_snapshot1['status'])
|
||||||
|
|
||||||
# reset group snapshot status
|
# reset group snapshot status
|
||||||
self.api.reset_group_snapshot(group_snapshot_id,
|
self.api.reset_group_snapshot(group_snapshot_id, {"reset_status": {
|
||||||
{"reset_status": {"status": "error"}})
|
"status": fields.GroupSnapshotStatus.ERROR}})
|
||||||
|
|
||||||
group_snapshot1 = self.api.get_group_snapshot(group_snapshot_id)
|
group_snapshot1 = self.api.get_group_snapshot(group_snapshot_id)
|
||||||
self.assertEqual("error", group_snapshot1['status'])
|
self.assertEqual(fields.GroupSnapshotStatus.ERROR,
|
||||||
|
group_snapshot1['status'])
|
||||||
|
|
||||||
# Delete group, volume and group snapshot
|
# Delete group, volume and group snapshot
|
||||||
self.api.delete_group_snapshot(group_snapshot_id)
|
self.api.delete_group_snapshot(group_snapshot_id)
|
||||||
found_group_snapshot = self._poll_group_snapshot_while(
|
found_group_snapshot = self._poll_group_snapshot_while(
|
||||||
group_snapshot_id, ['deleting'])
|
group_snapshot_id, [fields.GroupSnapshotStatus.DELETING])
|
||||||
self.api.delete_group(group_id,
|
self.api.delete_group(group_id,
|
||||||
{'delete': {'delete-volumes': True}})
|
{'delete': {'delete-volumes': True}})
|
||||||
|
|
||||||
|
@ -84,7 +84,8 @@ class GroupSnapshotsAPITestCase(test.TestCase):
|
|||||||
res_dict['group_snapshot']['description'])
|
res_dict['group_snapshot']['description'])
|
||||||
self.assertEqual('test_group_snapshot',
|
self.assertEqual('test_group_snapshot',
|
||||||
res_dict['group_snapshot']['name'])
|
res_dict['group_snapshot']['name'])
|
||||||
self.assertEqual('creating', res_dict['group_snapshot']['status'])
|
self.assertEqual(fields.GroupSnapshotStatus.CREATING,
|
||||||
|
res_dict['group_snapshot']['status'])
|
||||||
|
|
||||||
group_snapshot.destroy()
|
group_snapshot.destroy()
|
||||||
|
|
||||||
@ -422,7 +423,7 @@ class GroupSnapshotsAPITestCase(test.TestCase):
|
|||||||
group_snapshot = utils.create_group_snapshot(
|
group_snapshot = utils.create_group_snapshot(
|
||||||
self.context,
|
self.context,
|
||||||
group_id=self.group.id,
|
group_id=self.group.id,
|
||||||
status='available')
|
status=fields.GroupSnapshotStatus.AVAILABLE)
|
||||||
req = fakes.HTTPRequest.blank('/v3/%s/group_snapshots/%s' %
|
req = fakes.HTTPRequest.blank('/v3/%s/group_snapshots/%s' %
|
||||||
(fake.PROJECT_ID, group_snapshot.id),
|
(fake.PROJECT_ID, group_snapshot.id),
|
||||||
version=GROUP_MICRO_VERSION)
|
version=GROUP_MICRO_VERSION)
|
||||||
@ -431,7 +432,8 @@ class GroupSnapshotsAPITestCase(test.TestCase):
|
|||||||
group_snapshot = objects.GroupSnapshot.get_by_id(self.context,
|
group_snapshot = objects.GroupSnapshot.get_by_id(self.context,
|
||||||
group_snapshot.id)
|
group_snapshot.id)
|
||||||
self.assertEqual(http_client.ACCEPTED, res_dict.status_int)
|
self.assertEqual(http_client.ACCEPTED, res_dict.status_int)
|
||||||
self.assertEqual('deleting', group_snapshot.status)
|
self.assertEqual(fields.GroupSnapshotStatus.DELETING,
|
||||||
|
group_snapshot.status)
|
||||||
|
|
||||||
group_snapshot.destroy()
|
group_snapshot.destroy()
|
||||||
|
|
||||||
@ -439,7 +441,7 @@ class GroupSnapshotsAPITestCase(test.TestCase):
|
|||||||
group_snapshot = utils.create_group_snapshot(
|
group_snapshot = utils.create_group_snapshot(
|
||||||
self.context,
|
self.context,
|
||||||
group_id=self.group.id,
|
group_id=self.group.id,
|
||||||
status='available')
|
status=fields.GroupSnapshotStatus.AVAILABLE)
|
||||||
|
|
||||||
group2 = utils.create_group(
|
group2 = utils.create_group(
|
||||||
self.context, status='creating',
|
self.context, status='creating',
|
||||||
|
@ -19,6 +19,7 @@ import six
|
|||||||
|
|
||||||
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 fake_constants as fake
|
from cinder.tests.unit import fake_constants as fake
|
||||||
from cinder.tests.unit import objects as test_objects
|
from cinder.tests.unit import objects as test_objects
|
||||||
from cinder.tests.unit.objects.test_group import fake_group
|
from cinder.tests.unit.objects.test_group import fake_group
|
||||||
@ -29,7 +30,7 @@ fake_group_snapshot = {
|
|||||||
'project_id': fake.PROJECT_ID,
|
'project_id': fake.PROJECT_ID,
|
||||||
'name': 'fake_name',
|
'name': 'fake_name',
|
||||||
'description': 'fake_description',
|
'description': 'fake_description',
|
||||||
'status': 'creating',
|
'status': fields.GroupSnapshotStatus.CREATING,
|
||||||
'group_id': fake.GROUP_ID,
|
'group_id': fake.GROUP_ID,
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,7 +91,7 @@ class TestGroupSnapshot(test_objects.BaseObjectsTestCase):
|
|||||||
@mock.patch('cinder.db.sqlalchemy.api.group_snapshot_destroy')
|
@mock.patch('cinder.db.sqlalchemy.api.group_snapshot_destroy')
|
||||||
def test_destroy(self, group_snapshot_destroy, utcnow_mock):
|
def test_destroy(self, group_snapshot_destroy, utcnow_mock):
|
||||||
group_snapshot_destroy.return_value = {
|
group_snapshot_destroy.return_value = {
|
||||||
'status': 'deleted',
|
'status': fields.GroupSnapshotStatus.DELETED,
|
||||||
'deleted': True,
|
'deleted': True,
|
||||||
'deleted_at': utcnow_mock.return_value}
|
'deleted_at': utcnow_mock.return_value}
|
||||||
group_snapshot = objects.GroupSnapshot(context=self.context,
|
group_snapshot = objects.GroupSnapshot(context=self.context,
|
||||||
@ -100,7 +101,8 @@ class TestGroupSnapshot(test_objects.BaseObjectsTestCase):
|
|||||||
admin_context = group_snapshot_destroy.call_args[0][0]
|
admin_context = group_snapshot_destroy.call_args[0][0]
|
||||||
self.assertTrue(admin_context.is_admin)
|
self.assertTrue(admin_context.is_admin)
|
||||||
self.assertTrue(group_snapshot.deleted)
|
self.assertTrue(group_snapshot.deleted)
|
||||||
self.assertEqual('deleted', group_snapshot.status)
|
self.assertEqual(fields.GroupSnapshotStatus.DELETED,
|
||||||
|
group_snapshot.status)
|
||||||
self.assertEqual(utcnow_mock.return_value.replace(tzinfo=pytz.UTC),
|
self.assertEqual(utcnow_mock.return_value.replace(tzinfo=pytz.UTC),
|
||||||
group_snapshot.deleted_at)
|
group_snapshot.deleted_at)
|
||||||
|
|
||||||
|
@ -5050,7 +5050,7 @@ class HPE3PARBaseDriver(object):
|
|||||||
optional=group_snap_optional)]
|
optional=group_snap_optional)]
|
||||||
|
|
||||||
# delete the snapshot of the consistency group
|
# delete the snapshot of the consistency group
|
||||||
group_snapshot.status = 'deleting'
|
group_snapshot.status = fields.GroupSnapshotStatus.DELETING
|
||||||
self.driver.delete_group_snapshot(context.get_admin_context(),
|
self.driver.delete_group_snapshot(context.get_admin_context(),
|
||||||
group_snapshot, [])
|
group_snapshot, [])
|
||||||
|
|
||||||
|
@ -3637,11 +3637,12 @@ class VolumeManager(manager.CleanableManager,
|
|||||||
fields.SnapshotStatus.ERROR_DELETING,
|
fields.SnapshotStatus.ERROR_DELETING,
|
||||||
fields.SnapshotStatus.ERROR] and
|
fields.SnapshotStatus.ERROR] and
|
||||||
model_update['status'] not in
|
model_update['status'] not in
|
||||||
['error_deleting', 'error']):
|
[fields.GroupSnapshotStatus.ERROR_DELETING,
|
||||||
|
fields.GroupSnapshotStatus.ERROR]):
|
||||||
model_update['status'] = snap_model['status']
|
model_update['status'] = snap_model['status']
|
||||||
|
|
||||||
if model_update:
|
if model_update:
|
||||||
if model_update['status'] == 'error':
|
if model_update['status'] == fields.GroupSnapshotStatus.ERROR:
|
||||||
msg = (_('Error occurred when creating group_snapshot '
|
msg = (_('Error occurred when creating group_snapshot '
|
||||||
'%s.') % group_snapshot.id)
|
'%s.') % group_snapshot.id)
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
@ -3652,7 +3653,7 @@ class VolumeManager(manager.CleanableManager,
|
|||||||
|
|
||||||
except exception.CinderException:
|
except exception.CinderException:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
group_snapshot.status = 'error'
|
group_snapshot.status = fields.GroupSnapshotStatus.ERROR
|
||||||
group_snapshot.save()
|
group_snapshot.save()
|
||||||
# Update snapshot status to 'error' if driver returns
|
# Update snapshot status to 'error' if driver returns
|
||||||
# None for snapshots_model_update.
|
# None for snapshots_model_update.
|
||||||
@ -3690,7 +3691,7 @@ class VolumeManager(manager.CleanableManager,
|
|||||||
snapshot.progress = '100%'
|
snapshot.progress = '100%'
|
||||||
snapshot.save()
|
snapshot.save()
|
||||||
|
|
||||||
group_snapshot.status = 'available'
|
group_snapshot.status = fields.GroupSnapshotStatus.AVAILABLE
|
||||||
group_snapshot.save()
|
group_snapshot.save()
|
||||||
|
|
||||||
LOG.info("group_snapshot %s: created successfully",
|
LOG.info("group_snapshot %s: created successfully",
|
||||||
@ -3821,7 +3822,7 @@ class VolumeManager(manager.CleanableManager,
|
|||||||
|
|
||||||
except exception.CinderException:
|
except exception.CinderException:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
group_snapshot.status = 'error'
|
group_snapshot.status = fields.GroupSnapshotStatus.ERROR
|
||||||
group_snapshot.save()
|
group_snapshot.save()
|
||||||
# Update snapshot status to 'error' if driver returns
|
# Update snapshot status to 'error' if driver returns
|
||||||
# None for snapshots_model_update.
|
# None for snapshots_model_update.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user