Ask Your Question
0

outputs from nested template

asked 2016-08-17 22:17:47 -0600

allmaya gravatar image

updated 2016-09-20 13:37:32 -0600

zaneb gravatar image

I am creating volumes using nested ...I want to print the volume id(UUID) for each volume I create. I tried different ways nothing seems to work i am lost...

base_template

    parameters:

      vfl_prb_volume_name:
       type: comma_delimited_list
       description: VolumeName for vfl probe instances
      vfl_prb_vol_size:
       type: comma_delimited_list
       label: volume_size
       description: Volumesize for probes

    resources:
     vfl_prb_3_vol_0:
        type: nested_vfl_prb_volume.yaml
        properties:
         vfl_prb_volume_name: { get_param: [vfl_prb_volume_name, 0] } 
         vfl_prb_vol_size: { get_param: [vfl_prb_vol_size, 0] }
     vfl_prb_4_vol_0:
        type: nested_vfl_prb_volume.yaml
        properties:
         vfl_prb_volume_name: { get_param: [vfl_prb_volume_name, 1] }
         vfl_prb_vol_size: { get_param: [vfl_prb_vol_size, 1] }

nested template

parameters:

  vfl_prb_volume_name:
   type: string
   constraints: 
     - length: { min: 3, max: 25 }
     - allowed_pattern: "vfl_prb_volume_name_[0-9]*"
   description: the volume names for vfl  probe instances
  vfl_prb_vol_size:
   type: number
   label: volume_size
   constraints:
      - range: { min: 1, max: 1000000 }
        description: Volumesize defined in gigabytes
   description: Volume size for  probes


resources:
 vfl_prb_volume_create:
  type: OS::Cinder::Volume 
  properties:
   name: { get_param: vfl_prb_volume_name } 
   size: { get_param: vfl_prb_vol_size }

Where do I need to define the outputs at base or nested?how do I define so that I can get ssomething like below

vfl_prb_3_vol_0_id: UUID
vfl_prb_4_vol_0_id: UUID

I tried something like below didn't work

outputs:
  volumes_ids:
  description: output the volume_ids all volumes created
    value:
      vfl_prb_3_vol_0_id: { get_resource: vfl_prb_3_vol_0 }
edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-09-20 13:34:26 -0600

zaneb gravatar image

updated 2016-09-20 13:40:37 -0600

If you want them to be visible as outputs of the root stack, then you need to define them in both. To export the volume ID from the nested template you'll need to add something like:

outputs:
  volume_id:
    description: The volume ID
    value: {get_resource: vfl_prb_volume_create}

And then to export them from the root stack, add this to your base template:

outputs:
  volume_ids:
    description: The IDs of all volumes created
    value:
      vfl_prb_3_vol_0_id: {get_attr: [vfl_prb_3_vol_0, volume_id]}

i.e. outputs in the nested stack show up as attributes of the parent resource in the base stack.

Alternatively, starting with the Kilo release you can use the special output name OS::stack_id in the nested stack. If you do that then you'll be able to reference the value using the get_resource intrinsic function (instead of get_attr), as you initially tried. (Note the correct indentation of the description though.)

edit flag offensive delete link more

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: 2016-08-17 22:15:58 -0600

Seen: 521 times

Last updated: Sep 20 '16