]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
delete.start/delete.end notification for hostless
authorJay S. Bryant <jsbryant@us.ibm.com>
Wed, 4 Dec 2013 03:31:17 +0000 (21:31 -0600)
committerJay S. Bryant <jsbryant@us.ibm.com>
Wed, 4 Dec 2013 03:42:25 +0000 (21:42 -0600)
Third party GUIs may rely on notifications to track the
progress of volume creation and deletion.  In the case that
a volume is being deleted after a failed attempt to create
(the volume is listed in the database but is not actually
resident in a backing store) the path that is taken in
volume.api.delete() makes no notifications of deletion
occurring.

This patch adds a volume_utils.notify_about_volume_usage
call to the beginning and end of the delete with a
delete.start and delete.end respectively.  The notifications
serve as triggers for GUIs to refresh the state of the
volume.  This change makes the hostless delete path's
functionality more consistent with the other paths through
the delete code.

Change-Id: I091b9d277834b341105569d41a48ef5c1fc105ce
Closes-Bug: 1257053

cinder/volume/api.py

index 7b4dd70dadd7554d0923b38f1cb0ce0596660966..7958fbe453bdbbc5a9a8279f51cd1bc8d864d1cf 100644 (file)
@@ -41,6 +41,7 @@ from cinder import units
 from cinder import utils
 from cinder.volume.flows import create_volume
 from cinder.volume import rpcapi as volume_rpcapi
+from cinder.volume import utils as volume_utils
 from cinder.volume import volume_types
 
 from cinder.taskflow import states
@@ -193,6 +194,8 @@ class API(base.Base):
 
         volume_id = volume['id']
         if not volume['host']:
+            volume_utils.notify_about_volume_usage(context,
+                                                   volume, "delete.start")
             # NOTE(vish): scheduling failed, so delete it
             # Note(zhiteng): update volume quota reservation
             try:
@@ -210,6 +213,9 @@ class API(base.Base):
 
             if reservations:
                 QUOTAS.commit(context, reservations, project_id=project_id)
+
+            volume_utils.notify_about_volume_usage(context,
+                                                   volume, "delete.end")
             return
         if not force and volume['status'] not in ["available", "error",
                                                   "error_restoring",