Rename Resource._resolve_all_attributes() method

This confuses me every time I look at it.

Change-Id: Ie26af6dbc43f651abb2faff0941894fd410e665f
changes/06/467806/26
Zane Bitter 5 years ago
parent 960f626c24
commit 2c3824436e
  1. 8
      heat/engine/resource.py
  2. 4
      heat/tests/engine/service/test_stack_resources.py
  3. 4
      heat/tests/engine/service/test_stack_update.py
  4. 6
      heat/tests/openstack/neutron/test_neutron.py
  5. 6
      heat/tests/openstack/nova/test_server.py

@ -2051,11 +2051,11 @@ class Resource(status.ResourceStatus):
else:
self._store_with_lock({}, self.LOCK_RELEASE)
def _resolve_all_attributes(self, attr):
"""Method for resolving all attributes.
def _resolve_any_attribute(self, attr):
"""Method for resolving any attribute, including base attributes.
This method uses basic _resolve_attribute method for resolving
specific attributes. Base attributes will be resolved with
plugin-specific attributes. Base attributes will be resolved with
corresponding method, which should be defined in each resource
class.
@ -2527,5 +2527,5 @@ class Resource(status.ResourceStatus):
res = ref()
if res is None:
raise RuntimeError("Resource collected")
return res._resolve_all_attributes(attr)
return res._resolve_any_attribute(attr)
return resolve

@ -70,8 +70,8 @@ class StackResourcesServiceTest(common.HeatTestCase):
def _test_describe_stack_resource(self, mock_load):
mock_load.return_value = self.stack
# Patch _resolve_all_attributes or it tries to call novaclient
self.patchobject(res.Resource, '_resolve_all_attributes',
# Patch _resolve_any_attribute or it tries to call novaclient
self.patchobject(res.Resource, '_resolve_any_attribute',
return_value=None)
r = self.eng.describe_stack_resource(self.ctx, self.stack.identifier(),

@ -1017,8 +1017,8 @@ resources:
mock_validate = self.patchobject(stk, 'validate', return_value=None)
mock_merge = self.patchobject(env_util, 'merge_environments')
# Patch _resolve_all_attributes or it tries to call novaclient
self.patchobject(resource.Resource, '_resolve_all_attributes',
# Patch _resolve_any_attribute or it tries to call novaclient
self.patchobject(resource.Resource, '_resolve_any_attribute',
return_value=None)
# do preview_update_stack

@ -98,7 +98,7 @@ class NeutronTest(common.HeatTestCase):
{'attr2': attributes.Schema(type=attributes.Schema.STRING)})
res.attributes = attributes.Attributes(res.name,
res.attributes_schema,
res._resolve_all_attributes)
res._resolve_any_attribute)
side_effect = [{'attr1': 'val1', 'attr2': 'val2'},
{'attr1': 'val1', 'attr2': 'val2'},
{'attr1': 'val1', 'attr2': 'val2'},
@ -108,8 +108,8 @@ class NeutronTest(common.HeatTestCase):
self.assertEqual({'attr1': 'val1', 'attr2': 'val2'},
res.FnGetAtt('show'))
self.assertEqual('val2', res.attributes['attr2'])
self.assertRaises(KeyError, res._resolve_all_attributes, 'attr3')
self.assertIsNone(res._resolve_all_attributes('attr1'))
self.assertRaises(KeyError, res._resolve_any_attribute, 'attr3')
self.assertIsNone(res._resolve_any_attribute('attr1'))
res.resource_id = None
# use local cached object for non-show attribute

@ -3189,7 +3189,7 @@ class ServersTest(common.HeatTestCase):
server.resource_id = '1234'
self.patchobject(self.fc.servers, 'get',
side_effect=fakes_nova.fake_exception())
self.assertEqual('', server._resolve_all_attributes("accessIPv4"))
self.assertEqual('', server._resolve_any_attribute("accessIPv4"))
def test_resolve_attribute_console_url(self):
server = self.fc.servers.list()[0]
@ -3200,7 +3200,7 @@ class ServersTest(common.HeatTestCase):
'WebServer', tmpl.resource_definitions(stack)['WebServer'], stack)
ws.resource_id = server.id
self.patchobject(self.fc.servers, 'get', return_value=server)
console_urls = ws._resolve_all_attributes('console_urls')
console_urls = ws._resolve_any_attribute('console_urls')
self.assertIsInstance(console_urls, collections.Mapping)
supported_consoles = ('novnc', 'xvpvnc', 'spice-html5', 'rdp-html5',
'serial', 'webmks')
@ -3221,7 +3221,7 @@ class ServersTest(common.HeatTestCase):
expect_networks = {"fake_uuid": ["10.0.0.3"],
"fake_net": ["10.0.0.3"]}
self.assertEqual(expect_networks,
server._resolve_all_attributes("networks"))
server._resolve_any_attribute("networks"))
def test_empty_instance_user(self):
"""Test Nova server doesn't set instance_user in build_userdata

Loading…
Cancel
Save