Simone Tiraboschi has uploaded a new change for review.

Change subject: ovirt-iso-uploader: fixing usage of API SDK insecure parameter
......................................................................

ovirt-iso-uploader: fixing usage of API SDK insecure parameter

Python SDK insecure parameter simply skips hostname validation,
it still gives errors if we also pass an unmatching CA cert.

Change-Id: Ie72fbef874f595d60e0441a212329dfb07223c16
Bug-Url: https://bugzilla.redhat.com/1136768
Signed-off-by: Simone Tiraboschi <stira...@redhat.com>
---
M src/__main__.py
1 file changed, 17 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-iso-uploader 
refs/changes/04/32604/1

diff --git a/src/__main__.py b/src/__main__.py
index 505ed99..b149415 100644
--- a/src/__main__.py
+++ b/src/__main__.py
@@ -491,13 +491,20 @@
 
             try:
                 # If "insecure" option was provided, use it during API creation
-                self.api = API(
-                    url=url,
-                    username=self.configuration.get("user"),
-                    password=self.configuration.get("passwd"),
-                    ca_file=self.configuration.get("cert_file"),
-                    insecure=self.configuration.get("insecure"),
-                )
+                if self.configuration.get("insecure"):
+                    self.api = API(
+                        url=url,
+                        username=self.configuration.get("user"),
+                        password=self.configuration.get("passwd"),
+                        insecure=True,
+                    )
+                else:
+                    self.api = API(
+                        url=url,
+                        username=self.configuration.get("user"),
+                        password=self.configuration.get("passwd"),
+                        ca_file=self.configuration.get("cert_file"),
+                    )
 
                 pi = self.api.get_product_info()
                 if pi is not None:
@@ -554,7 +561,7 @@
             return ary[0]
 
         if not self._initialize_api():
-            return
+            sys.exit(ExitCodes.CRITICAL)
 
         dcAry = self.api.datacenters.list()
         if dcAry is not None:
@@ -615,7 +622,7 @@
           (host, id, path)
         """
         if not self._initialize_api():
-            return
+            sys.exit(ExitCodes.CRITICAL)
         sd = self.api.storagedomains.get(isodomain)
         if sd is not None:
             if sd.get_type() != 'iso':
@@ -910,7 +917,7 @@
         RESTful method will cause it to refresh that list.
         """
         if not self._initialize_api():
-            return
+            sys.exit(ExitCodes.CRITICAL)
         try:
             sd = self.api.storagedomains.get(id=id)
             if sd is not None and sd.files is not None:


-- 
To view, visit http://gerrit.ovirt.org/32604
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ie72fbef874f595d60e0441a212329dfb07223c16
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-iso-uploader
Gerrit-Branch: ovirt-iso-uploader-3.4
Gerrit-Owner: Simone Tiraboschi <stira...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to