Ryan Barry 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 <[email protected]> --- 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/42/50542/1 diff --git a/src/ovirt/node/setup/rhn/rhn_page.py b/src/ovirt/node/setup/rhn/rhn_page.py index 0c37f40..28da855 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 = ("RHNSM 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/50542 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ifc8ef7dcf35634b5f67a45a44bc4f416d34ecd39 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-node Gerrit-Branch: master Gerrit-Owner: Ryan Barry <[email protected]> _______________________________________________ node-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/node-patches
