3fb8722012
The Stack._find_filtered_resources() method returns Resource objects for all resources associated with the Stack, regardless of whether they are current (present in the template; latest version in the case of convergence). To do this, it previously created a new Resource object for every resource found in the database. However, for those resources which *are* current this is unnecessary. We can access the Resource object simply through self.resources. It turns out this is necessary for obtaining the required_by list for legacy stacks, because only the Resources obtained from self.resources also appear in the Dependencies graph obtained from self.dependencies. The required_by list is read when listing or showing resources, which would either return an empty list or fail for legacy stacks. This patch also makes the Resource.required_by() method more robust in its error handling. Change-Id: Id438336e5c88dc7c2d168ba01ee703faa17e8b8e Closes-Bug: #1703703 Related-Bug: #1523748 (cherry picked from commit5ce238fb17
and65630d4e8b
)
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
#
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
# License for the specific language governing permissions and limitations
|
|
# under the License.
|
|
|
|
from heat_integrationtests.functional import functional_base
|
|
|
|
|
|
test_template_depend = {
|
|
'heat_template_version': '2013-05-23',
|
|
'resources': {
|
|
'test1': {
|
|
'type': 'OS::Heat::TestResource',
|
|
'properties': {
|
|
'value': 'Test1',
|
|
}
|
|
},
|
|
'test2': {
|
|
'type': 'OS::Heat::TestResource',
|
|
'depends_on': ['test1'],
|
|
'properties': {
|
|
'value': 'Test2',
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
class ResourcesList(functional_base.FunctionalTestsBase):
|
|
|
|
def test_filtering_with_depend(self):
|
|
stack_identifier = self.stack_create(template=test_template_depend)
|
|
[test2] = self.client.resources.list(stack_identifier,
|
|
filters={'name': 'test2'})
|
|
|
|
self.assertEqual('CREATE_COMPLETE', test2.resource_status)
|
|
|
|
def test_required_by(self):
|
|
stack_identifier = self.stack_create(template=test_template_depend)
|
|
[test1] = self.client.resources.list(stack_identifier,
|
|
filters={'name': 'test1'})
|
|
|
|
self.assertEqual(['test2'], test1.required_by)
|