Merge "[Bug:2126848] Client Cert Mangement Changes to test no certificate and keyerror"

This commit is contained in:
Zuul 2018-06-20 02:23:50 +00:00 committed by Gerrit Code Review
commit c5e1410964
1 changed files with 19 additions and 4 deletions

View File

@ -580,11 +580,26 @@ class NSXV3Client(object):
Get self signed openstack client certificate
"""
cert_response = self.get_nsx_certificate()
i_err = "No certificates in the backend"
k_err = "Argument does not exist in the certificate"
#check for empty certificates
try:
cert_response['results'][0]
except Exception:
LOG.exception(i_err)
raise
#check if openstack certificate is enabled
for cert in cert_response['results']:
if (cert["_create_user"] == "admin" and cert[
"resource_type"] == "certificate_self_signed" and cert[
"display_name"] != "NSX MP Client Certificate for Key "
"Manager"):
try:
cert['used_by'][0]['service_types']
cert["_create_user"]
except Exception:
LOG.exception(k_err)
raise
if (cert['used_by'][0]['service_types'][0] ==
'Client Authentication' and cert["_create_user"] == "admin"
and "'com.vmware.nsx.openstack'"
in cert['used_by'][0]['node_id']):
LOG.info('Client certificate created')
return cert
LOG.error("Client Certificate not created")