From e9befdfca51b63e001af7ec61ba621d1c573ec31 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Fri, 4 Nov 2022 14:54:26 +0000 Subject: [PATCH] Add 2 more example functions --- check_openstack.py | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/check_openstack.py b/check_openstack.py index 87f8b4c..7a99124 100755 --- a/check_openstack.py +++ b/check_openstack.py @@ -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__':