Bugfix: yardstick https support 19/30319/1
authorchenjiankun <chenjiankun1@huawei.com>
Fri, 10 Mar 2017 10:43:28 +0000 (10:43 +0000)
committerJack Chan <chenjiankun1@huawei.com>
Mon, 13 Mar 2017 06:22:17 +0000 (06:22 +0000)
JIRA: YARDSTICK-587

When run in https environment, there is a bug:
error: failed to deploy stack: '_init_() got an unexpected keyword argument 'ca_cert''
The reason is the key pass to Session() is cacert, but the key should be
verify.

Change-Id: Ia9fc1d7908c2fca9d827a5f64deac7cd333d5c07
Signed-off-by: chenjiankun <chenjiankun1@huawei.com>
(cherry picked from commit 747e3c5f8a882b07b6876aae61c84d05a8b832f4)

yardstick/common/openstack_utils.py

index aa369b8..2df8fa5 100644 (file)
@@ -62,20 +62,6 @@ def get_credentials():
                 "project_domain_name": os.getenv('OS_PROJECT_DOMAIN_NAME')
             })
 
-    cacert = os.environ.get("OS_CACERT")
-
-    if cacert is not None:
-        # each openstack client uses differnt kwargs for this
-        creds.update({"cacert": cacert,
-                      "ca_cert": cacert,
-                      "https_ca_cert": cacert,
-                      "https_cacert": cacert,
-                      "ca_file": cacert})
-        creds.update({"insecure": "True", "https_insecure": "True"})
-        if not os.path.isfile(cacert):
-            log.info("WARNING: The 'OS_CACERT' environment variable is set \
-                      to %s but the file does not exist.", cacert)
-
     return creds
 
 
@@ -88,7 +74,12 @@ def get_session_auth():
 
 def get_session():
     auth = get_session_auth()
-    return session.Session(auth=auth)
+    try:
+        cacert = os.environ['OS_CACERT']
+    except KeyError:
+        return session.Session(auth=auth)
+    else:
+        return session.Session(auth=auth, verify=cacert)
 
 
 def get_endpoint(service_type, endpoint_type='publicURL'):