add endpoint_type variable, and fine tune grab of credentials

This commit is contained in:
Arif Ali 2022-11-03 23:00:23 +00:00
parent 46e737d485
commit 5532a666d4
Signed by: arif
GPG Key ID: 369608FBA1353A70

View File

@ -10,13 +10,17 @@ from keystoneclient.v3.client import Client as keystone_auth
headers = {}
headers['content-type'] = 'application/json'
endpoint_type = "public"
def get_credentials(site_id):
home = os.environ['HOME']
with open('{}/clouds.yaml'.format(home), 'r') as stream:
creds = yaml.safe_load(stream)['clouds'][site_id]['auth']
clouds = yaml.safe_load(stream)['clouds']
creds = clouds[site_id]['auth']
creds['version'] = clouds[site_id]['identity_api_version']
creds['version'] = '2'
return creds
@ -28,7 +32,7 @@ def get_servers(keystone):
url = keystone.service_catalog.get_endpoints(
service_name="nova",
endpoint_type="public"
endpoint_type=endpoint_type,
)['compute'][0]['url']
request = "servers"
@ -45,7 +49,7 @@ def get_cores(keystone):
url = keystone.service_catalog.get_endpoints(
service_name="placement",
endpoint_type="public"
endpoint_type=endpoint_type,
)['placement'][0]['url']
psc_request = "resource_providers"
@ -76,7 +80,7 @@ def get_networks(keystone):
url = keystone.service_catalog.get_endpoints(
service_name="neutron",
endpoint_type="public"
endpoint_type=endpoint_type,
)['network'][0]['url']
request = "networks"