[node-patches] Change in ovirt-node[master]: use sam when registering sat6+

rbarry at redhat.com rbarry at redhat.com
Fri Jul 18 15:31:40 UTC 2014


Hello Joey Boggs,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/30282

to review the following change.

Change subject: use sam when registering sat6+
......................................................................

use sam when registering sat6+

Use SAM/subscription-manager instead of legacy registration for
new Satellite.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1067355
Change-Id: I9906ef0e605c3936ba4d1cf7b80e8a83e5863d19
Signed-off-by: Joey Boggs <jboggs at redhat.com>
---
M src/ovirt/node/setup/rhn/rhn_model.py
M src/ovirt/node/setup/rhn/rhn_page.py
2 files changed, 27 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/82/30282/1

diff --git a/src/ovirt/node/setup/rhn/rhn_model.py b/src/ovirt/node/setup/rhn/rhn_model.py
index a337f1b..63788ad 100644
--- a/src/ovirt/node/setup/rhn/rhn_model.py
+++ b/src/ovirt/node/setup/rhn/rhn_model.py
@@ -194,12 +194,19 @@
                     sys.path.append("/usr/share/rhn")
                     from virtualization import support
                     support.refresh(True)
+                    # find old SAM/Sat 6 registrations
+                    if Config().exists("/etc/rhsm/rhsm.conf"):
+                        process.call(["subscription-manager",
+                                            "remove", "--all"])
+                        process.call(["subscription-manager", "clean"])
+                        Config().unpersist("/etc/rhsm/rhsm.conf")
                 except:
                     self.logger.exception("Failed to call: %s" % logged_args)
                     raise RuntimeError("Error registering to RHN account")
 
         class ConfigureSAM(utils.Transaction.Element):
-            title = "Configuring SAM"
+            # sam path is used for sat6 as well, making generic
+            title = "Registering to Server..."
 
             def commit(self):
                 cfg = RHN().retrieve()
@@ -270,9 +277,15 @@
                 smconf.append(host)
                 smconf.append('--server.port')
                 smconf.append(port)
-                smconf.append('--server.prefix')
-                smconf.append(prefix)
-
+                if not cacert.endswith(".pem"):
+                    smconf.append('--server.prefix')
+                    smconf.append(prefix)
+                else:
+                    smconf.append('--rhsm.baseurl')
+                    if prefix:
+                        smconf.append("%s/%s" % (host, prefix))
+                    else:
+                        smconf.append(host + '/pulp/repos')
                 if cacert:
                     smconf.append('--rhsm.repo_ca_cert')
                     smconf.append('/etc/rhsm/ca/candlepin-local.pem')
@@ -356,9 +369,10 @@
         cfg = self.retrieve()
         self.logger.debug(cfg)
         rhntype = cfg["rhntype"]
+        cacert = cfg["ca_cert"]
         tx = utils.Transaction("Performing RHN Registration")
 
-        if rhntype == "sam":
+        if rhntype == "sam" or cacert.endswith(".pem"):
             tx.append(ConfigureSAM())
         else:
             tx.append(ConfigureRHNClassic())
diff --git a/src/ovirt/node/setup/rhn/rhn_page.py b/src/ovirt/node/setup/rhn/rhn_page.py
index f3c920d..518914b 100644
--- a/src/ovirt/node/setup/rhn/rhn_page.py
+++ b/src/ovirt/node/setup/rhn/rhn_page.py
@@ -139,7 +139,7 @@
 
         rhn_conf = get_rhn_config()
         status, rhn_type = get_rhn_status()
-        model["rhn.type"] = rhn_type.lower()
+        model["rhn.type"] = cfg["rhntype"]
         model["rhn.profilename"] = cfg["profile"]
         if RHN_XMLRPC_ADDR not in rhn_conf["serverURL"] and not sam_check():
             model["rhn.url"] = rhn_conf["serverURL"] if rhn_conf["serverURL"]\
@@ -183,6 +183,7 @@
                 }
 
     def ui_content(self):
+        cfg = rhn_model.RHN().retrieve()
         if self.application.args.dry:
             net_is_configured = True
         else:
@@ -203,8 +204,13 @@
                            "to use Red Hat Enterprise Linux with virtual " +
                            "guests subscriptions for your guests.")
             else:
+                rhntype = cfg["rhntype"]
+                if "satellite" in rhntype:
+                    rhntype = rhntype.title()
+                else:
+                    rhntype = rhntype.upper()
                 rhn_msg = "RHN Registration\n\nRegistration Status: %s" \
-                          % rhn_type
+                          % rhntype
 
             ws = [ui.Header("header[0]", rhn_msg),
                   ui.Entry("rhn.user", "Login:"),


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

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



More information about the node-patches mailing list