Revision history [back]

click to hide/show revision 1
initial version

openstacksdk list all project instance

How can i list all projects instance using native openstacksdk api client as of now i can list only single project instances

this is my code.

!/usr/bin/env python

from openstack import connection from os import getenv import sys sys.path.append('/home/openstack/.pwd') import kypass import json

conn = connection.Connection(auth_url="http://horizon.com:5000/v3/", project_name="WS",username=kypass.user, password=kypass.password, user_domain_id="3d2f7b6dfa4148a3aad8f7", project_domain_id="3d2f7b6dfa4148a3aa61bf418f7") host_names = [] for server in conn.compute.servers(): host = server.name if host.startswith('rw'): if 'production' in server.metadata and str(server.metadata['production']).lower() == "yes" and 'ACTIVE' in server.status: host_names.append(host)

rws_host_names = { "all": { "hosts": host_names, "vars": {} }, "_meta": { "hostvars": {} } } print(json.dumps(rws_host_names,indent=4,sort_keys=False))

openstacksdk list all project instance

How can i list all projects instance using native openstacksdk api client as of now i can list only single project instances

this is my code.

# !/usr/bin/env python

python from openstack import connection from os import getenv import sys sys.path.append('/home/openstack/.pwd') import kypass import json

json conn = connection.Connection(auth_url="http://horizon.com:5000/v3/", project_name="WS",username=kypass.user, password=kypass.password, user_domain_id="3d2f7b6dfa4148a3aad8f7", project_domain_id="3d2f7b6dfa4148a3aa61bf418f7") host_names = [] for server in conn.compute.servers(): host = server.name if host.startswith('rw'): if 'production' in server.metadata and str(server.metadata['production']).lower() == "yes" and 'ACTIVE' in server.status: host_names.append(host)

host_names.append(host) rws_host_names = { "all": { "hosts": host_names, "vars": {} }, "_meta": { "hostvars": {} } } print(json.dumps(rws_host_names,indent=4,sort_keys=False))

print(json.dumps(rws_host_names,indent=4,sort_keys=False))