<div dir="ltr"><div dir="ltr"><div dir="ltr">On Mon, Feb 11, 2019 at 9:23 PM NANTHINI A A <<a href="mailto:nanthini.a.a@ericsson.com">nanthini.a.a@ericsson.com</a>> wrote:<br></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi ,<br>
I have tried the below .But getting error .Please let me know how I can proceed further .<br>
<br>
root@cic-1:~# cat try1.yaml <br>
heat_template_version: 2013-05-23<br>
description:<br>
This is the template for I&V R6.1 base configuration to create neutron resources other than sg and vm for vyos vms<br>
parameters:<br>
resource_name_map:<br>
- network1: NetworkA1<br>
network2: NetworkA2<br>
- network1: NetworkB1<br>
network2: NetworkB2<br>
<br>
resources:<br>
neutron_Network_1:<br>
type: OS::Neutron::Net<br>
properties:<br>
name: {get_param: [resource_name_map, %index%, network1]}<br>
</blockquote><div><br></div><div>I don't think you can use %index% directly in this template. You have to pass it as resource property from tryreapet.yaml. Please check the example[1] in heat-templates repo (resource_group_index_lookup.yaml and random.yaml).<br></div><div><br></div><div>[1] <a href="https://github.com/openstack/heat-templates/blob/master/hot/resource_group/resource_group_index_lookup.yaml">https://github.com/openstack/heat-templates/blob/master/hot/resource_group/resource_group_index_lookup.yaml</a><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> neutron_Network_2:<br>
type: OS::Neutron::Net<br>
properties:<br>
name: {get_param: [resource_name_map, %index%, network2]}<br>
root@cic-1:~# cat tryrepeat.yaml <br>
<br>
heat_template_version: 2013-05-23<br>
<br>
resources:<br>
rg:<br>
type: OS::Heat::ResourceGroup<br>
properties:<br>
count: 2<br>
resource_def: <br>
type: try1.yaml<br>
root@cic-1:~#<br>
<br>
root@cic-1:~# heat stack-create tests -f tryrepeat.yaml <br>
WARNING (shell) "heat stack-create" is deprecated, please use "openstack stack create" instead<br>
ERROR: resources.rg<nested_stack>: : Error parsing template file:///root/try1.yaml while scanning for the next token<br>
found character '%' that cannot start any token<br>
in "<unicode string>", line 15, column 45:<br>
... {get_param: [resource_name_map, %index%, network1]}<br>
<br>
<br>
<br>
Thanks in advance .<br>
<br>
<br>
Thanks,<br>
A.Nanthini<br>
-----Original Message-----<br>
From: Harald Jensås [mailto:<a href="mailto:hjensas@redhat.com" target="_blank">hjensas@redhat.com</a>] <br>
Sent: Monday, February 11, 2019 7:47 PM<br>
To: NANTHINI A A <<a href="mailto:nanthini.a.a@ericsson.com" target="_blank">nanthini.a.a@ericsson.com</a>>; <a href="mailto:openstack-dev@lists.openstack.org" target="_blank">openstack-dev@lists.openstack.org</a><br>
Subject: Re: [Heat] Reg accessing variables of resource group heat api<br>
<br>
On Wed, 2019-02-06 at 06:12 +0000, NANTHINI A A wrote:<br>
> Hi ,<br>
> We are developing heat templates for our vnf deployment .It <br>
> includes multiple resources .We want to repeat the resource and hence <br>
> used the api RESOURCE GROUP .<br>
> Attached are the templates which we used<br>
> <br>
> Set1.yaml -> has the resources we want to repeat Setrepeat.yaml -> has <br>
> the resource group api with count .<br>
> <br>
> We want to access the variables of resource in set1.yaml while <br>
> repeating it with count .Eg . port name ,port fixed ip address we want <br>
> to change in each set .<br>
> Please let us know how we can have a variable with each repeated <br>
> resource .<br>
> <br>
<br>
Sounds like you want to use the index_var variable[1] to prefix/suffix reource names?<br>
<br>
I.e in set1.yaml you can use:<br>
<br>
name: <br>
list_join:<br>
- '_'<br>
- {get_param: 'OS::stack_name'}<br>
- %index%<br>
- <resource_name><br>
<br>
<br>
The example should resulting in something like:<br>
stack_0_Network3, stack_0_Subnet3<br>
stack_1_Network0, stack_1_Subnet0<br>
[ ... ]<br>
<br>
<br>
If you want to be more advanced you could use a list parameter in the set1.yaml template, and have each list entry contain a dictionaly of each resource name. The %index% variable would then be used to pick the correct entry from the list.<br>
<br>
<br>
parameters:<br>
resource_name_map:<br>
- network1: foo_custom_name_net1<br>
network2: foo_custom_name_net2<br>
- network1: bar_custom_name_net1<br>
network2: bar_custom_name_net2 - <br>
<br>
resources:<br>
neutron_Network_1:<br>
type: OS::Neutron::Net<br>
properties:<br>
name: {get_param: [resource_name_map, %index%, network1]}<br>
neutron_Network_2:<br>
type: OS::Neutron::Net<br>
properties:<br>
name: {get_param: [resource_name_map, %index%, network2]}<br>
<br>
<br>
%index% is the "count" picking the 'foo' entries when %index% is 0, and 'bar' entries when %index% is 1 and so on.<br>
<br>
<br>
<br>
<br>
<br>
[1]<br>
<a href="https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Heat::ResourceGroup-props-opt" rel="noreferrer" target="_blank">https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Heat::ResourceGroup-props-opt</a><br>
<br>
<br>
<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div>Regards,</div>Rabi Mishra<div><br></div></div></div></div></div></div></div>