Ask Your Question
2

HEAT and count list elements

asked 2018-11-25 04:45:09 -0500

Proximm gravatar image

updated 2018-11-27 03:50:52 -0500

How to get count/number of elements in list in HEAT? For example:

parameters:
  attach_ports_to_node:
    type: comma_delimited_list
    default: [ "port1", "port2", "port3" ]

group_of_ports:
    type: OS::Heat::ResourceGroup
    properties:
    count: 3  #<---how to get number of elements in attach_ports_to_node?

UPDATE:

The answer is:

heat_template_version: 2017-09-01

parameters:
  list_param:
    type: comma_delimited_list
    default: [1, 2, 3, 8, 6]

outputs:
  count_elem:
    value:
      yaql:
        expression: $.data.list_param.count()
        data:
          list_param: {get_param: list_param}

Result:

count_elem
    No description given

    5

@Bernd Bausch: Thanks, you guide me to almost right answer :)

edit retag flag offensive close merge delete

Comments

1

The yaql example in the Heat template guide seems to do what you want.

Bernd Bausch gravatar imageBernd Bausch ( 2018-11-25 16:19:50 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2018-11-27 03:27:26 -0500

Proximm gravatar image

updated 2018-11-27 03:51:02 -0500

The answer is:

heat_template_version: 2017-09-01

parameters:
  list_param:
    type: comma_delimited_list
    default: [1, 2, 3, 8, 6]

outputs:
  count_elem:
    value:
      yaql:
        expression: $.data.list_param.count()
        data:
          list_param: {get_param: list_param}

Result:

count_elem
    No description given

    5

@Bernd Bausch: Thanks, you guide me to almost right answer :)

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: 2018-11-25 04:45:09 -0500

Seen: 103 times

Last updated: Nov 27 '18