diff --git a/heat/engine/resource.py b/heat/engine/resource.py index b838f0612..57397a8e0 100644 --- a/heat/engine/resource.py +++ b/heat/engine/resource.py @@ -12,7 +12,6 @@ # under the License. import base64 -import copy from datetime import datetime import six @@ -283,39 +282,9 @@ class Resource(object): str(self.stack)) return '%s "%s"' % (self.__class__.__name__, self.name) - def _add_dependencies(self, deps, path, fragment): - if isinstance(fragment, dict): - for key, value in fragment.items(): - if key in ('DependsOn', 'Ref', 'Fn::GetAtt', 'get_attr', - 'get_resource'): - if key in ('Fn::GetAtt', 'get_attr'): - res_name = value[0] - res_list = [res_name] - elif key == 'DependsOn' and isinstance(value, list): - res_list = value - else: - res_list = [value] - - for res in res_list: - try: - target = self.stack[res] - except KeyError: - if (key != 'Ref' or - res not in self.stack.parameters): - raise exception.InvalidTemplateReference( - resource=res, - key=path) - else: - if key == 'DependsOn' or target.strict_dependency: - deps += (self, target) - else: - self._add_dependencies(deps, '%s.%s' % (path, key), value) - elif isinstance(fragment, list): - for index, item in enumerate(fragment): - self._add_dependencies(deps, '%s[%d]' % (path, index), item) - def add_dependencies(self, deps): - self._add_dependencies(deps, self.name, copy.deepcopy(dict(self.t))) + for dep in self.t.dependencies(self.stack): + deps += (self, dep) deps += (self, None) def required_by(self): diff --git a/heat/tests/test_resource.py b/heat/tests/test_resource.py index e742e0b92..4c689be3f 100644 --- a/heat/tests/test_resource.py +++ b/heat/tests/test_resource.py @@ -993,9 +993,8 @@ class ResourceDependenciesTest(HeatTestCase): } }) stack = parser.Stack(utils.dummy_context(), 'test', tmpl) - ex = self.assertRaises(exception.InvalidTemplateReference, - stack.validate) - self.assertIn('"baz" (in bar.Properties.Foo)', str(ex)) + self.assertRaises(exception.StackValidationFailed, + stack.validate) def test_hot_ref_fail(self): tmpl = template.Template({ diff --git a/heat/tests/test_vpc.py b/heat/tests/test_vpc.py index d292ee13c..66ca46d6f 100644 --- a/heat/tests/test_vpc.py +++ b/heat/tests/test_vpc.py @@ -654,15 +654,10 @@ Resources: self.m.VerifyAll() def test_network_interface_error(self): - real_exception = self.assertRaises( - exception.InvalidTemplateReference, + self.assertRaises( + exception.StackValidationFailed, self.create_stack, self.test_template_error) - expected_exception = exception.InvalidTemplateReference( - resource='INVALID-REF-IN-TEMPLATE', - key='the_nic.Properties.GroupSet[0]') - - self.assertEqual(str(expected_exception), str(real_exception)) class InternetGatewayTest(VPCTestBase):