[node-patches] Change in ovirt-node[ovirt-3.6]: subscription-manager can return 0 when not registered...

fabiand at redhat.com fabiand at redhat.com
Tue Dec 22 15:00:24 UTC 2015


Fabian Deutsch has uploaded a new change for review.

Change subject: subscription-manager can return 0 when not registered...
......................................................................

subscription-manager can return 0 when not registered...

Though I tested this earlier, it appears that relying on
"subcription-manager status" returning a non-zero exit code when
there was a problem registering is not reliable.

It still happens on some situations, though, so check the output,
and check again when there's an exception (just to make sure we
give users the right output)

Change-Id: Ifc8ef7dcf35634b5f67a45a44bc4f416d34ecd39
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, 10 insertions(+), 8 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/17/50917/1

diff --git a/src/ovirt/node/setup/rhn/rhn_page.py b/src/ovirt/node/setup/rhn/rhn_page.py
index 155d0cd..1840bc8 100755
--- a/src/ovirt/node/setup/rhn/rhn_page.py
+++ b/src/ovirt/node/setup/rhn/rhn_page.py
@@ -101,11 +101,11 @@
                    ui.Divider("notice.divider")])
 
         else:
-            if not cfg["rhntype"]:
-                rhn_msg = ("RHN Registration is required only if you wish " +
-                           "to use Red Hat Enterprise Linux with virtual " +
-                           "guests subscriptions for your guests.")
-            else:
+            rhn_msg = ("RHNSM Registration is required only if you wish " +
+                       "to use Red Hat Enterprise Linux with virtual " +
+                       "guests subscriptions for your guests.")
+
+            if cfg["rhntype"] and self._get_status(cfg) is not None:
                 rhn_msg = self._get_status(cfg)
 
             ws = [ui.Header("header[0]", rhn_msg),
@@ -241,6 +241,7 @@
         return self.ui_content()
 
     def _get_status(self, cfg):
+        rhn_msg = None
         if "satellite" in cfg["rhntype"]:
             rhntype = cfg["rhntype"].title()
         else:
@@ -248,9 +249,10 @@
 
         try:
             cmd = ["subscription-manager", "status"]
-            process.check_call(cmd)
-            rhn_msg = "RHNSM Registration\n\nRegistration Status: %s" \
-                      % rhntype
+            output = process.check_output(cmd)
+            if not "Status: Unknown" in output:
+                rhn_msg = "RHNSM Registration\n\nRegistration Status: %s" \
+                          % rhntype
 
         except process.CalledProcessError as e:
             if "Status: Unknown" in e.output:


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ifc8ef7dcf35634b5f67a45a44bc4f416d34ecd39
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: ovirt-3.6
Gerrit-Owner: Fabian Deutsch <fabiand at redhat.com>
Gerrit-Reviewer: Fabian Deutsch <fabiand at redhat.com>



More information about the node-patches mailing list