Merge "Add snapshot clean worker decorator"

This commit is contained in:
Jenkins 2017-07-09 18:12:09 +00:00 committed by Gerrit Code Review
commit ab236e32d6
2 changed files with 11 additions and 0 deletions

View File

@ -1929,6 +1929,16 @@ class VolumeTestCase(base.BaseVolumeTestCase):
self.assertEqual(fields.SnapshotStatus.DELETING, snapshot.status)
self.volume.delete_volume(self.context, volume)
def test_create_snapshot_set_worker(self):
volume = tests_utils.create_volume(self.context)
snapshot = create_snapshot(volume.id, size=volume['size'],
ctxt=self.context,
status=fields.SnapshotStatus.CREATING)
self.volume.create_snapshot(self.context, snapshot)
volume.set_worker.assert_called_once_with()
def test_cannot_delete_snapshot_with_bad_status(self):
volume = tests_utils.create_volume(self.context, CONF.host)
snapshot = create_snapshot(volume.id, size=volume['size'],

View File

@ -1020,6 +1020,7 @@ class VolumeManager(manager.CleanableManager,
msg_args = {'v_id': volume.id, 'snap_id': snapshot.id}
LOG.info(msg, msg_args)
@objects.Snapshot.set_workers
def create_snapshot(self, context, snapshot):
"""Creates and exports the snapshot."""
context = context.elevated()