Ask Your Question

Heat api stack list

asked 2015-03-18 07:54:41 -0600

sreejithp gravatar image

updated 2015-03-18 08:58:41 -0600

Ranjit gravatar image

Hello All,

I am learning openstack api programming, trying to get the list of stacks using python-heatclient api. The code is as follows

import sys
import os
from heatclient.client import Client as Heat_Client
from keystoneclient.v2_0 import Client as Keystone_Client

def get_keystone_creds():
    d = {}
    d['username'] = os.environ['OS_USERNAME']
    d['password'] = os.environ['OS_PASSWORD']
    d['auth_url'] = os.environ['OS_AUTH_URL']
    d['tenant_name'] = os.environ['OS_TENANT_NAME']
    return d

cred = get_keystone_creds()
ks_client = Keystone_Client(**cred)
heat_endpoint = ks_client.service_catalog.url_for(service_type='image', endpoint_type='publicURL')
heatclient = Heat_Client('1', heat_endpoint, token=ks_client.auth_token)
stack = heatclient.stacks.list()
print stack

this displays an output <generator object="" paginate="" at="" 0x7fdb0755fa50="">.

Please let me know how can i print the list of available heat stack.

Thanks and Regards, Sreejith P

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted

answered 2015-03-19 03:10:28 -0600

Ranjit gravatar image
 1. Change service type to 'orchestration'.
 2.  Return type of list() is generator object. You need to write while loop and call next() API.
for ex: will print first stack from database.
edit flag offensive delete link more


Thanks for pointing the error in the code. I am able to print the stack list. but the return type is still paginate not list. The modified code is below.

Modified: heat_endpoint = ks_client.service_catalog.url_for(service_type='orchestration', endpoint_type='publicURL')

Added: print

sreejithp gravatar imagesreejithp ( 2015-03-19 04:14:48 -0600 )edit

answered 2015-04-10 14:13:32 -0600

zaneb gravatar image

    print list(heatclient.stacks.list())
edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2015-03-18 07:54:41 -0600

Seen: 739 times

Last updated: Apr 10 '15