[node-patches] Change in ovirt-node[master]: Make rhn_model work with Satellite 6

rbarry at redhat.com rbarry at redhat.com
Fri Nov 7 15:26:24 UTC 2014


Ryan Barry has uploaded a new change for review.

Change subject: Make rhn_model work with Satellite 6
......................................................................

Make rhn_model work with Satellite 6

First, don't try --autosubscribe, since it's caused problems with
SAM and Satellite 6. Don't remove it, but leave it disabled until
we clarify what's supposed to happen here.

If an organization is specified, use it. Check whether the call
prompts for one to see if we're trying to hit Sat6 without
specificying one.

Use process.pipe instead of check_output so we don't wait forever
if it is prompting.

Don't use wget. It shifts the TUI. urllib.urlrequest is an easy to
use pythonic replacement.

Change-Id: Ifc5f87400efa351c8fa4cd4ced9fc8b4462e9d2e
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1067355
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M src/ovirt/node/setup/rhn/rhn_model.py
1 file changed, 33 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/41/34941/1

diff --git a/src/ovirt/node/setup/rhn/rhn_model.py b/src/ovirt/node/setup/rhn/rhn_model.py
index c9728cb..7774470 100644
--- a/src/ovirt/node/setup/rhn/rhn_model.py
+++ b/src/ovirt/node/setup/rhn/rhn_model.py
@@ -27,6 +27,7 @@
 import os.path
 import glob
 import subprocess
+import urllib
 
 
 RHN_XMLRPC_ADDR = "https://xmlrpc.rhn.redhat.com/XMLRPC"
@@ -80,12 +81,18 @@
         return cfg
 
     def retrieveCert(self, url, dest):
-        try:
-            cmd = ["wget", "-nd", "--no-check-certificate", "--timeout=30",
-                   "--tries=3", "-O", dest, url]
-            subprocess.check_call(cmd)
-        except:
-            raise RuntimeError("Error Downloading SSL Certificate!")
+        for x in range(0, 3):
+            try:
+                # urllib doesn't check ssl certs, so we're ok here
+                urllib.urlretrieve(url, dest)
+                return
+            except IOError:
+                logger.debug(
+                    "Failed to download {url} on try {x}".format(
+                        url=url, x=x))
+
+        # If we're here, we failed to get it
+        raise RuntimeError("Error downloading SSL certificate!")
 
     def transaction(self, password, proxypass=None):
 
@@ -224,8 +231,12 @@
                     conf.unpersist("/etc/sysconfig/rhn/systemid")
 
                 extra_args = ['--force']
-                if not activationkey:
-                    extra_args.append("--autosubscribe")
+
+                # Don't autosubscribe for now, since it may cause entitlement
+                # problems with SAM and Sat6
+                # if not activationkey:
+                #     extra_args.append("--autosubscribe")
+
                 sm = ['/usr/sbin/subscription-manager']
 
                 args = list(sm)
@@ -241,6 +252,9 @@
                     if password:
                         args.append('--password')
                         args.append(password)
+                    if org:
+                        args.append('--org')
+                        args.append(org)
                 else:
                     # skip RHN registration when neither activationkey
                     # nor username/password is supplied
@@ -251,6 +265,8 @@
                     (host, port) = parse_host_port(serverurl)
                     parsed_url = urlparse(serverurl)
                     prefix = parsed_url.path
+                    if cacert.endswith(".pem") and rhntype == "satellite":
+                        prefix = "/rhsm"
                     if port == 0:
                         port = "443"
                     else:
@@ -276,7 +292,8 @@
                 smconf.append(host)
                 smconf.append('--server.port')
                 smconf.append(port)
-                if cacert and not cacert.endswith(".pem"):
+                if cacert and not cacert.endswith(".pem") or \
+                   rhntype == "satellite":
                     smconf.append('--server.prefix')
                     smconf.append(prefix)
                 else:
@@ -349,7 +366,9 @@
                 logged_args = str(logged_args)
                 self.logger.info(logged_args)
 
-                smreg_output = process.check_output(args)
+                # This may block if waiting for input with check_output.
+                # pipe doesn't block
+                smreg_output = process.pipe(args)
                 if "been registered" not in smreg_output:
                     if "Invalid credentials" in smreg_output:
                         raise RuntimeError("Invalid Username / Password")
@@ -357,6 +376,10 @@
                         raise RuntimeError("Hostname is already " +
                                            "registered")
 
+                    if "Organization" in smreg_output:
+                        raise RuntimeError("Organization must be specified "
+                                           "with Satellite 6")
+
                     if activationkey:
                         cmd = ["subscription-manager", "auto-attach"]
                         try:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifc5f87400efa351c8fa4cd4ced9fc8b4462e9d2e
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Ryan Barry <rbarry at redhat.com>



More information about the node-patches mailing list