Skip to content

Commit

Permalink
Update and add notifiers in create volume
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jenny-shieh committed Jun 14, 2013
1 parent 0a26b70 commit 3deebee
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion cinder/tests/test_volume.py
Expand Up @@ -144,7 +144,7 @@ def fake_rollback(context, reservations, project_id=None):
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',
Expand Down
12 changes: 9 additions & 3 deletions cinder/volume/manager.py
Expand Up @@ -287,9 +287,13 @@ def create_volume(self, context, volume_id, request_spec=None,
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
Expand All @@ -315,9 +319,11 @@ def create_volume(self, context, volume_id, request_spec=None,
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()

Expand Down

0 comments on commit 3deebee

Please sign in to comment.