Ask Your Question
0

Heat api stack list

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

sreejithp gravatar image

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

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
0

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

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:  stack.next() will print first stack from database.
edit flag offensive delete link more

Comments

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 stack.next()

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

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

zaneb gravatar image

    print list(heatclient.stacks.list())
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: 2015-03-18 07:54:41 -0500

Seen: 602 times

Last updated: Apr 10 '15