From: jenny-shieh Date: Thu, 13 Jun 2013 22:04:59 +0000 (-0700) Subject: Update and add notifiers in create volume X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=3deebeeb5045797c6ac97e9c34cbc42603296c37;p=openstack-build%2Fcinder-build.git 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 --- 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()