def keystone_auth(auth_details):
try:
if auth_details['OS_AUTH_URL'].endswith('v3'):
k_client = k3_client
else:
k_client = k2_client
tenant_name = auth_details['OS_TENANT_NAME']
keystone = k_client.Client(username=auth_details['OS_USERNAME'],
password=auth_details['OS_PASSWORD'],
tenant_name=tenant_name,
auth_url=auth_details['OS_AUTH_URL'])
except Exception as e:
status_err(str(e))
try:
with open(TOKEN_FILE, 'w') as token_file:
json.dump(keystone.auth_ref, token_file)
except IOError:
# if we can't write the file we go on
pass
return keystone.auth_ref
评论列表
文章目录