Add notifications about snapshot.update.*

Now we have notifications about volume.update.*, but don't have
notifications about snapshot.update.*
In this patchset added this notifications.

Change-Id: Idc17516436b06871421c17cde0e2128f81613716
This commit is contained in:
Lena Novokshonova 2015-01-26 12:51:02 +04:00 committed by Sean McGinnis
parent bff548c690
commit 1a4c2e82f1
2 changed files with 11 additions and 2 deletions

View File

@ -27,6 +27,7 @@ from cinder import exception
from cinder.i18n import _, _LI
from cinder import utils
from cinder import volume
from cinder.volume import utils as volume_utils
LOG = logging.getLogger(__name__)
@ -261,6 +262,8 @@ class SnapshotsController(wsgi.Controller):
try:
snapshot = self.volume_api.get_snapshot(context, id)
volume_utils.notify_about_snapshot_usage(context, snapshot,
'update.start')
self.volume_api.update_snapshot(context, snapshot, update_dict)
except exception.NotFound:
msg = _("Snapshot could not be found")
@ -268,6 +271,8 @@ class SnapshotsController(wsgi.Controller):
snapshot.update(update_dict)
req.cache_db_snapshot(snapshot)
volume_utils.notify_about_snapshot_usage(context, snapshot,
'update.end')
return {'snapshot': _translate_snapshot_detail_view(context, snapshot)}

View File

@ -45,8 +45,12 @@ def _get_default_snapshot_param():
'status': 'available',
'volume_size': 100,
'created_at': None,
'user_id': 'bcb7746c7a41472d88a1ffac89ba6a9b',
'project_id': '7ffe17a15c724e2aa79fc839540aec15',
'display_name': 'Default name',
'display_description': 'Default description',
'deleted': None,
'volume': {'availability_zone': 'test_zone'}
}
@ -201,6 +205,7 @@ class SnapshotApiTest(test.TestCase):
}
}
self.assertEqual(expected, res_dict)
self.assertEqual(2, len(self.notifier.notifications))
def test_snapshot_update_missing_body(self):
body = {}
@ -277,7 +282,6 @@ class SnapshotApiTest(test.TestCase):
fake_volume_obj = fake_volume.fake_volume_obj(ctx)
snapshot_get_by_id.return_value = snapshot_obj
volume_get_by_id.return_value = fake_volume_obj
req = fakes.HTTPRequest.blank('/v2/snapshots/%s' % UUID)
resp_dict = self.controller.show(req, UUID)
@ -359,7 +363,7 @@ class SnapshotApiTest(test.TestCase):
# admin case
list_snapshots_with_limit_and_offset(is_admin=True)
# non_admin case
# non-admin case
list_snapshots_with_limit_and_offset(is_admin=False)
@mock.patch('cinder.db.snapshot_metadata_get', return_value=dict())