From 3deebeeb5045797c6ac97e9c34cbc42603296c37 Mon Sep 17 00:00:00 2001 From: jenny-shieh Date: Thu, 13 Jun 2013 15:04:59 -0700 Subject: [PATCH] Update and add notifiers in create volume 1. Change status from 'creating' to 'available' when the volume is created 2. Add a notifier when it fails to create the volume Implements: notifiers for create volume Fixes: bug #1190754 Change-Id: I3a7d118630b32cfa7efb6bc8984418ca9836764a --- cinder/tests/test_volume.py | 2 +- cinder/volume/manager.py | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/cinder/tests/test_volume.py b/cinder/tests/test_volume.py index 64761e831..bdfe0154d 100644 --- a/cinder/tests/test_volume.py +++ b/cinder/tests/test_volume.py @@ -144,7 +144,7 @@ class VolumeTestCase(test.TestCase): msg = test_notifier.NOTIFICATIONS[1] self.assertEqual(msg['event_type'], 'volume.create.end') expected = { - 'status': 'creating', + 'status': 'available', 'display_name': None, 'availability_zone': 'nova', 'tenant_id': 'fake', diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index e986b7cd0..678d9892a 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -287,9 +287,13 @@ class VolumeManager(manager.SchedulerDependentManager): self.db.volume_update(context, volume_ref['id'], model_update) except Exception: with excutils.save_and_reraise_exception(): + volume_ref['status'] = 'error' self.db.volume_update(context, - volume_ref['id'], {'status': 'error'}) + volume_ref['id'], + {'status': volume_ref['status']}) LOG.error(_("volume %s: create failed"), volume_ref['name']) + self._notify_about_volume_usage(context, volume_ref, + "create.end") if snapshot_id: # Copy any Glance metadata from the original volume @@ -315,9 +319,11 @@ class VolumeManager(manager.SchedulerDependentManager): key, value) now = timeutils.utcnow() + volume_ref['status'] = status self.db.volume_update(context, - volume_ref['id'], {'status': status, - 'launched_at': now}) + volume_ref['id'], + {'status': volume_ref['status'], + 'launched_at': now}) LOG.info(_("volume %s: created successfully"), volume_ref['name']) self._reset_stats() -- 2.45.2