diff --git a/check_openstack.py b/check_openstack.py index fd92b28..e009e15 100644 --- a/check_openstack.py +++ b/check_openstack.py @@ -60,9 +60,30 @@ def get_cores(creds): if 'PCPU' in inventory: cores+=inventory['PCPU']['total'] - print("{}: {}".format(hostname,cores)) +def get_networks(creds): + keystone = get_keystoneclient(creds) + token = keystone.auth_token + + url = keystone.service_catalog.get_endpoints(service_name="neutron",endpoint_type="public")['network'][0]['url'] + + headers = {} + headers['content-type'] = 'application/json' + headers['x-auth-token'] = token + + data = {} + + request = "networks" + + r = requests.get("{}/v2.0/{}".format(url,request),headers=headers) + + networks = r.json()['networks'] + + for network in networks: + print(network['id']) + + def _parse_args(): parser = argparse.ArgumentParser() parser.add_argument('-s', '--site', metavar="", @@ -75,6 +96,7 @@ def main(args): get_servers(creds) get_cores(creds) + get_networks(creds) if __name__ == '__main__': main(_parse_args())