Add support for TLS enabled endpoints
Change-Id: I4d8461bf06d28a2c7afd9a57c18e151ecabfc4d6
This commit is contained in:
parent
e4cc5697b7
commit
3370ffda01
|
@ -31,6 +31,8 @@ class Credentials(object):
|
|||
dct['password'] = self.rc_password
|
||||
dct['auth_url'] = self.rc_auth_url
|
||||
dct['tenant_name'] = self.rc_tenant_name
|
||||
dct['cacert'] = self.rc_cacert
|
||||
dct['ca_cert'] = self.rc_cacert
|
||||
return dct
|
||||
|
||||
def get_nova_credentials(self):
|
||||
|
@ -39,6 +41,7 @@ class Credentials(object):
|
|||
dct['api_key'] = self.rc_password
|
||||
dct['auth_url'] = self.rc_auth_url
|
||||
dct['project_id'] = self.rc_tenant_name
|
||||
dct['cacert'] = self.rc_cacert
|
||||
return dct
|
||||
|
||||
def get_nova_credentials_v2(self):
|
||||
|
@ -71,6 +74,8 @@ class Credentials(object):
|
|||
self.rc_auth_url = value
|
||||
elif name == 'TENANT_NAME':
|
||||
self.rc_tenant_name = value
|
||||
elif name == 'CACERT':
|
||||
self.rc_cacert = value
|
||||
|
||||
# Read a openrc file and take care of the password
|
||||
# The 2 args are passed from the command line and can be None
|
||||
|
@ -79,6 +84,7 @@ class Credentials(object):
|
|||
self.rc_username = None
|
||||
self.rc_tenant_name = None
|
||||
self.rc_auth_url = None
|
||||
self.rc_cacert = None
|
||||
self.openrc_contents = openrc_contents
|
||||
success = True
|
||||
|
||||
|
@ -104,6 +110,7 @@ class Credentials(object):
|
|||
self.rc_username = os.environ['OS_USERNAME']
|
||||
self.rc_auth_url = os.environ['OS_AUTH_URL']
|
||||
self.rc_tenant_name = os.environ['OS_TENANT_NAME']
|
||||
self.rc_cacert = os.environ.get('OS_CACERT', None)
|
||||
|
||||
# always override with CLI argument if provided
|
||||
if pwd:
|
||||
|
|
|
@ -58,7 +58,7 @@ def create_keystone_client(creds):
|
|||
Return the keystone client and auth URL given a credential
|
||||
"""
|
||||
creds = creds.get_credentials()
|
||||
return (keystoneclient.Client(endpoint_type='publicURL', **creds), creds['auth_url'])
|
||||
return keystoneclient.Client(endpoint_type='publicURL', **creds)
|
||||
|
||||
|
||||
class Kloud(object):
|
||||
|
@ -68,7 +68,8 @@ class Kloud(object):
|
|||
self.scale_cfg = scale_cfg
|
||||
self.reusing_tenants = reusing_tenants
|
||||
self.storage_mode = storage_mode
|
||||
self.keystone, self.auth_url = create_keystone_client(cred)
|
||||
self.cred = cred
|
||||
self.keystone = create_keystone_client(cred)
|
||||
self.flavor_to_use = None
|
||||
self.vm_up_count = 0
|
||||
self.res_logger = KBResLogger()
|
||||
|
@ -270,14 +271,8 @@ class KloudBuster(object):
|
|||
self.testing_kloud = None
|
||||
|
||||
def get_hypervisor_list(self, cred):
|
||||
creden_nova = {}
|
||||
ret_list = []
|
||||
cred_dict = cred.get_credentials()
|
||||
creden_nova['username'] = cred_dict['username']
|
||||
creden_nova['api_key'] = cred_dict['password']
|
||||
creden_nova['auth_url'] = cred_dict['auth_url']
|
||||
creden_nova['project_id'] = cred_dict['tenant_name']
|
||||
creden_nova['version'] = 2
|
||||
creden_nova = cred.get_nova_credentials_v2()
|
||||
nova_client = novaclient(endpoint_type='publicURL',
|
||||
http_log_debug=True, **creden_nova)
|
||||
for hypervisor in nova_client.hypervisors.list():
|
||||
|
@ -287,14 +282,8 @@ class KloudBuster(object):
|
|||
return ret_list
|
||||
|
||||
def get_az_list(self, cred):
|
||||
creden_nova = {}
|
||||
ret_list = []
|
||||
cred_dict = cred.get_credentials()
|
||||
creden_nova['username'] = cred_dict['username']
|
||||
creden_nova['api_key'] = cred_dict['password']
|
||||
creden_nova['auth_url'] = cred_dict['auth_url']
|
||||
creden_nova['project_id'] = cred_dict['tenant_name']
|
||||
creden_nova['version'] = 2
|
||||
creden_nova = cred.get_nova_credentials_v2()
|
||||
nova_client = novaclient(endpoint_type='publicURL',
|
||||
http_log_debug=True, **creden_nova)
|
||||
for az in nova_client.availability_zones.list():
|
||||
|
@ -307,17 +296,21 @@ class KloudBuster(object):
|
|||
|
||||
def check_and_upload_images(self, retry_count=150):
|
||||
retry = 0
|
||||
keystone_list = [create_keystone_client(self.server_cred)[0],
|
||||
create_keystone_client(self.client_cred)[0]]
|
||||
keystone_dict = dict(zip(['Server kloud', 'Client kloud'], keystone_list))
|
||||
|
||||
creds_list = [
|
||||
{'keystone': create_keystone_client(self.server_cred), 'cred': self.server_cred},
|
||||
{'keystone': create_keystone_client(self.client_cred), 'cred': self.client_cred}
|
||||
]
|
||||
creds_dict = dict(zip(['Server kloud', 'Client kloud'], creds_list))
|
||||
img_name_dict = dict(zip(['Server kloud', 'Client kloud'],
|
||||
[self.server_cfg.image_name, self.client_cfg.image_name]))
|
||||
|
||||
for kloud, keystone in keystone_dict.items():
|
||||
for kloud, creds in creds_dict.items():
|
||||
keystone = creds['keystone']
|
||||
cacert = creds['cred'].get_credentials()['cacert']
|
||||
glance_endpoint = keystone.service_catalog.url_for(
|
||||
service_type='image', endpoint_type='publicURL')
|
||||
glance_client = glanceclient.Client(glance_endpoint, token=keystone.auth_token)
|
||||
glance_client = glanceclient.Client(
|
||||
glance_endpoint, token=keystone.auth_token, cacert=cacert)
|
||||
try:
|
||||
# Search for the image
|
||||
img = glance_client.images.list(filters={'name': img_name_dict[kloud]}).next()
|
||||
|
|
|
@ -190,22 +190,17 @@ class User(object):
|
|||
2. Creates the neutron and nova client objects
|
||||
"""
|
||||
# Create a new neutron client for this User with correct credentials
|
||||
creden = {}
|
||||
creden = self.tenant.kloud.cred.get_credentials()
|
||||
creden['username'] = self.user_name
|
||||
creden['password'] = self.password
|
||||
creden['auth_url'] = self.tenant.kloud.auth_url
|
||||
creden['tenant_name'] = self.tenant.tenant_name
|
||||
|
||||
# Create the neutron client to be used for all operations
|
||||
self.neutron_client = neutronclient.Client(endpoint_type='publicURL', **creden)
|
||||
|
||||
# Create a new nova and cinder client for this User with correct credentials
|
||||
creden_nova = {}
|
||||
creden_nova = self.tenant.kloud.cred.get_nova_credentials_v2()
|
||||
creden_nova['username'] = self.user_name
|
||||
creden_nova['api_key'] = self.password
|
||||
creden_nova['auth_url'] = self.tenant.kloud.auth_url
|
||||
creden_nova['project_id'] = self.tenant.tenant_name
|
||||
creden_nova['version'] = 2
|
||||
|
||||
self.nova_client = novaclient.Client(endpoint_type='publicURL',
|
||||
http_log_debug=True, **creden_nova)
|
||||
|
|
Loading…
Reference in New Issue