From d26633b37e08fb6906d2d3a150ee4048f00d9c98 Mon Sep 17 00:00:00 2001 From: Arif Ali Date: Thu, 3 Nov 2022 11:17:18 +0000 Subject: [PATCH] use clouds.yaml instead for the auth params --- check_openstack.py | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/check_openstack.py b/check_openstack.py index 41286fe..088911f 100644 --- a/check_openstack.py +++ b/check_openstack.py @@ -2,21 +2,17 @@ import os import requests +import yaml from novaclient.client import Client as nova_auth from keystoneclient.v3.client import Client as keystone_auth def get_credentials(): - cred = {} - cred['version'] = '2' - cred['username'] = "admin" - cred['password'] = "openstack" - cred['auth_url'] = "http://10.0.1.216:5000/v3" - cred['project_name'] = "admin" - cred['user_domain_name'] = "admin_domain" - cred['project_domain_name'] = "admin_domain" + with open('/home/arif/clouds.yaml','r') as stream: + creds = yaml.safe_load(stream)['clouds']['arif-home']['auth'] - return cred + creds['version'] = '2' + return creds def get_auth_token(): creds = get_credentials()