[node-patches] Change in ovirt-node[master]: Be smarter about failed RHNSM/Satellite registrations

rbarry at redhat.com rbarry at redhat.com
Thu Nov 12 16:20:56 UTC 2015


Ryan Barry has uploaded a new change for review.

Change subject: Be smarter about failed RHNSM/Satellite registrations
......................................................................

Be smarter about failed RHNSM/Satellite registrations

Check subscription-manager when the page is loaded so we can keep
the selection on the radio widgets correct (instead of clearing
rhntype from the model), but catch unusual exit codes to reflect
whether it's not registered at all or not subscribed.

Also, auto attaching works now, so try to auto-attach in the
model.

Since subscription-manager doesn't return meaningful exit codes
(just 1 for all possible errors I've seen), check the output from
the exception.

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


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/15/48515/1

diff --git a/src/ovirt/node/setup/rhn/rhn_page.py b/src/ovirt/node/setup/rhn/rhn_page.py
index c40e45f..a866810 100755
--- a/src/ovirt/node/setup/rhn/rhn_page.py
+++ b/src/ovirt/node/setup/rhn/rhn_page.py
@@ -20,6 +20,7 @@
 # also available at http://www.gnu.org/copyleft/gpl.html.
 from ovirt.node import plugins, valid, ui, utils
 from ovirt.node.plugins import Changeset
+from ovirt.node.utils import process
 from ovirt.node.utils.network import NodeNetwork
 import rhn_model
 
@@ -110,8 +111,21 @@
                     rhntype = rhntype.title()
                 else:
                     rhntype = rhntype.upper()
-                rhn_msg = "RHNSM Registration\n\nRegistration Status: %s" \
-                          % rhntype
+
+                try:
+                    cmd = ["subscription-manager", "status"]
+                    process.check_call(cmd)
+                    rhn_msg = "RHNSM Registration\n\nRegistration Status: %s" \
+                              % rhntype
+
+                except process.CalledProcessError as e:
+                    if "Status: Unknown" in e.output:
+                        # Not registered or registration failed
+                        pass
+                    else:
+                        rhn_msg = ("Registered to %s, but there are no "
+                                   "subscriptions attached or it is otherwise"
+                                   " invalid" % rhntype)
 
             ws = [ui.Header("header[0]", rhn_msg),
                   ui.Entry("rhn.username", "Login:"),


-- 
To view, visit https://gerrit.ovirt.org/48515
To unsubscribe, visit https://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ied4c2774ab4c36b1d612fbf765f87e315adf73ac
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