Fix improper certificate validation for VMWare and VROPS connectors
[osm/MON.git] / osm_mon / collector / vnf_collectors / vrops / vrops_helper.py
index 8164510..eadd5c7 100644 (file)
@@ -44,10 +44,17 @@ METRIC_MULTIPLIERS = {
 
 
 class vROPS_Helper:
-    def __init__(self, vrops_site="https://vrops", vrops_user="", vrops_password=""):
+    def __init__(
+        self,
+        vrops_site="https://vrops",
+        vrops_user="",
+        vrops_password="",
+        verify_ssl=False,
+    ):
         self.vrops_site = vrops_site
         self.vrops_user = vrops_user
         self.vrops_password = vrops_password
+        self.verify_ssl = verify_ssl
 
     def get_vrops_token(self):
         """Fetches token from vrops"""
@@ -55,7 +62,10 @@ class vROPS_Helper:
         headers = {"Content-Type": "application/json", "Accept": "application/json"}
         req_body = {"username": self.vrops_user, "password": self.vrops_password}
         resp = requests.post(
-            self.vrops_site + auth_url, json=req_body, verify=False, headers=headers
+            self.vrops_site + auth_url,
+            json=req_body,
+            verify=self.verify_ssl,
+            headers=headers,
         )
         if resp.status_code != 200:
             log.error(
@@ -78,7 +88,9 @@ class vROPS_Helper:
         }
         resource_list = []
 
-        resp = requests.get(self.vrops_site + api_url, verify=False, headers=headers)
+        resp = requests.get(
+            self.vrops_site + api_url, verify=self.verify_ssl, headers=headers
+        )
 
         if resp.status_code != 200:
             log.error(
@@ -144,7 +156,7 @@ class vROPS_Helper:
             }
 
             resp = requests.get(
-                self.vrops_site + api_url, verify=False, headers=headers
+                self.vrops_site + api_url, verify=self.verify_ssl, headers=headers
             )
 
             if resp.status_code != 200: