[Heat] Reg accessing variables of resource group heat api
Hi , We are developing heat templates for our vnf deployment .It includes multiple resources .We want to repeat the resource and hence used the api RESOURCE GROUP . Attached are the templates which we used Set1.yaml -> has the resources we want to repeat Setrepeat.yaml -> has the resource group api with count . We want to access the variables of resource in set1.yaml while repeating it with count .Eg . port name ,port fixed ip address we want to change in each set . Please let us know how we can have a variable with each repeated resource . Thanks, A.Nanthini
On Wed, 2019-02-06 at 06:12 +0000, NANTHINI A A wrote:
Hi , We are developing heat templates for our vnf deployment .It includes multiple resources .We want to repeat the resource and hence used the api RESOURCE GROUP . Attached are the templates which we used
Set1.yaml -> has the resources we want to repeat Setrepeat.yaml -> has the resource group api with count .
We want to access the variables of resource in set1.yaml while repeating it with count .Eg . port name ,port fixed ip address we want to change in each set . Please let us know how we can have a variable with each repeated resource .
Sounds like you want to use the index_var variable[1] to prefix/suffix reource names? I.e in set1.yaml you can use: name: list_join: - '_' - {get_param: 'OS::stack_name'} - %index% - <resource_name> The example should resulting in something like: stack_0_Network3, stack_0_Subnet3 stack_1_Network0, stack_1_Subnet0 [ ... ] 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. parameters: resource_name_map: - network1: foo_custom_name_net1 network2: foo_custom_name_net2 - network1: bar_custom_name_net1 network2: bar_custom_name_net2 - resources: neutron_Network_1: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network1]} neutron_Network_2: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network2]} %index% is the "count" picking the 'foo' entries when %index% is 0, and 'bar' entries when %index% is 1 and so on. [1] https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Hea...
Hi , I have tried the below .But getting error .Please let me know how I can proceed further . root@cic-1:~# cat try1.yaml heat_template_version: 2013-05-23 description: This is the template for I&V R6.1 base configuration to create neutron resources other than sg and vm for vyos vms parameters: resource_name_map: - network1: NetworkA1 network2: NetworkA2 - network1: NetworkB1 network2: NetworkB2 resources: neutron_Network_1: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network1]} neutron_Network_2: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network2]} root@cic-1:~# cat tryrepeat.yaml heat_template_version: 2013-05-23 resources: rg: type: OS::Heat::ResourceGroup properties: count: 2 resource_def: type: try1.yaml root@cic-1:~# root@cic-1:~# heat stack-create tests -f tryrepeat.yaml WARNING (shell) "heat stack-create" is deprecated, please use "openstack stack create" instead ERROR: resources.rg<nested_stack>: : Error parsing template file:///root/try1.yaml while scanning for the next token found character '%' that cannot start any token in "<unicode string>", line 15, column 45: ... {get_param: [resource_name_map, %index%, network1]} Thanks in advance . Thanks, A.Nanthini -----Original Message----- From: Harald Jensås [mailto:hjensas@redhat.com] Sent: Monday, February 11, 2019 7:47 PM To: NANTHINI A A <nanthini.a.a@ericsson.com>; openstack-dev@lists.openstack.org Subject: Re: [Heat] Reg accessing variables of resource group heat api On Wed, 2019-02-06 at 06:12 +0000, NANTHINI A A wrote:
Hi , We are developing heat templates for our vnf deployment .It includes multiple resources .We want to repeat the resource and hence used the api RESOURCE GROUP . Attached are the templates which we used
Set1.yaml -> has the resources we want to repeat Setrepeat.yaml -> has the resource group api with count .
We want to access the variables of resource in set1.yaml while repeating it with count .Eg . port name ,port fixed ip address we want to change in each set . Please let us know how we can have a variable with each repeated resource .
Sounds like you want to use the index_var variable[1] to prefix/suffix reource names? I.e in set1.yaml you can use: name: list_join: - '_' - {get_param: 'OS::stack_name'} - %index% - <resource_name> The example should resulting in something like: stack_0_Network3, stack_0_Subnet3 stack_1_Network0, stack_1_Subnet0 [ ... ] 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. parameters: resource_name_map: - network1: foo_custom_name_net1 network2: foo_custom_name_net2 - network1: bar_custom_name_net1 network2: bar_custom_name_net2 - resources: neutron_Network_1: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network1]} neutron_Network_2: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network2]} %index% is the "count" picking the 'foo' entries when %index% is 0, and 'bar' entries when %index% is 1 and so on. [1] https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Hea...
On 12/02/19 4:32 AM, NANTHINI A A wrote:
Hi , I have tried the below .But getting error .Please let me know how I can proceed further .
root@cic-1:~# cat try1.yaml heat_template_version: 2013-05-23 description: This is the template for I&V R6.1 base configuration to create neutron resources other than sg and vm for vyos vms parameters: resource_name_map: - network1: NetworkA1 network2: NetworkA2 - network1: NetworkB1 network2: NetworkB2
resources: neutron_Network_1: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network1]} neutron_Network_2: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network2]} root@cic-1:~# cat tryrepeat.yaml
heat_template_version: 2013-05-23
resources: rg: type: OS::Heat::ResourceGroup properties: count: 2 resource_def: type: try1.yaml root@cic-1:~#
root@cic-1:~# heat stack-create tests -f tryrepeat.yaml WARNING (shell) "heat stack-create" is deprecated, please use "openstack stack create" instead ERROR: resources.rg<nested_stack>: : Error parsing template file:///root/try1.yaml while scanning for the next token found character '%' that cannot start any token in "<unicode string>", line 15, column 45: ... {get_param: [resource_name_map, %index%, network1]}
That's a yaml parsing error. You just need to put quotes around the thing that starts with %, like "%index%"
Thanks in advance .
Thanks, A.Nanthini -----Original Message----- From: Harald Jensås [mailto:hjensas@redhat.com] Sent: Monday, February 11, 2019 7:47 PM To: NANTHINI A A <nanthini.a.a@ericsson.com>; openstack-dev@lists.openstack.org Subject: Re: [Heat] Reg accessing variables of resource group heat api
On Wed, 2019-02-06 at 06:12 +0000, NANTHINI A A wrote:
Hi , We are developing heat templates for our vnf deployment .It includes multiple resources .We want to repeat the resource and hence used the api RESOURCE GROUP . Attached are the templates which we used
Set1.yaml -> has the resources we want to repeat Setrepeat.yaml -> has the resource group api with count .
We want to access the variables of resource in set1.yaml while repeating it with count .Eg . port name ,port fixed ip address we want to change in each set . Please let us know how we can have a variable with each repeated resource .
Sounds like you want to use the index_var variable[1] to prefix/suffix reource names?
I.e in set1.yaml you can use:
name: list_join: - '_' - {get_param: 'OS::stack_name'} - %index% - <resource_name>
The example should resulting in something like: stack_0_Network3, stack_0_Subnet3 stack_1_Network0, stack_1_Subnet0 [ ... ]
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.
parameters: resource_name_map: - network1: foo_custom_name_net1 network2: foo_custom_name_net2 - network1: bar_custom_name_net1 network2: bar_custom_name_net2 -
resources: neutron_Network_1: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network1]} neutron_Network_2: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network2]}
%index% is the "count" picking the 'foo' entries when %index% is 0, and 'bar' entries when %index% is 1 and so on.
[1] https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Hea...
On Mon, Feb 11, 2019 at 9:23 PM NANTHINI A A <nanthini.a.a@ericsson.com> wrote:
Hi , I have tried the below .But getting error .Please let me know how I can proceed further .
root@cic-1:~# cat try1.yaml heat_template_version: 2013-05-23 description: This is the template for I&V R6.1 base configuration to create neutron resources other than sg and vm for vyos vms parameters: resource_name_map: - network1: NetworkA1 network2: NetworkA2 - network1: NetworkB1 network2: NetworkB2
resources: neutron_Network_1: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network1]}
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). [1] https://github.com/openstack/heat-templates/blob/master/hot/resource_group/r...
neutron_Network_2: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network2]} root@cic-1:~# cat tryrepeat.yaml
heat_template_version: 2013-05-23
resources: rg: type: OS::Heat::ResourceGroup properties: count: 2 resource_def: type: try1.yaml root@cic-1:~#
root@cic-1:~# heat stack-create tests -f tryrepeat.yaml WARNING (shell) "heat stack-create" is deprecated, please use "openstack stack create" instead ERROR: resources.rg<nested_stack>: : Error parsing template file:///root/try1.yaml while scanning for the next token found character '%' that cannot start any token in "<unicode string>", line 15, column 45: ... {get_param: [resource_name_map, %index%, network1]}
Thanks in advance .
Thanks, A.Nanthini -----Original Message----- From: Harald Jensås [mailto:hjensas@redhat.com] Sent: Monday, February 11, 2019 7:47 PM To: NANTHINI A A <nanthini.a.a@ericsson.com>; openstack-dev@lists.openstack.org Subject: Re: [Heat] Reg accessing variables of resource group heat api
On Wed, 2019-02-06 at 06:12 +0000, NANTHINI A A wrote:
Hi , We are developing heat templates for our vnf deployment .It includes multiple resources .We want to repeat the resource and hence used the api RESOURCE GROUP . Attached are the templates which we used
Set1.yaml -> has the resources we want to repeat Setrepeat.yaml -> has the resource group api with count .
We want to access the variables of resource in set1.yaml while repeating it with count .Eg . port name ,port fixed ip address we want to change in each set . Please let us know how we can have a variable with each repeated resource .
Sounds like you want to use the index_var variable[1] to prefix/suffix reource names?
I.e in set1.yaml you can use:
name: list_join: - '_' - {get_param: 'OS::stack_name'} - %index% - <resource_name>
The example should resulting in something like: stack_0_Network3, stack_0_Subnet3 stack_1_Network0, stack_1_Subnet0 [ ... ]
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.
parameters: resource_name_map: - network1: foo_custom_name_net1 network2: foo_custom_name_net2 - network1: bar_custom_name_net1 network2: bar_custom_name_net2 -
resources: neutron_Network_1: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network1]} neutron_Network_2: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network2]}
%index% is the "count" picking the 'foo' entries when %index% is 0, and 'bar' entries when %index% is 1 and so on.
[1]
https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Hea...
-- Regards, Rabi Mishra
Hi , May I know in the following example given parameters: resource_name_map: - network1: foo_custom_name_net1 network2: foo_custom_name_net2 - network1: bar_custom_name_net1 network2: bar_custom_name_net2 what is the parameter type ? Thanks, A.Nanthini From: Rabi Mishra [mailto:ramishra@redhat.com] Sent: Tuesday, February 12, 2019 10:45 AM To: NANTHINI A A <nanthini.a.a@ericsson.com> Cc: hjensas@redhat.com; openstack-dev@lists.openstack.org Subject: Re: [Heat] Reg accessing variables of resource group heat api On Mon, Feb 11, 2019 at 9:23 PM NANTHINI A A <nanthini.a.a@ericsson.com<mailto:nanthini.a.a@ericsson.com>> wrote: Hi , I have tried the below .But getting error .Please let me know how I can proceed further . root@cic-1:~# cat try1.yaml heat_template_version: 2013-05-23 description: This is the template for I&V R6.1 base configuration to create neutron resources other than sg and vm for vyos vms parameters: resource_name_map: - network1: NetworkA1 network2: NetworkA2 - network1: NetworkB1 network2: NetworkB2 resources: neutron_Network_1: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network1]} 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). [1] https://github.com/openstack/heat-templates/blob/master/hot/resource_group/r... neutron_Network_2: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network2]} root@cic-1:~# cat tryrepeat.yaml heat_template_version: 2013-05-23 resources: rg: type: OS::Heat::ResourceGroup properties: count: 2 resource_def: type: try1.yaml root@cic-1:~# root@cic-1:~# heat stack-create tests -f tryrepeat.yaml WARNING (shell) "heat stack-create" is deprecated, please use "openstack stack create" instead ERROR: resources.rg<nested_stack>: : Error parsing template file:///root/try1.yaml while scanning for the next token found character '%' that cannot start any token in "<unicode string>", line 15, column 45: ... {get_param: [resource_name_map, %index%, network1]} Thanks in advance . Thanks, A.Nanthini -----Original Message----- From: Harald Jensås [mailto:hjensas@redhat.com<mailto:hjensas@redhat.com>] Sent: Monday, February 11, 2019 7:47 PM To: NANTHINI A A <nanthini.a.a@ericsson.com<mailto:nanthini.a.a@ericsson.com>>; openstack-dev@lists.openstack.org<mailto:openstack-dev@lists.openstack.org> Subject: Re: [Heat] Reg accessing variables of resource group heat api On Wed, 2019-02-06 at 06:12 +0000, NANTHINI A A wrote:
Hi , We are developing heat templates for our vnf deployment .It includes multiple resources .We want to repeat the resource and hence used the api RESOURCE GROUP . Attached are the templates which we used
Set1.yaml -> has the resources we want to repeat Setrepeat.yaml -> has the resource group api with count .
We want to access the variables of resource in set1.yaml while repeating it with count .Eg . port name ,port fixed ip address we want to change in each set . Please let us know how we can have a variable with each repeated resource .
Sounds like you want to use the index_var variable[1] to prefix/suffix reource names? I.e in set1.yaml you can use: name: list_join: - '_' - {get_param: 'OS::stack_name'} - %index% - <resource_name> The example should resulting in something like: stack_0_Network3, stack_0_Subnet3 stack_1_Network0, stack_1_Subnet0 [ ... ] 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. parameters: resource_name_map: - network1: foo_custom_name_net1 network2: foo_custom_name_net2 - network1: bar_custom_name_net1 network2: bar_custom_name_net2 - resources: neutron_Network_1: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network1]} neutron_Network_2: type: OS::Neutron::Net properties: name: {get_param: [resource_name_map, %index%, network2]} %index% is the "count" picking the 'foo' entries when %index% is 0, and 'bar' entries when %index% is 1 and so on. [1] https://docs.openstack.org/heat/latest/template_guide/openstack.html#OS::Hea... -- Regards, Rabi Mishra
On Tue, Feb 12, 2019 at 11:14 AM NANTHINI A A <nanthini.a.a@ericsson.com> wrote:
Hi ,
May I know in the following example given
parameters: resource_name_map: - network1: foo_custom_name_net1 network2: foo_custom_name_net2 - network1: bar_custom_name_net1 network2: bar_custom_name_net2
what is the parameter type ?
json
Hi , I followed the example given in random.yaml .But getting below error .Can you please tell me what is wrong here . root@cic-1:~# heat stack-create test -f main.yaml WARNING (shell) "heat stack-create" is deprecated, please use "openstack stack create" instead ERROR: Property error: : resources.rg<nested_stack>.resources[0].properties: : Unknown Property names root@cic-1:~# cat main.yaml heat_template_version: 2015-04-30 description: Shows how to look up list/map values by group index parameters: net_names: type: json default: - network1: NetworkA1 network2: NetworkA2 - network1: NetworkB1 network2: NetworkB2 resources: rg: type: OS::Heat::ResourceGroup properties: count: 3 resource_def: type: nested.yaml properties: # Note you have to pass the index and the entire list into the # nested template, resolving via %index% doesn't work directly # in the get_param here index: "%index%" names: {get_param: net_names} outputs: all_values: value: {get_attr: [rg, value]} root@cic-1:~# cat nested.yaml heat_template_version: 2013-05-23 description: This is the template for I&V R6.1 base configuration to create neutron resources other than sg and vm for vyos vms parameters: net_names: type: json index: type: number resources: neutron_Network_1: type: OS::Neutron::Net properties: name: {get_param: [names, {get_param: index}, network1]} Thanks, A.Nanthini From: Rabi Mishra [mailto:ramishra@redhat.com] Sent: Tuesday, February 12, 2019 6:34 PM To: NANTHINI A A <nanthini.a.a@ericsson.com> Cc: hjensas@redhat.com; openstack-dev@lists.openstack.org Subject: Re: [Heat] Reg accessing variables of resource group heat api On Tue, Feb 12, 2019 at 11:14 AM NANTHINI A A <nanthini.a.a@ericsson.com<mailto:nanthini.a.a@ericsson.com>> wrote: Hi , May I know in the following example given parameters: resource_name_map: - network1: foo_custom_name_net1 network2: foo_custom_name_net2 - network1: bar_custom_name_net1 network2: bar_custom_name_net2 what is the parameter type ? json
On Tue, Feb 12, 2019 at 7:48 PM NANTHINI A A <nanthini.a.a@ericsson.com> wrote:
Hi ,
I followed the example given in random.yaml .But getting below error .Can you please tell me what is wrong here .
root@cic-1:~# heat stack-create test -f main.yaml
WARNING (shell) "heat stack-create" is deprecated, please use "openstack stack create" instead
ERROR: Property error: : resources.rg<nested_stack>.resources[0].properties: : Unknown Property names
root@cic-1:~# cat main.yaml
heat_template_version: 2015-04-30
description: Shows how to look up list/map values by group index
parameters:
net_names:
type: json
default:
- network1: NetworkA1
network2: NetworkA2
- network1: NetworkB1
network2: NetworkB2
resources:
rg:
type: OS::Heat::ResourceGroup
properties:
count: 3
resource_def:
type: nested.yaml
properties:
# Note you have to pass the index and the entire list into the
# nested template, resolving via %index% doesn't work directly
# in the get_param here
index: "%index%"
names: {get_param: net_names}
property name should be same as parameter name in you nested.yaml
outputs:
all_values:
value: {get_attr: [rg, value]}
root@cic-1:~# cat nested.yaml
heat_template_version: 2013-05-23
description:
This is the template for I&V R6.1 base configuration to create neutron resources other than sg and vm for vyos vms
parameters:
net_names:
changing this to 'names' should fix your error.
type: json
index:
type: number
resources:
neutron_Network_1:
type: OS::Neutron::Net
properties:
name: {get_param: [names, {get_param: index}, network1]}
Thanks,
A.Nanthini
*From:* Rabi Mishra [mailto:ramishra@redhat.com] *Sent:* Tuesday, February 12, 2019 6:34 PM *To:* NANTHINI A A <nanthini.a.a@ericsson.com> *Cc:* hjensas@redhat.com; openstack-dev@lists.openstack.org *Subject:* Re: [Heat] Reg accessing variables of resource group heat api
On Tue, Feb 12, 2019 at 11:14 AM NANTHINI A A <nanthini.a.a@ericsson.com> wrote:
Hi ,
May I know in the following example given
parameters: resource_name_map: - network1: foo_custom_name_net1 network2: foo_custom_name_net2 - network1: bar_custom_name_net1 network2: bar_custom_name_net2
what is the parameter type ?
json
-- Regards, Rabi Mishra
Hi , As per your suggested change ,I am able to create network A1,network A2 ; in second iteration network b1,network b2 .But I want to reduce number of lines of variable params.hence tried using repeat function .But it is not working .Can you please let me know what is wrong here . I am getting following error . root@cic-1:~# heat stack-create test2 -f main.yaml WARNING (shell) "heat stack-create" is deprecated, please use "openstack stack create" instead ERROR: AttributeError: : resources.rg: : 'NoneType' object has no attribute 'parameters' root@cic-1:~# cat main.yaml heat_template_version: 2015-04-30 description: Shows how to look up list/map values by group index parameters: sets: type: comma_delimited_list label: sets default: "A,B,C" net_names: type: json default: repeat: for each: <%set%>: {get_param: sets} template: - network1: Network<%set>1 network2: Network<%set>2 resources: rg: type: OS::Heat::ResourceGroup properties: count: 3 resource_def: type: nested.yaml properties: # Note you have to pass the index and the entire list into the # nested template, resolving via %index% doesn't work directly # in the get_param here index: "%index%" names: {get_param: net_names} outputs: all_values: value: {get_attr: [rg, value]} root@cic-1:~# Thanks in advance. Regards, A.Nanthini From: Rabi Mishra [mailto:ramishra@redhat.com] Sent: Wednesday, February 13, 2019 9:07 AM To: NANTHINI A A <nanthini.a.a@ericsson.com> Cc: hjensas@redhat.com; openstack-dev@lists.openstack.org Subject: Re: [Heat] Reg accessing variables of resource group heat api On Tue, Feb 12, 2019 at 7:48 PM NANTHINI A A <nanthini.a.a@ericsson.com<mailto:nanthini.a.a@ericsson.com>> wrote: Hi , I followed the example given in random.yaml .But getting below error .Can you please tell me what is wrong here . root@cic-1:~# heat stack-create test -f main.yaml WARNING (shell) "heat stack-create" is deprecated, please use "openstack stack create" instead ERROR: Property error: : resources.rg<nested_stack>.resources[0].properties: : Unknown Property names root@cic-1:~# cat main.yaml heat_template_version: 2015-04-30 description: Shows how to look up list/map values by group index parameters: net_names: type: json default: - network1: NetworkA1 network2: NetworkA2 - network1: NetworkB1 network2: NetworkB2 resources: rg: type: OS::Heat::ResourceGroup properties: count: 3 resource_def: type: nested.yaml properties: # Note you have to pass the index and the entire list into the # nested template, resolving via %index% doesn't work directly # in the get_param here index: "%index%" names: {get_param: net_names} property name should be same as parameter name in you nested.yaml outputs: all_values: value: {get_attr: [rg, value]} root@cic-1:~# cat nested.yaml heat_template_version: 2013-05-23 description: This is the template for I&V R6.1 base configuration to create neutron resources other than sg and vm for vyos vms parameters: net_names: changing this to 'names' should fix your error. type: json index: type: number resources: neutron_Network_1: type: OS::Neutron::Net properties: name: {get_param: [names, {get_param: index}, network1]} Thanks, A.Nanthini From: Rabi Mishra [mailto:ramishra@redhat.com<mailto:ramishra@redhat.com>] Sent: Tuesday, February 12, 2019 6:34 PM To: NANTHINI A A <nanthini.a.a@ericsson.com<mailto:nanthini.a.a@ericsson.com>> Cc: hjensas@redhat.com<mailto:hjensas@redhat.com>; openstack-dev@lists.openstack.org<mailto:openstack-dev@lists.openstack.org> Subject: Re: [Heat] Reg accessing variables of resource group heat api On Tue, Feb 12, 2019 at 11:14 AM NANTHINI A A <nanthini.a.a@ericsson.com<mailto:nanthini.a.a@ericsson.com>> wrote: Hi , May I know in the following example given parameters: resource_name_map: - network1: foo_custom_name_net1 network2: foo_custom_name_net2 - network1: bar_custom_name_net1 network2: bar_custom_name_net2 what is the parameter type ? json -- Regards, Rabi Mishra
On Wed, 2019-02-13 at 13:48 +0000, NANTHINI A A wrote:
Hi , As per your suggested change ,I am able to create network A1,network A2 ; in second iteration network b1,network b2 .But I want to reduce number of lines of variable params.hence tried using repeat function .But it is not working .Can you please let me know what is wrong here .
I am getting following error . root@cic-1:~# heat stack-create test2 -f main.yaml WARNING (shell) "heat stack-create" is deprecated, please use "openstack stack create" instead ERROR: AttributeError: : resources.rg: : 'NoneType' object has no attribute 'parameters'
root@cic-1:~# cat main.yaml heat_template_version: 2015-04-30
description: Shows how to look up list/map values by group index
parameters: sets: type: comma_delimited_list label: sets default: "A,B,C" net_names: type: json default: repeat: for each: <%set%>: {get_param: sets} template: - network1: Network<%set>1 network2: Network<%set>2
I don't think you can use the repeat function in the parameters section. You could try using a OS::Heat::Value resource in the resources section below to iterate over the sets parameter. Then use get_attr to read the result of the heat value and pass that as names to nested.yaml.
resources: rg: type: OS::Heat::ResourceGroup properties: count: 3 resource_def: type: nested.yaml properties: # Note you have to pass the index and the entire list into the # nested template, resolving via %index% doesn't work directly # in the get_param here index: "%index%" names: {get_param: net_names}
Alternatively you could put the repeat function here? names: repeat: for each: [ ... ]
outputs: all_values: value: {get_attr: [rg, value]} root@cic-1:~#
Thanks in advance.
Regards, A.Nanthini
From: Rabi Mishra [mailto:ramishra@redhat.com] Sent: Wednesday, February 13, 2019 9:07 AM To: NANTHINI A A <nanthini.a.a@ericsson.com> Cc: hjensas@redhat.com; openstack-dev@lists.openstack.org Subject: Re: [Heat] Reg accessing variables of resource group heat api
On Tue, Feb 12, 2019 at 7:48 PM NANTHINI A A < nanthini.a.a@ericsson.com> wrote:
Hi , I followed the example given in random.yaml .But getting below error .Can you please tell me what is wrong here .
root@cic-1:~# heat stack-create test -f main.yaml WARNING (shell) "heat stack-create" is deprecated, please use "openstack stack create" instead ERROR: Property error: : resources.rg<nested_stack>.resources[0].properties: : Unknown Property names root@cic-1:~# cat main.yaml heat_template_version: 2015-04-30
description: Shows how to look up list/map values by group index
parameters: net_names: type: json default: - network1: NetworkA1 network2: NetworkA2 - network1: NetworkB1 network2: NetworkB2
resources: rg: type: OS::Heat::ResourceGroup properties: count: 3 resource_def: type: nested.yaml properties: # Note you have to pass the index and the entire list into the # nested template, resolving via %index% doesn't work directly # in the get_param here index: "%index%"
names: {get_param: net_names}
property name should be same as parameter name in you nested.yaml
outputs: all_values: value: {get_attr: [rg, value]} root@cic-1:~# cat nested.yaml heat_template_version: 2013-05-23 description: This is the template for I&V R6.1 base configuration to create neutron resources other than sg and vm for vyos vms parameters: net_names:
changing this to 'names' should fix your error.
type: json index: type: number resources: neutron_Network_1: type: OS::Neutron::Net properties: name: {get_param: [names, {get_param: index}, network1]}
Thanks, A.Nanthini
From: Rabi Mishra [mailto:ramishra@redhat.com] Sent: Tuesday, February 12, 2019 6:34 PM To: NANTHINI A A <nanthini.a.a@ericsson.com> Cc: hjensas@redhat.com; openstack-dev@lists.openstack.org Subject: Re: [Heat] Reg accessing variables of resource group heat api
On Tue, Feb 12, 2019 at 11:14 AM NANTHINI A A < nanthini.a.a@ericsson.com> wrote:
Hi , May I know in the following example given
parameters: resource_name_map: - network1: foo_custom_name_net1 network2: foo_custom_name_net2 - network1: bar_custom_name_net1 network2: bar_custom_name_net2 what is the parameter type ?
json
-- Regards, Rabi Mishra
Hi , To resolve previous mentioned issue I am trying to use list_join function in nested.yaml.Stack is created successfully .but the resources are not created .Can you please let me know what might be the issue here with list_join. root@cic-1:~# cat nested.yaml heat_template_version: 2013-05-23 description: This is the template for I&V R6.1 base configuration to create neutron resources other than sg and vm for vyos vms parameters: names: type: comma_delimited_list index: type: number resources: neutron_Network_1: type: OS::Neutron::Net properties: name: list_join: [",",['Network','{get_param: [names, {get_param: index}]','1']] # str_replace: # template: net%-set%-number% # params: # "net%": "Network" # "set%": "A" # "number%": "1" neutron_Network_2: type: OS::Neutron::Net properties: name: list_join: [",",['Network','{get_param: [names, {get_param: index}]','1']] # str_replace: # template: net%-set%-number% # params: # "net%": "Network" # "set%": "A" #"number%": "2" root@cic-1:~# root@cic-1:~# cat main.yaml heat_template_version: 2015-04-30 description: Shows how to look up list/map values by group index parameters: sets: type: comma_delimited_list label: sets default: "A,B,C" net_names: type: json default: repeat: for each: <%set%>: {get_param: sets} template: - network1: Network<%set>1 network2: Network<%set>2 resources: rg: type: OS::Heat::ResourceGroup properties: count: 3 resource_def: type: nested.yaml properties: # Note you have to pass the index and the entire list into the # nested template, resolving via %index% doesn't work directly # in the get_param here index: "%index%" names: {get_param: sets} outputs: all_values: value: {get_attr: [rg, value]} root@cic-1:~# -----Original Message----- From: Harald Jensås [mailto:hjensas@redhat.com] Sent: Friday, February 15, 2019 1:36 AM To: NANTHINI A A <nanthini.a.a@ericsson.com> Cc: openstack-dev@lists.openstack.org Subject: Re: [Heat] Reg accessing variables of resource group heat api On Wed, 2019-02-13 at 13:48 +0000, NANTHINI A A wrote:
Hi , As per your suggested change ,I am able to create network A1,network A2 ; in second iteration network b1,network b2 .But I want to reduce number of lines of variable params.hence tried using repeat function .But it is not working .Can you please let me know what is wrong here .
I am getting following error . root@cic-1:~# heat stack-create test2 -f main.yaml WARNING (shell) "heat stack-create" is deprecated, please use "openstack stack create" instead ERROR: AttributeError: : resources.rg: : 'NoneType' object has no attribute 'parameters'
root@cic-1:~# cat main.yaml heat_template_version: 2015-04-30
description: Shows how to look up list/map values by group index
parameters: sets: type: comma_delimited_list label: sets default: "A,B,C" net_names: type: json default: repeat: for each: <%set%>: {get_param: sets} template: - network1: Network<%set>1 network2: Network<%set>2
I don't think you can use the repeat function in the parameters section. You could try using a OS::Heat::Value resource in the resources section below to iterate over the sets parameter. Then use get_attr to read the result of the heat value and pass that as names to nested.yaml.
resources: rg: type: OS::Heat::ResourceGroup properties: count: 3 resource_def: type: nested.yaml properties: # Note you have to pass the index and the entire list into the # nested template, resolving via %index% doesn't work directly # in the get_param here index: "%index%" names: {get_param: net_names}
Alternatively you could put the repeat function here? names: repeat: for each: [ ... ]
outputs: all_values: value: {get_attr: [rg, value]} root@cic-1:~#
Thanks in advance.
Regards, A.Nanthini
From: Rabi Mishra [mailto:ramishra@redhat.com] Sent: Wednesday, February 13, 2019 9:07 AM To: NANTHINI A A <nanthini.a.a@ericsson.com> Cc: hjensas@redhat.com; openstack-dev@lists.openstack.org Subject: Re: [Heat] Reg accessing variables of resource group heat api
On Tue, Feb 12, 2019 at 7:48 PM NANTHINI A A < nanthini.a.a@ericsson.com> wrote:
Hi , I followed the example given in random.yaml .But getting below error .Can you please tell me what is wrong here .
root@cic-1:~# heat stack-create test -f main.yaml WARNING (shell) "heat stack-create" is deprecated, please use "openstack stack create" instead ERROR: Property error: : resources.rg<nested_stack>.resources[0].properties: : Unknown Property names root@cic-1:~# cat main.yaml heat_template_version: 2015-04-30
description: Shows how to look up list/map values by group index
parameters: net_names: type: json default: - network1: NetworkA1 network2: NetworkA2 - network1: NetworkB1 network2: NetworkB2
resources: rg: type: OS::Heat::ResourceGroup properties: count: 3 resource_def: type: nested.yaml properties: # Note you have to pass the index and the entire list into the # nested template, resolving via %index% doesn't work directly # in the get_param here index: "%index%"
names: {get_param: net_names}
property name should be same as parameter name in you nested.yaml
outputs: all_values: value: {get_attr: [rg, value]} root@cic-1:~# cat nested.yaml heat_template_version: 2013-05-23 description: This is the template for I&V R6.1 base configuration to create neutron resources other than sg and vm for vyos vms parameters: net_names:
changing this to 'names' should fix your error.
type: json index: type: number resources: neutron_Network_1: type: OS::Neutron::Net properties: name: {get_param: [names, {get_param: index}, network1]}
Thanks, A.Nanthini
From: Rabi Mishra [mailto:ramishra@redhat.com] Sent: Tuesday, February 12, 2019 6:34 PM To: NANTHINI A A <nanthini.a.a@ericsson.com> Cc: hjensas@redhat.com; openstack-dev@lists.openstack.org Subject: Re: [Heat] Reg accessing variables of resource group heat api
On Tue, Feb 12, 2019 at 11:14 AM NANTHINI A A < nanthini.a.a@ericsson.com> wrote:
Hi , May I know in the following example given
parameters: resource_name_map: - network1: foo_custom_name_net1 network2: foo_custom_name_net2 - network1: bar_custom_name_net1 network2: bar_custom_name_net2 what is the parameter type ?
json
-- Regards, Rabi Mishra
participants (4)
-
Harald Jensås
-
NANTHINI A A
-
Rabi Mishra
-
Zane Bitter