bug-fix: insecure option for quota setting
[bottlenecks.git] / utils / infra_setup / heat / common.py
index 28257ac..f0512b0 100755 (executable)
@@ -54,20 +54,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
 
 
@@ -80,7 +66,16 @@ def get_session_auth():
 
 def get_session():
     auth = get_session_auth()
-    return session.Session(auth=auth)
+    if os.getenv('OS_INSECURE', '').lower() == 'true':
+        cacert = False
+        return session.Session(auth=auth, verify=cacert)
+    else:
+        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'):
@@ -97,6 +92,7 @@ def get_heat_api_version():
         return api_version
     return DEFAULT_HEAT_API_VERSION
 
+
 def get_nova_api_version():
     api_version = os.getenv('OS_COMPUTE_API_VERSION')
     if api_version is not None:
@@ -110,4 +106,4 @@ def get_glance_api_version():
     if api_version is not None:
         log.info("GLANCE_API_VERSION is set in env as '%s'", api_version)
         return api_version
-    return DEFAULT_GLANCE_API_VERSION
\ No newline at end of file
+    return DEFAULT_GLANCE_API_VERSION