Add 2 more example functions
This commit is contained in:
parent
5532a666d4
commit
e9befdfca5
@ -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__':
|
||||
|
Loading…
Reference in New Issue
Block a user