Use EntityNotFound instead of WatchRuleNotFound
Replace and keep WatchRuleNotFound only for AWS compatibility. Partial-Bug: #1515603 Change-Id: If5584de1c8f28efdc76d3b82b62f5c1af089285c
This commit is contained in:
parent
a1f1ce6968
commit
04bcee4945
|
@ -215,6 +215,7 @@ class ResourceNotAvailable(HeatException):
|
||||||
|
|
||||||
|
|
||||||
class WatchRuleNotFound(HeatException):
|
class WatchRuleNotFound(HeatException):
|
||||||
|
'''Keep this for AWS compatiblility.'''
|
||||||
msg_fmt = _("The Watch Rule (%(watch_name)s) could not be found.")
|
msg_fmt = _("The Watch Rule (%(watch_name)s) could not be found.")
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -369,7 +369,7 @@ class CeilometerAlarm(resource.Resource):
|
||||||
wr = watchrule.WatchRule.load(
|
wr = watchrule.WatchRule.load(
|
||||||
self.context, watch_name=self.physical_resource_name())
|
self.context, watch_name=self.physical_resource_name())
|
||||||
wr.destroy()
|
wr.destroy()
|
||||||
except exception.WatchRuleNotFound:
|
except exception.EntityNotFound:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
return super(CeilometerAlarm, self).handle_delete()
|
return super(CeilometerAlarm, self).handle_delete()
|
||||||
|
|
|
@ -176,7 +176,7 @@ class CloudWatchAlarm(resource.Resource):
|
||||||
wr = watchrule.WatchRule.load(
|
wr = watchrule.WatchRule.load(
|
||||||
self.context, watch_name=self.physical_resource_name())
|
self.context, watch_name=self.physical_resource_name())
|
||||||
wr.destroy()
|
wr.destroy()
|
||||||
except exception.WatchRuleNotFound:
|
except exception.EntityNotFound:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def handle_suspend(self):
|
def handle_suspend(self):
|
||||||
|
|
|
@ -1662,7 +1662,8 @@ class EngineService(service.Service):
|
||||||
if not rule_run:
|
if not rule_run:
|
||||||
if watch_name is None:
|
if watch_name is None:
|
||||||
watch_name = 'Unknown'
|
watch_name = 'Unknown'
|
||||||
raise exception.WatchRuleNotFound(watch_name=watch_name)
|
raise exception.EntityNotFound(entity='Watch Rule',
|
||||||
|
name=watch_name)
|
||||||
|
|
||||||
return stats_data
|
return stats_data
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,8 @@ class WatchRule(object):
|
||||||
LOG.warn(_LW('WatchRule.load (%(watch_name)s) db error '
|
LOG.warn(_LW('WatchRule.load (%(watch_name)s) db error '
|
||||||
'%(ex)s'), {'watch_name': watch_name, 'ex': ex})
|
'%(ex)s'), {'watch_name': watch_name, 'ex': ex})
|
||||||
if watch is None:
|
if watch is None:
|
||||||
raise exception.WatchRuleNotFound(watch_name=watch_name)
|
raise exception.EntityNotFound(entity='Watch Rule',
|
||||||
|
name=watch_name)
|
||||||
else:
|
else:
|
||||||
return cls(context=context,
|
return cls(context=context,
|
||||||
watch_name=watch.name,
|
watch_name=watch.name,
|
||||||
|
|
|
@ -106,7 +106,7 @@ class StackWatchTest(common.HeatTestCase):
|
||||||
ex = self.assertRaises(dispatcher.ExpectedException,
|
ex = self.assertRaises(dispatcher.ExpectedException,
|
||||||
self.eng.show_watch,
|
self.eng.show_watch,
|
||||||
self.ctx, watch_name="nonexistent")
|
self.ctx, watch_name="nonexistent")
|
||||||
self.assertEqual(exception.WatchRuleNotFound, ex.exc_info[0])
|
self.assertEqual(exception.EntityNotFound, ex.exc_info[0])
|
||||||
|
|
||||||
# Check the response has all keys defined in the engine API
|
# Check the response has all keys defined in the engine API
|
||||||
for key in rpc_api.WATCH_KEYS:
|
for key in rpc_api.WATCH_KEYS:
|
||||||
|
@ -255,11 +255,12 @@ class StackWatchTest(common.HeatTestCase):
|
||||||
@mock.patch.object(watchrule.WatchRule, 'load')
|
@mock.patch.object(watchrule.WatchRule, 'load')
|
||||||
def test_set_watch_state_noexist(self, mock_load):
|
def test_set_watch_state_noexist(self, mock_load):
|
||||||
state = watchrule.WatchRule.ALARM # State valid
|
state = watchrule.WatchRule.ALARM # State valid
|
||||||
mock_load.side_effect = exception.WatchRuleNotFound(watch_name='test')
|
mock_load.side_effect = exception.EntityNotFound(entity='Watch Rule',
|
||||||
|
name='test')
|
||||||
|
|
||||||
ex = self.assertRaises(dispatcher.ExpectedException,
|
ex = self.assertRaises(dispatcher.ExpectedException,
|
||||||
self.eng.set_watch_state,
|
self.eng.set_watch_state,
|
||||||
self.ctx, watch_name="nonexistent",
|
self.ctx, watch_name="nonexistent",
|
||||||
state=state)
|
state=state)
|
||||||
self.assertEqual(exception.WatchRuleNotFound, ex.exc_info[0])
|
self.assertEqual(exception.EntityNotFound, ex.exc_info[0])
|
||||||
mock_load.assert_called_once_with(self.ctx, "nonexistent")
|
mock_load.assert_called_once_with(self.ctx, "nonexistent")
|
||||||
|
|
|
@ -479,8 +479,8 @@ class CeilometerAlarmTest(common.HeatTestCase):
|
||||||
|
|
||||||
wr = mock.MagicMock()
|
wr = mock.MagicMock()
|
||||||
self.patchobject(watchrule.WatchRule, 'load',
|
self.patchobject(watchrule.WatchRule, 'load',
|
||||||
side_effect=[exception.WatchRuleNotFound(
|
side_effect=[exception.EntityNotFound(
|
||||||
watch_name='test')])
|
entity='Watch Rule', name='test')])
|
||||||
wr.destroy.return_value = None
|
wr.destroy.return_value = None
|
||||||
|
|
||||||
self.patchobject(ceilometer.CeilometerClientPlugin, 'client',
|
self.patchobject(ceilometer.CeilometerClientPlugin, 'client',
|
||||||
|
@ -511,7 +511,7 @@ class CeilometerAlarmTest(common.HeatTestCase):
|
||||||
@mock.patch.object(alarm.watchrule.WatchRule, 'load')
|
@mock.patch.object(alarm.watchrule.WatchRule, 'load')
|
||||||
def test_check_watchrule_failure(self, mock_load):
|
def test_check_watchrule_failure(self, mock_load):
|
||||||
res = self._prepare_check_resource()
|
res = self._prepare_check_resource()
|
||||||
exc = alarm.exception.WatchRuleNotFound(watch_name='Boom')
|
exc = alarm.exception.EntityNotFound(entity='Watch Rule', name='Boom')
|
||||||
mock_load.side_effect = exc
|
mock_load.side_effect = exc
|
||||||
|
|
||||||
self.assertRaises(exception.ResourceFailure,
|
self.assertRaises(exception.ResourceFailure,
|
||||||
|
|
|
@ -89,7 +89,8 @@ class CloudWatchAlarmTest(common.HeatTestCase):
|
||||||
watch_name=res_name)
|
watch_name=res_name)
|
||||||
|
|
||||||
with mock.patch.object(watchrule.WatchRule, 'destroy') as bad_destroy:
|
with mock.patch.object(watchrule.WatchRule, 'destroy') as bad_destroy:
|
||||||
watch_exc = exception.WatchRuleNotFound(watch_name='test')
|
watch_exc = exception.EntityNotFound(entity='Watch Rule',
|
||||||
|
name='test')
|
||||||
bad_destroy.side_effect = watch_exc
|
bad_destroy.side_effect = watch_exc
|
||||||
self.assertIsNone(scheduler.TaskRunner(s['test_me'].delete)())
|
self.assertIsNone(scheduler.TaskRunner(s['test_me'].delete)())
|
||||||
|
|
||||||
|
@ -107,7 +108,8 @@ class CloudWatchAlarmTest(common.HeatTestCase):
|
||||||
@mock.patch.object(cloud_watch.watchrule.WatchRule, 'load')
|
@mock.patch.object(cloud_watch.watchrule.WatchRule, 'load')
|
||||||
def test_check_fail(self, mock_load):
|
def test_check_fail(self, mock_load):
|
||||||
res = self._get_watch_rule()
|
res = self._get_watch_rule()
|
||||||
exc = cloud_watch.exception.WatchRuleNotFound(watch_name='Boom')
|
exc = cloud_watch.exception.EntityNotFound(entity='Watch Rule',
|
||||||
|
name='Boom')
|
||||||
mock_load.side_effect = exc
|
mock_load.side_effect = exc
|
||||||
|
|
||||||
self.assertRaises(exception.ResourceFailure,
|
self.assertRaises(exception.ResourceFailure,
|
||||||
|
|
|
@ -887,10 +887,11 @@ class WatchRuleTest(common.HeatTestCase):
|
||||||
|
|
||||||
# Test
|
# Test
|
||||||
wr.destroy()
|
wr.destroy()
|
||||||
self.assertRaises(exception.WatchRuleNotFound,
|
ex = self.assertRaises(exception.EntityNotFound,
|
||||||
watchrule.WatchRule.load,
|
watchrule.WatchRule.load,
|
||||||
context=self.ctx,
|
context=self.ctx,
|
||||||
watch_name='testwatch_destroy')
|
watch_name='testwatch_destroy')
|
||||||
|
self.assertEqual('Watch Rule', ex.kwargs.get('entity'))
|
||||||
|
|
||||||
def test_state_set(self):
|
def test_state_set(self):
|
||||||
# Setup
|
# Setup
|
||||||
|
|
Loading…
Reference in New Issue