Merge "Resolve all functions before RESOLVE translation"
This commit is contained in:
commit
0792da16d0
|
@ -321,8 +321,6 @@ class TranslationRule(object):
|
|||
def _exec_resolve(self, translation_key, translation_data):
|
||||
|
||||
def resolve_and_find(translation_value):
|
||||
if isinstance(translation_value, hot_funcs.GetResource):
|
||||
return
|
||||
if isinstance(translation_value, function.Function):
|
||||
translation_value = function.resolve(translation_value)
|
||||
if translation_value:
|
||||
|
@ -333,10 +331,9 @@ class TranslationRule(object):
|
|||
return resolved_value
|
||||
finder = getattr(self.client_plugin, self.finder)
|
||||
if self.entity:
|
||||
value = finder(self.entity, translation_value)
|
||||
return finder(self.entity, translation_value)
|
||||
else:
|
||||
value = finder(translation_value)
|
||||
return value
|
||||
return finder(translation_value)
|
||||
|
||||
if isinstance(translation_data, list):
|
||||
for item in translation_data:
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
# under the License.
|
||||
|
||||
import copy
|
||||
import mox
|
||||
from neutronclient.common import exceptions as qe
|
||||
from neutronclient.neutron import v2_0 as neutronV20
|
||||
from neutronclient.v2_0 import client as neutronclient
|
||||
|
@ -105,9 +104,10 @@ class NeutronSubnetTest(common.HeatTestCase):
|
|||
self.m.StubOutWithMock(neutronclient.Client, 'delete_subnet')
|
||||
self.m.StubOutWithMock(neutronclient.Client, 'show_subnet')
|
||||
self.m.StubOutWithMock(neutronclient.Client, 'update_subnet')
|
||||
self.m.StubOutWithMock(neutronV20, 'find_resourceid_by_name_or_id')
|
||||
self.patchobject(neutron.NeutronClientPlugin, 'has_extension',
|
||||
return_value=True)
|
||||
self.patchobject(neutronV20, 'find_resourceid_by_name_or_id',
|
||||
return_value='fc68ea2c-b60b-4b4f-bd82-94ec81110766')
|
||||
|
||||
def create_subnet(self, t, stack, resource_name):
|
||||
resource_defns = stack.t.resource_definitions(stack)
|
||||
|
@ -251,12 +251,6 @@ class NeutronSubnetTest(common.HeatTestCase):
|
|||
"tenant_id": "c1210485b2424d48804aad5d39c61b8f"
|
||||
}
|
||||
}
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
mox.IsA(neutronclient.Client),
|
||||
'subnetpool',
|
||||
'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
|
||||
cmd_resource=None,
|
||||
).MultipleTimes().AndReturn('fc68ea2c-b60b-4b4f-bd82-94ec81110766')
|
||||
neutronclient.Client.create_subnet({
|
||||
'subnet': {
|
||||
'network_id': 'fc68ea2c-b60b-4b4f-bd82-94ec81110766',
|
||||
|
@ -640,13 +634,9 @@ class NeutronSubnetTest(common.HeatTestCase):
|
|||
"supported for ipv4.", six.text_type(ex))
|
||||
|
||||
def test_validate_both_subnetpool_cidr(self):
|
||||
neutronV20.find_resourceid_by_name_or_id(
|
||||
mox.IsA(neutronclient.Client),
|
||||
'subnetpool',
|
||||
'new_pool',
|
||||
cmd_resource=None,
|
||||
).AndReturn('new_pool')
|
||||
self.m.ReplayAll()
|
||||
self.patchobject(neutronV20, 'find_resourceid_by_name_or_id',
|
||||
return_value='new_pool')
|
||||
|
||||
t = template_format.parse(neutron_template)
|
||||
props = t['resources']['sub_net']['properties']
|
||||
props['subnetpool'] = 'new_pool'
|
||||
|
|
|
@ -538,6 +538,9 @@ class TestTranslationRule(common.HeatTestCase):
|
|||
class rsrc(object):
|
||||
action = INIT = "INIT"
|
||||
|
||||
def FnGetRefId(self):
|
||||
return 'resource_id'
|
||||
|
||||
class DummyStack(dict):
|
||||
pass
|
||||
|
||||
|
@ -616,6 +619,9 @@ class TestTranslationRule(common.HeatTestCase):
|
|||
class rsrc(object):
|
||||
action = INIT = "INIT"
|
||||
|
||||
def FnGetRefId(self):
|
||||
return 'resource_id'
|
||||
|
||||
class DummyStack(dict):
|
||||
pass
|
||||
|
||||
|
|
|
@ -33,6 +33,26 @@ outputs:
|
|||
value: {get_attr: [subnet, gateway_ip]}
|
||||
'''
|
||||
|
||||
test_template_with_translation = '''
|
||||
heat_template_version: 2016-10-14
|
||||
description: Test template to create/update subnet with translation
|
||||
parameters:
|
||||
net_cidr:
|
||||
type: string
|
||||
resources:
|
||||
net:
|
||||
type: OS::Neutron::Net
|
||||
net_value:
|
||||
type: OS::Heat::Value
|
||||
properties:
|
||||
value: {get_resource: net}
|
||||
subnet:
|
||||
type: OS::Neutron::Subnet
|
||||
properties:
|
||||
network: { get_attr: [net_value, value] }
|
||||
cidr: {get_param: net_cidr}
|
||||
'''
|
||||
|
||||
|
||||
class UpdateSubnetTest(functional_base.FunctionalTestsBase):
|
||||
|
||||
|
@ -125,3 +145,14 @@ class UpdateSubnetTest(functional_base.FunctionalTestsBase):
|
|||
new_gw_ip = self.get_outputs(stack_identifier, 'gateway_ip')
|
||||
# new gateway_ip should be None
|
||||
self.assertIsNone(new_gw_ip)
|
||||
|
||||
def test_update_with_network_translation(self):
|
||||
# Just create and update where network is translated properly.
|
||||
env = {'parameters': {'net_cidr': '11.11.11.0/24'}}
|
||||
stack_identifier = self.stack_create(
|
||||
template=test_template_with_translation,
|
||||
environment=env)
|
||||
env = {'parameters': {'net_cidr': '11.11.12.0/24'}}
|
||||
self.update_stack(stack_identifier,
|
||||
template=test_template_with_translation,
|
||||
environment=env)
|
||||
|
|
Loading…
Reference in New Issue