Emit notifications for volume retype

Emit a notification for volume retype when retype is sucessful.
The event contains the new volume type to allow proper billing.

Change-Id: I46590f214e42e187458d06b27fc07adfa49c0b62
Closes-Bug: #1555722
This commit is contained in:
Ed Balduf 2016-03-11 20:56:08 -07:00
parent 6ff821c2b5
commit 46c00f5c0c
2 changed files with 22 additions and 0 deletions

View File

@ -4868,6 +4868,8 @@ class VolumeMigrationTestCase(BaseVolumeTestCase):
self.context, volume, new_vol_type['id'])
volume = db.volume_get(elevated, volume.id)
self.assertEqual(0, len(self.notifier.notifications),
self.notifier.notifications)
self.assertEqual('available', volume['status'])
def _retype_volume_exec(self, driver, snap=False, policy='on-demand',
@ -4982,16 +4984,33 @@ class VolumeMigrationTestCase(BaseVolumeTestCase):
self.assertEqual('available', volume.status)
self.assertEqual(CONF.host, volume.host)
self.assertEqual(1, volumes_in_use)
self.assertEqual(1, len(self.notifier.notifications),
"Notifier count incorrect %s" %
(self.notifier.notifications))
self.assertEqual(vol_type['id'], self.notifier.notifications[0]
['payload']['volume_type'])
self.assertEqual('volume.retype', self.notifier.notifications[0]
['event_type'])
elif not exc:
self.assertEqual(old_vol_type['id'], volume.volume_type_id)
self.assertEqual('retyping', volume.status)
self.assertEqual(CONF.host, volume.host)
self.assertEqual(1, volumes_in_use)
self.assertEqual(1, len(self.notifier.notifications),
"Notifier count incorrect %s" %
(self.notifier.notifications))
self.assertEqual(vol_type['id'], self.notifier.notifications[0]
['payload']['volume_type'])
self.assertEqual('volume.retype', self.notifier.notifications[0]
['event_type'])
else:
self.assertEqual(old_vol_type['id'], volume.volume_type_id)
self.assertEqual('available', volume.status)
self.assertEqual(CONF.host, volume.host)
self.assertEqual(0, volumes_in_use)
self.assertEqual(0, len(self.notifier.notifications),
"Notifier count incorrect %s" %
(self.notifier.notifications))
def test_retype_volume_driver_success(self):
self._retype_volume_exec(True)

View File

@ -2317,6 +2317,9 @@ class VolumeManager(manager.SchedulerDependentManager):
QUOTAS.commit(context, old_reservations, project_id=project_id)
if new_reservations:
QUOTAS.commit(context, new_reservations, project_id=project_id)
self._notify_about_volume_usage(
context, volume, "retype",
extra_usage_info={'volume_type': new_type_id})
self.publish_service_capabilities(context)
LOG.info(_LI("Retype volume completed successfully."),
resource=volume)