From e3dc4885cc3336c715412f2305183673ae72591b Mon Sep 17 00:00:00 2001 From: wanghao Date: Wed, 15 Mar 2017 10:38:43 +0800 Subject: [PATCH] Fix: SnapshotStatus missing in Cinder Now we have introduced SnapshotStatus in Cinder, but some places still miss changing to use it. So this bug will fix them quickly. Change-Id: I99cc33c540cb0781635aba4309a083633e43952f Closes-Bug: #1672918 --- cinder/tests/unit/consistencygroup/test_cg.py | 2 +- cinder/tests/unit/objects/test_snapshot.py | 4 ++-- cinder/tests/unit/volume/test_snapshot.py | 2 +- cinder/tests/unit/volume/test_volume.py | 2 +- cinder/tests/unit/volume/test_volume_migration.py | 3 ++- cinder/tests/unit/windows/test_smbfs.py | 3 ++- cinder/volume/flows/manager/manage_existing_snapshot.py | 3 ++- 7 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cinder/tests/unit/consistencygroup/test_cg.py b/cinder/tests/unit/consistencygroup/test_cg.py index f4f84e6a1e3..8643c2dd131 100644 --- a/cinder/tests/unit/consistencygroup/test_cg.py +++ b/cinder/tests/unit/consistencygroup/test_cg.py @@ -508,7 +508,7 @@ class ConsistencyGroupTestCase(base.BaseVolumeTestCase): snap.user_id = fake.USER_ID snap.project_id = fake.PROJECT_ID snap.volume_id = volume_id - snap.status = "available" + snap.status = fields.SnapshotStatus.AVAILABLE snap.cgsnapshot_id = cgsnap.id snap.create() snaps.append(snap) diff --git a/cinder/tests/unit/objects/test_snapshot.py b/cinder/tests/unit/objects/test_snapshot.py index 4f0fc0bf09b..a83e64d735c 100644 --- a/cinder/tests/unit/objects/test_snapshot.py +++ b/cinder/tests/unit/objects/test_snapshot.py @@ -129,7 +129,7 @@ class TestSnapshot(test_objects.BaseObjectsTestCase): snapshot_destroy.assert_called_once_with(self.context, fake.SNAPSHOT_ID) self.assertTrue(snapshot.deleted) - self.assertEqual('deleted', snapshot.status) + self.assertEqual(fields.SnapshotStatus.DELETED, snapshot.status) self.assertEqual(utcnow_mock.return_value.replace(tzinfo=pytz.UTC), snapshot.deleted_at) @@ -233,7 +233,7 @@ class TestSnapshot(test_objects.BaseObjectsTestCase): @ddt.data('1.1', '1.3') def test_obj_make_compatible(self, version): snapshot = objects.Snapshot(context=self.context) - snapshot.status = 'unmanaging' + snapshot.status = fields.SnapshotStatus.UNMANAGING primitive = snapshot.obj_to_primitive(version) snapshot = objects.Snapshot.obj_from_primitive(primitive) if version == '1.3': diff --git a/cinder/tests/unit/volume/test_snapshot.py b/cinder/tests/unit/volume/test_snapshot.py index 63a9c3b652d..b4f6ef222ed 100644 --- a/cinder/tests/unit/volume/test_snapshot.py +++ b/cinder/tests/unit/volume/test_snapshot.py @@ -55,7 +55,7 @@ def create_snapshot(volume_id, size=1, metadata=None, ctxt=None, snap.user_id = fake.USER_ID snap.project_id = fake.PROJECT_ID snap.volume_id = volume_id - snap.status = "creating" + snap.status = fields.SnapshotStatus.CREATING if metadata is not None: snap.metadata = metadata snap.update(kwargs) diff --git a/cinder/tests/unit/volume/test_volume.py b/cinder/tests/unit/volume/test_volume.py index 7a15851e9bb..001761c5eca 100644 --- a/cinder/tests/unit/volume/test_volume.py +++ b/cinder/tests/unit/volume/test_volume.py @@ -75,7 +75,7 @@ def create_snapshot(volume_id, size=1, metadata=None, ctxt=None, snap.user_id = fake.USER_ID snap.project_id = fake.PROJECT_ID snap.volume_id = volume_id - snap.status = "creating" + snap.status = fields.SnapshotStatus.CREATING if metadata is not None: snap.metadata = metadata snap.update(kwargs) diff --git a/cinder/tests/unit/volume/test_volume_migration.py b/cinder/tests/unit/volume/test_volume_migration.py index a4b64deda93..ccdd8938e73 100644 --- a/cinder/tests/unit/volume/test_volume_migration.py +++ b/cinder/tests/unit/volume/test_volume_migration.py @@ -28,6 +28,7 @@ from cinder import context from cinder import db from cinder import exception from cinder import objects +from cinder.objects import fields from cinder import quota from cinder.tests.unit.api import fakes from cinder.tests.unit import fake_constants as fake @@ -56,7 +57,7 @@ def create_snapshot(volume_id, size=1, metadata=None, ctxt=None, snap.user_id = kwargs.get('user_id', fake.USER_ID) snap.project_id = kwargs.get('project_id', fake.PROJECT_ID) snap.volume_id = volume_id - snap.status = "creating" + snap.status = fields.SnapshotStatus.CREATING if metadata is not None: snap.metadata = metadata snap.update(kwargs) diff --git a/cinder/tests/unit/windows/test_smbfs.py b/cinder/tests/unit/windows/test_smbfs.py index 2689ba35130..70d574ce459 100644 --- a/cinder/tests/unit/windows/test_smbfs.py +++ b/cinder/tests/unit/windows/test_smbfs.py @@ -23,6 +23,7 @@ from oslo_utils import units from cinder import context from cinder import exception from cinder.image import image_utils +from cinder.objects import fields from cinder import test from cinder.tests.unit import fake_snapshot from cinder.tests.unit import fake_volume @@ -610,7 +611,7 @@ class WindowsSmbFsTestCase(test.TestCase): mock.sentinel.src_vol) def test_create_volume_from_unavailable_snapshot(self): - self.snapshot.status = 'error' + self.snapshot.status = fields.SnapshotStatus.ERROR self.assertRaises( exception.InvalidSnapshot, self._smbfs_driver.create_volume_from_snapshot, diff --git a/cinder/volume/flows/manager/manage_existing_snapshot.py b/cinder/volume/flows/manager/manage_existing_snapshot.py index 735e332cd88..9d697880638 100644 --- a/cinder/volume/flows/manager/manage_existing_snapshot.py +++ b/cinder/volume/flows/manager/manage_existing_snapshot.py @@ -22,6 +22,7 @@ from cinder import exception from cinder import flow_utils from cinder.i18n import _, _LE, _LI from cinder import objects +from cinder.objects import fields from cinder import quota from cinder import quota_utils from cinder.volume.flows import common as flow_common @@ -253,7 +254,7 @@ class ManageExistingTask(flow_utils.CinderTask): raise return {'snapshot': snapshot_ref, - 'new_status': 'available'} + 'new_status': fields.SnapshotStatus.AVAILABLE} class CreateSnapshotOnFinishTask(NotifySnapshotActionTask):