Heat get_param Processing Array of Object
Hi
Have a template that consists of 2 parts: Part 1 that allocates a number of private IPs, and Part 2 that tries to assign each IP to a nova instance. I am using ResourceGroup class to instantiate proper number of objects:
heat_template_version: 2013-05-23
description: Template X.
parameters:
...
cluster_size:
type: number
label: Cluster size
description: Number of instances.
default: 2
resources:
masters_ip:
type: OS::Heat::ResourceGroup
properties:
count: { get_param: cluster_size }
resource_def:
type: Lib::GET_IP::GetIp
properties:
private_network: { get_param: private_network }
masters:
type: OS::Heat::ResourceGroup
properties:
count: { get_param: cluster_size }
resource_def:
type: Lib::MASTER::Master
properties:
...
private_ips: { get_attr: [masters_ip,ip] }
indx: "%index%"
outputs:
ip:
description: The IP address of the master instances.
value: { get_attr: [masters_ip,ip] }
Where GetIP:
heat_template_version: 2013-05-23
description: Template that gets an ip.
parameters:
private_network:
type: string
label: Private network name or ID
description: Network to attach server to.
default: priv01
resources:
ip_instance:
type: OS::Neutron::Port
properties:
network: { get_param: private_network }
outputs:
ip:
description: The IP address of the instance.
value: { get_attr: [ip_instance, fixed_ips,0,ip_address] }
Looking at the heat show-stack, I see the properly allocated IPs:
...
links | http://10.4.0.64:8004/v1/8f3633c4ba1640abbab3be608b6bcc88/stacks/masters/aad06669-90b9-4f02-808b-fa65b62a8e89 (self) |
| notification_topics | [] |
| outputs | [ |
| | { |
| | "output_value": [ |
| | "10.40.50.157", |
| | "10.40.50.156" |
| | ], |
| | "description": "The IP address of the master instances.", |
| | "output_key": "ip" |
| | } |
| | ] |
| parameters | {
...
In my nested nova sack, tried to pick up the ip using the following:
heat_template_version: 2013-05-23
description: Template masters.
parameters:
...
private_ips:
type: comma_delimited_list
label: Private network name or ID
description: Network to attach server to.
indx:
type: number
label: Id
description: Index of the current instance
default: 0
resources:
instance:
type: OS::Nova::Server
properties:
networks:
- port: { get_param: [ private_ips, indx ] }
...
This however gives the following error:
Resource CREATE failed: ResourceUnknownStatus: Resource |
| | failed - Unknown status FAILED due to "Resource CREATE |
| | failed: StackValidationFailed: Property error : |
| | master_instance: networks Property error : networks: 0 |
| | Property error : 0: port Multiple port matches found |
| | for name '', use an ID to be more specific."
Looking at the nova resource template, I see that the right array has been passed to both instances:
heat_template_version: '2013-05-23'
resources:
'0':
properties:
...
private_ips: [10.40.50.157, 10.40.50.156]
type: Lib::MASTER::Master
'1':
properties:
...
indx: '1'
key: lab_admin
private_ips: [10.40.50.157, 10.40.50.156]
type: Lib::MASTER::Master
Also tried json type, in nova stack, while defining the "outputs" Section of GetIp as "get_attr: [ip_instance, fixed_ips]", and attempted to access instance's IP's via "port: { get_param: [ private_ips,ip_address, indx ] }" to no avail.
Any thoughts?
Cheers,