context = req.environ['cinder.context']
self._check_type(context, type_id)
authorize(context)
- db.volume_type_extra_specs_delete(context, type_id, id)
+
+ try:
+ db.volume_type_extra_specs_delete(context, type_id, id)
+ except exception.VolumeTypeExtraSpecsNotFound as error:
+ raise webob.exc.HTTPNotFound(explanation=unicode(error))
+
notifier_info = dict(type_id=type_id, id=id)
notifier_api.notify(context, 'volumeTypeExtraSpecs',
'volume_type_extra_specs.delete',
@require_context
def volume_type_extra_specs_delete(context, volume_type_id, key):
+ session = get_session()
+ volume_type_extra_specs_get_item(context, volume_type_id, key, session)
_volume_type_extra_specs_query(context, volume_type_id).\
filter_by(key=key).\
update({'deleted': True,
import webob
from cinder.api.contrib import types_extra_specs
+from cinder import exception
from cinder.openstack.common.notifier import api as notifier_api
from cinder.openstack.common.notifier import test_notifier
from cinder import test
pass
+def delete_volume_type_extra_specs_not_found(context, volume_type_id, key):
+ raise exception.VolumeTypeExtraSpecsNotFound("Not Found")
+
+
def stub_volume_type_extra_specs():
specs = {
"key1": "value1",
self.controller.delete(req, 1, 'key5')
self.assertEquals(len(test_notifier.NOTIFICATIONS), 1)
+ def test_delete_not_found(self):
+ self.stubs.Set(cinder.db, 'volume_type_extra_specs_delete',
+ delete_volume_type_extra_specs_not_found)
+
+ req = fakes.HTTPRequest.blank(self.api_path + '/key6')
+ self.assertRaises(webob.exc.HTTPNotFound, self.controller.delete,
+ req, 1, 'key6')
+
def test_create(self):
self.stubs.Set(cinder.db,
'volume_type_extra_specs_update_or_create',