Convergence: Fix to use cache_data for FnGetRefId (3)
Closes-Bug: #1492116 Change-Id: I67cb2cad783a31e76804a48e16eef7f3ef2eb84d
This commit is contained in:
parent
6908e824cd
commit
dfda438c63
|
@ -1510,7 +1510,7 @@ class Resource(object):
|
|||
if res_name is not None:
|
||||
return six.text_type(res_name)
|
||||
else:
|
||||
return Resource.FnGetRefId(self)
|
||||
return Resource.get_reference_id(self)
|
||||
|
||||
def FnGetAtt(self, key, *path):
|
||||
"""For the intrinsic function Fn::GetAtt.
|
||||
|
|
|
@ -230,7 +230,7 @@ class LaunchConfiguration(resource.Resource):
|
|||
|
||||
return result
|
||||
|
||||
def FnGetRefId(self):
|
||||
def get_reference_id(self):
|
||||
return self.physical_resource_name_or_FnGetRefId()
|
||||
|
||||
def validate(self):
|
||||
|
|
|
@ -227,7 +227,7 @@ class ElasticIpAssociation(resource.Resource):
|
|||
|
||||
default_client_name = 'nova'
|
||||
|
||||
def FnGetRefId(self):
|
||||
def get_reference_id(self):
|
||||
return self.physical_resource_name_or_FnGetRefId()
|
||||
|
||||
def validate(self):
|
||||
|
|
|
@ -414,9 +414,9 @@ class SecurityGroup(resource.Resource):
|
|||
impl = NovaSecurityGroup
|
||||
impl(self).delete()
|
||||
|
||||
def FnGetRefId(self):
|
||||
def get_reference_id(self):
|
||||
if self.is_using_neutron():
|
||||
return super(SecurityGroup, self).FnGetRefId()
|
||||
return super(SecurityGroup, self).get_reference_id()
|
||||
else:
|
||||
return self.physical_resource_name()
|
||||
|
||||
|
|
|
@ -114,7 +114,7 @@ class User(stack_user.StackUser):
|
|||
super(User, self).handle_create()
|
||||
self.resource_id_set(self._get_user_id())
|
||||
|
||||
def FnGetRefId(self):
|
||||
def get_reference_id(self):
|
||||
return self.physical_resource_name_or_FnGetRefId()
|
||||
|
||||
def access_allowed(self, resource_name):
|
||||
|
|
|
@ -194,7 +194,7 @@ class CloudWatchAlarm(resource.Resource):
|
|||
watch_name = self.physical_resource_name()
|
||||
watchrule.WatchRule.load(self.context, watch_name=watch_name)
|
||||
|
||||
def FnGetRefId(self):
|
||||
def get_reference_id(self):
|
||||
return self.physical_resource_name_or_FnGetRefId()
|
||||
|
||||
def physical_resource_name(self):
|
||||
|
|
|
@ -376,7 +376,7 @@ class InstanceGroup(stack_resource.StackResource):
|
|||
lb_dict = dict((name, self.stack[name]) for name in lb_names)
|
||||
lbutils.reload_loadbalancers(self, lb_dict, exclude)
|
||||
|
||||
def FnGetRefId(self):
|
||||
def get_reference_id(self):
|
||||
return self.physical_resource_name_or_FnGetRefId()
|
||||
|
||||
def _resolve_attribute(self, name):
|
||||
|
|
|
@ -196,8 +196,8 @@ class AutoScalingPolicy(signal_responder.SignalResponder,
|
|||
elif name == self.SIGNAL_URL:
|
||||
return six.text_type(self._get_heat_signal_url())
|
||||
|
||||
def FnGetRefId(self):
|
||||
return resource.Resource.FnGetRefId(self)
|
||||
def get_reference_id(self):
|
||||
return resource.Resource.get_reference_id(self)
|
||||
|
||||
|
||||
def resource_mapping():
|
||||
|
|
|
@ -124,7 +124,7 @@ class NovaFloatingIpAssociation(resource.Resource):
|
|||
|
||||
default_client_name = 'nova'
|
||||
|
||||
def FnGetRefId(self):
|
||||
def get_reference_id(self):
|
||||
return self.physical_resource_name_or_FnGetRefId()
|
||||
|
||||
def handle_create(self):
|
||||
|
|
|
@ -118,6 +118,26 @@ class TestAutoScalingPolicy(common.HeatTestCase):
|
|||
group.adjust.assert_called_once_with(1, 'change_in_capacity', None,
|
||||
signal=True)
|
||||
|
||||
def test_scaling_policy_refid(self):
|
||||
t = template_format.parse(as_template)
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc = stack['my-policy']
|
||||
rsrc.resource_id = 'xyz'
|
||||
self.assertEqual('xyz', rsrc.FnGetRefId())
|
||||
|
||||
def test_scaling_policy_refid_convg_cache_data(self):
|
||||
t = template_format.parse(as_template)
|
||||
cache_data = {'my-policy': {
|
||||
'uuid': mock.ANY,
|
||||
'id': mock.ANY,
|
||||
'action': 'CREATE',
|
||||
'status': 'COMPLETE',
|
||||
'reference_id': 'convg_xyz'
|
||||
}}
|
||||
stack = utils.parse_stack(t, cache_data=cache_data)
|
||||
rsrc = stack['my-policy']
|
||||
self.assertEqual('convg_xyz', rsrc.FnGetRefId())
|
||||
|
||||
|
||||
class TestCooldownMixin(common.HeatTestCase):
|
||||
def setUp(self):
|
||||
|
|
|
@ -61,6 +61,20 @@ class LaunchConfigurationTest(common.HeatTestCase):
|
|||
self.assertIsNone(rsrc.resource_id)
|
||||
self.assertEqual('LaunchConfig', rsrc.FnGetRefId())
|
||||
|
||||
def test_launch_config_refid_convergence_cache_data(self):
|
||||
t = template_format.parse(inline_templates.as_template)
|
||||
cache_data = {'LaunchConfig': {
|
||||
'uuid': mock.ANY,
|
||||
'id': mock.ANY,
|
||||
'action': 'CREATE',
|
||||
'status': 'COMPLETE',
|
||||
'reference_id': 'convg_xyz'
|
||||
}}
|
||||
stack = utils.parse_stack(t, params=inline_templates.as_params,
|
||||
cache_data=cache_data)
|
||||
rsrc = stack['LaunchConfig']
|
||||
self.assertEqual('convg_xyz', rsrc.FnGetRefId())
|
||||
|
||||
def test_launch_config_create_with_instanceid(self):
|
||||
t = template_format.parse(inline_templates.as_template)
|
||||
lcp = t['Resources']['LaunchConfig']['Properties']
|
||||
|
|
|
@ -20,6 +20,7 @@ from novaclient import exceptions as nova_exceptions
|
|||
import six
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import short_id
|
||||
from heat.common import template_format
|
||||
from heat.engine.clients.os import nova
|
||||
from heat.engine.resources.aws.ec2 import eip
|
||||
|
@ -918,3 +919,35 @@ class AllocTest(common.HeatTestCase):
|
|||
self.assertEqual((ass.UPDATE, ass.COMPLETE), ass.state)
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_eip_allocation_refid_resource_name(self):
|
||||
t = template_format.parse(eip_template_ipassoc)
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc = stack['IPAssoc']
|
||||
rsrc.id = '123'
|
||||
rsrc.uuid = '9bfb9456-3fe8-41f4-b318-9dba18eeef74'
|
||||
rsrc.action = 'CREATE'
|
||||
expected = '%s-%s-%s' % (rsrc.stack.name,
|
||||
rsrc.name,
|
||||
short_id.get_id(rsrc.uuid))
|
||||
self.assertEqual(expected, rsrc.FnGetRefId())
|
||||
|
||||
def test_eip_allocation_refid_resource_id(self):
|
||||
t = template_format.parse(eip_template_ipassoc)
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc = stack['IPAssoc']
|
||||
rsrc.resource_id = 'phy-rsrc-id'
|
||||
self.assertEqual('phy-rsrc-id', rsrc.FnGetRefId())
|
||||
|
||||
def test_eip_allocation_refid_convergence_cache_data(self):
|
||||
t = template_format.parse(eip_template_ipassoc)
|
||||
cache_data = {'IPAssoc': {
|
||||
'uuid': mock.ANY,
|
||||
'id': mock.ANY,
|
||||
'action': 'CREATE',
|
||||
'status': 'COMPLETE',
|
||||
'reference_id': 'convg_xyz'
|
||||
}}
|
||||
stack = utils.parse_stack(t, cache_data=cache_data)
|
||||
rsrc = stack['IPAssoc']
|
||||
self.assertEqual('convg_xyz', rsrc.FnGetRefId())
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
import collections
|
||||
import copy
|
||||
import mock
|
||||
|
||||
from keystoneclient import exceptions as keystone_exc
|
||||
from neutronclient.common import exceptions as neutron_exc
|
||||
|
@ -21,8 +22,10 @@ from novaclient.v2 import security_group_rules as nova_sgr
|
|||
from novaclient.v2 import security_groups as nova_sg
|
||||
|
||||
from heat.common import exception
|
||||
from heat.common import short_id
|
||||
from heat.common import template_format
|
||||
from heat.engine.clients.os import nova
|
||||
from heat.engine.resources.aws.ec2 import security_group
|
||||
from heat.engine import rsrc_defn
|
||||
from heat.engine import scheduler
|
||||
from heat.engine import stack as parser
|
||||
|
@ -1075,3 +1078,39 @@ Resources:
|
|||
self.assertEqual((sg.UPDATE, sg.COMPLETE), sg.state)
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
@mock.patch.object(security_group.SecurityGroup, 'is_using_neutron')
|
||||
def test_security_group_refid_rsrc_name(self, mock_using_neutron):
|
||||
mock_using_neutron.return_value = False
|
||||
t = template_format.parse(self.test_template_nova)
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc = stack['the_sg']
|
||||
rsrc.id = '123'
|
||||
rsrc.uuid = '9bfb9456-3fe8-41f4-b318-9dba18eeef74'
|
||||
rsrc.action = 'CREATE'
|
||||
expected = '%s-%s-%s' % (rsrc.stack.name,
|
||||
rsrc.name,
|
||||
short_id.get_id(rsrc.uuid))
|
||||
self.assertEqual(expected, rsrc.FnGetRefId())
|
||||
|
||||
@mock.patch.object(security_group.SecurityGroup, 'is_using_neutron')
|
||||
def test_security_group_refid_rsrc_id(self, mock_using_neutron):
|
||||
mock_using_neutron.return_value = True
|
||||
t = template_format.parse(self.test_template_nova)
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc = stack['the_sg']
|
||||
rsrc.resource_id = 'phy-rsrc-id'
|
||||
self.assertEqual('phy-rsrc-id', rsrc.FnGetRefId())
|
||||
|
||||
def test_security_group_refid_convg_cache_data(self):
|
||||
t = template_format.parse(self.test_template_nova)
|
||||
cache_data = {'the_sg': {
|
||||
'uuid': mock.ANY,
|
||||
'id': mock.ANY,
|
||||
'action': 'CREATE',
|
||||
'status': 'COMPLETE',
|
||||
'reference_id': 'convg_xyz'
|
||||
}}
|
||||
stack = utils.parse_stack(t, cache_data=cache_data)
|
||||
rsrc = stack['the_sg']
|
||||
self.assertEqual('convg_xyz', rsrc.FnGetRefId())
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import mock
|
||||
from oslo_config import cfg
|
||||
import six
|
||||
|
||||
|
@ -273,6 +274,26 @@ class UserTest(common.HeatTestCase):
|
|||
self.assertFalse(rsrc.access_allowed('b_resource'))
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_user_refid_rsrc_id(self):
|
||||
t = template_format.parse(user_template)
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc = stack['CfnUser']
|
||||
rsrc.resource_id = 'phy-rsrc-id'
|
||||
self.assertEqual('phy-rsrc-id', rsrc.FnGetRefId())
|
||||
|
||||
def test_user_refid_convg_cache_data(self):
|
||||
t = template_format.parse(user_template)
|
||||
cache_data = {'CfnUser': {
|
||||
'uuid': mock.ANY,
|
||||
'id': mock.ANY,
|
||||
'action': 'CREATE',
|
||||
'status': 'COMPLETE',
|
||||
'reference_id': 'convg_xyz'
|
||||
}}
|
||||
stack = utils.parse_stack(t, cache_data=cache_data)
|
||||
rsrc = stack['CfnUser']
|
||||
self.assertEqual('convg_xyz', rsrc.FnGetRefId())
|
||||
|
||||
|
||||
class AccessKeyTest(common.HeatTestCase):
|
||||
def setUp(self):
|
||||
|
|
|
@ -17,6 +17,7 @@ import mock
|
|||
import six
|
||||
|
||||
from heat.common import exception as heat_ex
|
||||
from heat.common import short_id
|
||||
from heat.common import template_format
|
||||
from heat.engine.clients.os import nova
|
||||
from heat.engine.resources.openstack.nova import nova_floatingip
|
||||
|
@ -356,3 +357,35 @@ class NovaFloatingIPTest(common.HeatTestCase):
|
|||
self.assertEqual((rsrc.UPDATE, rsrc.COMPLETE), rsrc.state)
|
||||
|
||||
self.m.VerifyAll()
|
||||
|
||||
def test_floating_ip_assoc_refid_rsrc_name(self):
|
||||
t = template_format.parse(floating_ip_template_with_assoc)
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc = stack['MyFloatingIPAssociation']
|
||||
rsrc.id = '123'
|
||||
rsrc.uuid = '9bfb9456-3fe8-41f4-b318-9dba18eeef74'
|
||||
rsrc.action = 'CREATE'
|
||||
expected = '%s-%s-%s' % (rsrc.stack.name,
|
||||
rsrc.name,
|
||||
short_id.get_id(rsrc.uuid))
|
||||
self.assertEqual(expected, rsrc.FnGetRefId())
|
||||
|
||||
def test_floating_ip_assoc_refid_rsrc_id(self):
|
||||
t = template_format.parse(floating_ip_template_with_assoc)
|
||||
stack = utils.parse_stack(t)
|
||||
rsrc = stack['MyFloatingIPAssociation']
|
||||
rsrc.resource_id = 'phy-rsrc-id'
|
||||
self.assertEqual('phy-rsrc-id', rsrc.FnGetRefId())
|
||||
|
||||
def test_floating_ip_assoc_refid_convg_cache_data(self):
|
||||
t = template_format.parse(floating_ip_template_with_assoc)
|
||||
cache_data = {'MyFloatingIPAssociation': {
|
||||
'uuid': mock.ANY,
|
||||
'id': mock.ANY,
|
||||
'action': 'CREATE',
|
||||
'status': 'COMPLETE',
|
||||
'reference_id': 'convg_xyz'
|
||||
}}
|
||||
stack = utils.parse_stack(t, cache_data=cache_data)
|
||||
rsrc = stack['MyFloatingIPAssociation']
|
||||
self.assertEqual('convg_xyz', rsrc.FnGetRefId())
|
||||
|
|
|
@ -18,6 +18,7 @@ import six
|
|||
|
||||
from heat.common import exception
|
||||
from heat.common import grouputils
|
||||
from heat.common import short_id
|
||||
from heat.common import template_format
|
||||
from heat.engine.resources.openstack.heat import instance_group as instgrp
|
||||
from heat.engine import rsrc_defn
|
||||
|
@ -143,6 +144,20 @@ class TestInstanceGroup(common.HeatTestCase):
|
|||
res = self.instance_group._resolve_attribute('InstanceList')
|
||||
self.assertEqual('2.1.3.1,2.1.3.2,2.1.3.3', res)
|
||||
|
||||
def test_instance_group_refid_rsrc_name(self):
|
||||
self.instance_group.id = '123'
|
||||
|
||||
self.instance_group.uuid = '9bfb9456-3fe8-41f4-b318-9dba18eeef74'
|
||||
self.instance_group.action = 'CREATE'
|
||||
expected = '%s-%s-%s' % (self.instance_group.stack.name,
|
||||
self.instance_group.name,
|
||||
short_id.get_id(self.instance_group.uuid))
|
||||
self.assertEqual(expected, self.instance_group.FnGetRefId())
|
||||
|
||||
def test_instance_group_refid_rsrc_id(self):
|
||||
self.instance_group.resource_id = 'phy-rsrc-id'
|
||||
self.assertEqual('phy-rsrc-id', self.instance_group.FnGetRefId())
|
||||
|
||||
|
||||
class TestLaunchConfig(common.HeatTestCase):
|
||||
def create_resource(self, t, stack, resource_name):
|
||||
|
|
Loading…
Reference in New Issue