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

fabiand at redhat.com fabiand at redhat.com
Tue Jan 6 17:32:58 UTC 2015


Fabian Deutsch 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>
(cherry picked from commit fd4d21e0e7178c5f65038021decbf5483078edc5)
---
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/20/36620/1

diff --git a/src/ovirt/node/setup/rhn/rhn_model.py b/src/ovirt/node/setup/rhn/rhn_model.py
index e7aad86..a808200 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:
+                self.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/36620
To unsubscribe, visit http://gerrit.ovirt.org/settings

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



More information about the node-patches mailing list