Ask Your Question
0

How to display child attributes from parent yaml files?

asked 2017-03-24 07:36:46 -0500

udayutkarsh gravatar image

updated 2017-03-24 07:44:40 -0500

I have a child yaml file named child.yaml:: ====================================================

heat_template_version: 2015-04-30

description: Simple template to deploy a single compute instance

parameters:
  key_name:
    type: string
  image_id:
    type: string
  flavor_id:
    type: string
  network_id:
    type: string
  vm_name:
    type: string

resources:
  my_instance:
    type: OS::Nova::Server
    properties:
      name: { get_param: vm_name }
      key_name: { get_param: key_name }
      image: { get_param: image_id }
      flavor: { get_param: flavor_id }
      networks:
       - network: { get_param: network_id }

The parent file which looks like as under (parent.yaml )::
=====================================================

heat_template_version: 2015-04-30

description: Simple template to deploy a single compute instance

parameters:

  key_name:
    type: string
    label: Key Name
    description: Name of key-pair to be used for compute instance
    default: keypair-01

  image_id:
    type: string
    label: Image ID
    description: Image to be used for compute instance
    default: cirros

  flavor_id:
    type: string
    label: Instance Type
    description: Type of instance (flavor) to be used
    default: m1.tiny

  network_id:
    type: string
    label: Instance Type
    description: Type of instance (flavor) to be used
    default: private

  vm_name1:
    type: string
    default: vm1

  vm_name2:
    type: string
    default: vm2    

resources:
  my_instance1:
    type: ./child.yaml
    properties:
      vm_name: {get_param: vm_name1 }
      key_name: { get_param: key_name }
      image_id: { get_param: image_id }
      flavor_id: { get_param: flavor_id }
      network_id: { get_param: network_id }

 my_instance1:
     type: ./child.yaml
     properties:
        vm_name: {get_param: vm_name2 }
        key_name: { get_param: key_name }
        image_id: { get_param: image_id }
        flavor_id: { get_param: flavor_id }
        network_id: { get_param: network_id }

Now i need to create a stack from parent.yaml file (which invokes child.yaml two times in order to create two vms) to display ip addresses (or any other attributes) of both VMs (vm1 and vm2).

I have tried implementing output section in parent yaml but could not get values. Kindly help me writing outputs section so that I can display ip addresses of both vms from parent.yaml.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2017-03-24 09:14:48 -0500

zaneb gravatar image

In the child file:

outputs:
  ip_address:
    value: {get_attr: [my_instance, networks, {get_param: network_id}, 0]}

Then in the parent:

outputs:
  child_1_ip_address:
    value: {get_attr: [my_instance1, ip_address]}

&c.

BTW you can't call both of your resources my_instance1. One of them should be called my_instance2.

edit flag offensive delete link more

Comments

Thanks !!!. yeah I had just added my_instance1 twice manually for the sake of asking question. Two resources cannot have same name.

udayutkarsh gravatar imageudayutkarsh ( 2017-03-27 05:08:07 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower

Stats

Asked: 2017-03-24 07:36:46 -0500

Seen: 405 times

Last updated: Mar 24 '17