Add 2 more example functions

This commit is contained in:
Arif Ali 2022-11-04 14:54:26 +00:00
parent 5532a666d4
commit e9befdfca5
Signed by: arif
GPG Key ID: 369608FBA1353A70

View File

@ -45,6 +45,44 @@ def get_servers(keystone):
print("server_id: {}".format(server['id']))
def get_projects(keystone):
url = keystone.service_catalog.get_endpoints(
service_name="keystone",
endpoint_type=endpoint_type,
)['identity'][0]['url']
request = "projects"
r = requests.get("{}/{}".format(url, request), headers=headers)
projects = r.json()[request]
for project in projects:
print("project_id: {}".format(project['id']))
def get_hosts(keystone):
url = keystone.service_catalog.get_endpoints(
service_name="nova",
endpoint_type=endpoint_type,
)['compute'][0]['url']
request = "os-services"
r = requests.get("{}/{}".format(url, request), headers=headers)
services = r.json()['services']
for service in services:
if service['zone'] == 'nova':
print("host: {}, updated_at: {}".format(
service['host'],
service['updated_at'],
))
def get_cores(keystone):
url = keystone.service_catalog.get_endpoints(
@ -112,6 +150,8 @@ def main(args):
get_servers(keystone)
get_cores(keystone)
get_networks(keystone)
get_projects(keystone)
get_hosts(keystone)
if __name__ == '__main__':