Ask Your Question

How to get all the value in a list

asked 2016-01-21 08:10:08 -0500

Jeffrey Guan gravatar image

updated 2016-01-21 08:10:45 -0500

 suppose there is a map:
   zoneB_db_static_name_list: {
       "node0": "dltasVM003jeguan",
       "node1": "dltasVM004jeguan"
The number of Key:Value pairs in the map are not a constant, sometimes it is 3 or 4, sometimes it is other number.
Is there any way that I can get all the value in this map?

Thank you very much.
edit retag flag offensive close merge delete


you are talking about specific service in OpenStack or your question is general ?

Wohard gravatar imageWohard ( 2016-01-21 08:53:04 -0500 )edit

This question is about the heat template. Not Python.

Jeffrey Guan gravatar imageJeffrey Guan ( 2016-01-24 08:25:50 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-01-21 23:45:10 -0500

xiangfei-ma gravatar image

It very simple to do this by dict.values() method.

zoneB_db_static_name_list={"node0": "dltasVM003jeguan", "node1": "dltasVM004jeguan"}
values = zoneB_db_static_name_list.values()
print values

The result will be:

['dltasVM004jeguan', 'dltasVM003jeguan']
edit flag offensive delete link more


Thank you very much for your kind answer. I am sorry for my not showing my question clearly. This question is about the heat template, that is, I want to know how to get all value in a list when it is in heat template. I am not asking "how to get the value in a list for python".

Jeffrey Guan gravatar imageJeffrey Guan ( 2016-01-24 08:31:38 -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


Asked: 2016-01-21 08:10:08 -0500

Seen: 88 times

Last updated: Jan 21 '16