<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">Hi ,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">   May I know in the following example given
<o:p></o:p></span></p>
<p class="MsoNormal"><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   <o:p></o:p></p>
<p class="MsoNormal">   what is the parameter type ?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
<p class="MsoNormal">A.Nanthini<span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"><o:p> </o:p></span></p>
<p class="MsoNormal"><b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif">From:</span></b><span style="font-size:11.0pt;font-family:"Calibri",sans-serif"> Rabi Mishra [mailto:ramishra@redhat.com]
<br>
<b>Sent:</b> Tuesday, February 12, 2019 10:45 AM<br>
<b>To:</b> NANTHINI A A <nanthini.a.a@ericsson.com><br>
<b>Cc:</b> hjensas@redhat.com; openstack-dev@lists.openstack.org<br>
<b>Subject:</b> Re: [Heat] Reg accessing variables of resource group heat api<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div>
<div>
<p class="MsoNormal">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:<o:p></o:p></p>
</div>
<div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal">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]}<o:p></o:p></p>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">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).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">[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><o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> <o:p></o:p></p>
</div>
<blockquote style="border:none;border-left:solid #CCCCCC 1.0pt;padding:0in 0in 0in 6.0pt;margin-left:4.8pt;margin-right:0in">
<p class="MsoNormal" style="margin-bottom:12.0pt">  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 <a href="file:///root/try1.yaml">
file:///root/try1.yaml</a> 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" target="_blank">https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Heat::ResourceGroup-props-opt</a><br>
<br>
<br>
<o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><br clear="all">
<br>
-- <o:p></o:p></p>
<div>
<div>
<div>
<div>
<div>
<p class="MsoNormal">Regards,<o:p></o:p></p>
</div>
<p class="MsoNormal">Rabi Mishra<o:p></o:p></p>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>