[node-patches] Change in ovirt-node[master]: scripts: fix RHN activation key based registrations

Nigel Jones nigjones at redhat.com
Thu Oct 11 04:21:32 UTC 2012


Nigel Jones has uploaded a new change for review.

Change subject: scripts: fix RHN activation key based registrations
......................................................................

scripts: fix RHN activation key based registrations

Correct initialization of parameters that may be missing from command line
namely OVIRT_RHN_USERNAME and OVIRT_RHN_PASSWORD.

rhbz#865237

Change-Id: Ib86694bdc904edacd1a91ad5b3546ed26953410d
Signed-off-by: Nigel Jones <nigjones at redhat.com>
---
M scripts/rhn.py
1 file changed, 21 insertions(+), 21 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/81/8481/1

diff --git a/scripts/rhn.py b/scripts/rhn.py
index d88111e..912034b 100755
--- a/scripts/rhn.py
+++ b/scripts/rhn.py
@@ -338,33 +338,33 @@
 
 
 def rhn_auto():
+    rhn_parameters = ["OVIRT_RHN_CA_CERT", "OVIRT_RHN_USERNAME",
+        "OVIRT_RHN_PASSWORD", "OVIRT_RHN_ACTIVATIONKEY", "OVIRT_RHN_PROFILE",
+        "OVIRT_RHN_ACTIVATIONKEY", "OVIRT_RHN_PROXY", "OVIRT_RHN_PROXYUSER",
+        "OVIRT_RHN_PROXYPASSWORD"]
+
+    # RHN_TYPE & RHN_URL have defaults if not present, set them here
     if not "OVIRT_RHN_TYPE" in OVIRT_VARS:
-        OVIRT_VARS["OVIRT_RHN_TYPE"] = classic
+        OVIRT_VARS["OVIRT_RHN_TYPE"] = "classic"
     if not "OVIRT_RHN_URL" in OVIRT_VARS:
         OVIRT_VARS["OVIRT_RHN_URL"] = "https://xmlrpc.rhn.redhat.com/XMLRPC"
-    if not "OVIRT_RHN_CA_CERT" in OVIRT_VARS:
-        OVIRT_VARS["OVIRT_RHN_CA_CERT"] = ""
-    if (not "OVIRT_RHN_USERNAME" in OVIRT_VARS and
-        not "OVIRT_RHN_ACTIVATIONKEY" in OVIRT_VARS):
-            logger.debug("RHN registration requires a username")
+
+    # Default everything else to ""
+    for parameter in rhn_parameters:
+        if not parameter in OVIRT_VARS:
+            OVIRT_VARS[parameter] = ""
+
+    # We know USERNAME, PASSWORD & ACTIVATIONKEY are present
+    # verify if username+password or activationkey is not ""
+    if ((not OVIRT_VARS['OVIRT_RHN_USERNAME'] or
+            not OVIRT_VARS['OVIRT_RHN_PASSWORD']) and
+        not OVIRT_VARS['OVIRT_RHN_ACTIVATIONKEY']):
+            logger.debug("RHN registration requires a username and " +
+                "password, or an activation key.")
             return False
-    if (not "OVIRT_RHN_PASSWORD" in OVIRT_VARS and
-        not "OVIRT_RHN_ACTIVATIONKEY" in OVIRT_VARS):
-        logger.debug("RHN registration requires a password")
-        return False
-    if not "OVIRT_RHN_PROFILE" in OVIRT_VARS:
-        OVIRT_VARS["OVIRT_RHN_PROFILE"] = ""
-    if not "OVIRT_RHN_ACTIVATIONKEY" in OVIRT_VARS:
-        OVIRT_VARS["OVIRT_RHN_ACTIVATIONKEY"] = ""
-    if not "OVIRT_RHN_PROXY" in OVIRT_VARS:
-        OVIRT_VARS["OVIRT_RHN_PROXY"] = ""
-    if not "OVIRT_RHN_PROXYUSER" in OVIRT_VARS:
-        OVIRT_VARS["OVIRT_RHN_PROXYUSER"] = ""
-    if not "OVIRT_RHN_PROXYPASSWORD" in OVIRT_VARS:
-        OVIRT_VARS["OVIRT_RHN_PROXYPASSWORD"] = ""
 
     if (not "https://xmlrpc.rhn.redhat.com/XMLRPC" in
-        OVIRT_VARS["OVIRT_RHN_URL"] and OVIRT_VARS["OVIRT_RHN_CA_CERT"] == ""):
+        OVIRT_VARS["OVIRT_RHN_URL"] and not OVIRT_VARS["OVIRT_RHN_CA_CERT"]):
         logger.debug("Missing Satellite CA certificate URL")
         return False
 


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ib86694bdc904edacd1a91ad5b3546ed26953410d
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Nigel Jones <nigjones at redhat.com>



More information about the node-patches mailing list