diff --git a/heat/common/exception.py b/heat/common/exception.py index f5ad141554..cc3f432feb 100644 --- a/heat/common/exception.py +++ b/heat/common/exception.py @@ -215,6 +215,7 @@ class ResourceNotAvailable(HeatException): class WatchRuleNotFound(HeatException): + '''Keep this for AWS compatiblility.''' msg_fmt = _("The Watch Rule (%(watch_name)s) could not be found.") diff --git a/heat/engine/resources/openstack/ceilometer/alarm.py b/heat/engine/resources/openstack/ceilometer/alarm.py index 3fc2adb82f..88edd3c427 100644 --- a/heat/engine/resources/openstack/ceilometer/alarm.py +++ b/heat/engine/resources/openstack/ceilometer/alarm.py @@ -369,7 +369,7 @@ class CeilometerAlarm(resource.Resource): wr = watchrule.WatchRule.load( self.context, watch_name=self.physical_resource_name()) wr.destroy() - except exception.WatchRuleNotFound: + except exception.EntityNotFound: pass return super(CeilometerAlarm, self).handle_delete() diff --git a/heat/engine/resources/openstack/heat/cloud_watch.py b/heat/engine/resources/openstack/heat/cloud_watch.py index bf6ca136c7..f8d8dc63dc 100644 --- a/heat/engine/resources/openstack/heat/cloud_watch.py +++ b/heat/engine/resources/openstack/heat/cloud_watch.py @@ -176,7 +176,7 @@ class CloudWatchAlarm(resource.Resource): wr = watchrule.WatchRule.load( self.context, watch_name=self.physical_resource_name()) wr.destroy() - except exception.WatchRuleNotFound: + except exception.EntityNotFound: pass def handle_suspend(self): diff --git a/heat/engine/service.py b/heat/engine/service.py index 074609d346..52dc792700 100644 --- a/heat/engine/service.py +++ b/heat/engine/service.py @@ -1662,7 +1662,8 @@ class EngineService(service.Service): if not rule_run: if watch_name is None: watch_name = 'Unknown' - raise exception.WatchRuleNotFound(watch_name=watch_name) + raise exception.EntityNotFound(entity='Watch Rule', + name=watch_name) return stats_data diff --git a/heat/engine/watchrule.py b/heat/engine/watchrule.py index 29d1e5b205..cb6920a714 100644 --- a/heat/engine/watchrule.py +++ b/heat/engine/watchrule.py @@ -88,7 +88,8 @@ class WatchRule(object): LOG.warn(_LW('WatchRule.load (%(watch_name)s) db error ' '%(ex)s'), {'watch_name': watch_name, 'ex': ex}) if watch is None: - raise exception.WatchRuleNotFound(watch_name=watch_name) + raise exception.EntityNotFound(entity='Watch Rule', + name=watch_name) else: return cls(context=context, watch_name=watch.name, diff --git a/heat/tests/engine/service/test_stack_watch.py b/heat/tests/engine/service/test_stack_watch.py index 614ef0cb33..c47963ca34 100644 --- a/heat/tests/engine/service/test_stack_watch.py +++ b/heat/tests/engine/service/test_stack_watch.py @@ -106,7 +106,7 @@ class StackWatchTest(common.HeatTestCase): ex = self.assertRaises(dispatcher.ExpectedException, self.eng.show_watch, 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 for key in rpc_api.WATCH_KEYS: @@ -255,11 +255,12 @@ class StackWatchTest(common.HeatTestCase): @mock.patch.object(watchrule.WatchRule, 'load') def test_set_watch_state_noexist(self, mock_load): 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, self.eng.set_watch_state, self.ctx, watch_name="nonexistent", 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") diff --git a/heat/tests/openstack/ceilometer/test_ceilometer_alarm.py b/heat/tests/openstack/ceilometer/test_ceilometer_alarm.py index afe63895b0..ba4e67d303 100644 --- a/heat/tests/openstack/ceilometer/test_ceilometer_alarm.py +++ b/heat/tests/openstack/ceilometer/test_ceilometer_alarm.py @@ -479,8 +479,8 @@ class CeilometerAlarmTest(common.HeatTestCase): wr = mock.MagicMock() self.patchobject(watchrule.WatchRule, 'load', - side_effect=[exception.WatchRuleNotFound( - watch_name='test')]) + side_effect=[exception.EntityNotFound( + entity='Watch Rule', name='test')]) wr.destroy.return_value = None self.patchobject(ceilometer.CeilometerClientPlugin, 'client', @@ -511,7 +511,7 @@ class CeilometerAlarmTest(common.HeatTestCase): @mock.patch.object(alarm.watchrule.WatchRule, 'load') def test_check_watchrule_failure(self, mock_load): 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 self.assertRaises(exception.ResourceFailure, diff --git a/heat/tests/openstack/heat/test_cloudwatch.py b/heat/tests/openstack/heat/test_cloudwatch.py index 875c0aaff7..610bbabcaa 100644 --- a/heat/tests/openstack/heat/test_cloudwatch.py +++ b/heat/tests/openstack/heat/test_cloudwatch.py @@ -89,7 +89,8 @@ class CloudWatchAlarmTest(common.HeatTestCase): watch_name=res_name) 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 self.assertIsNone(scheduler.TaskRunner(s['test_me'].delete)()) @@ -107,7 +108,8 @@ class CloudWatchAlarmTest(common.HeatTestCase): @mock.patch.object(cloud_watch.watchrule.WatchRule, 'load') def test_check_fail(self, mock_load): 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 self.assertRaises(exception.ResourceFailure, diff --git a/heat/tests/test_watch.py b/heat/tests/test_watch.py index 93ca07358a..fa4f3556db 100644 --- a/heat/tests/test_watch.py +++ b/heat/tests/test_watch.py @@ -887,10 +887,11 @@ class WatchRuleTest(common.HeatTestCase): # Test wr.destroy() - self.assertRaises(exception.WatchRuleNotFound, - watchrule.WatchRule.load, - context=self.ctx, - watch_name='testwatch_destroy') + ex = self.assertRaises(exception.EntityNotFound, + watchrule.WatchRule.load, + context=self.ctx, + watch_name='testwatch_destroy') + self.assertEqual('Watch Rule', ex.kwargs.get('entity')) def test_state_set(self): # Setup