[node-patches] Change in ovirt-node[master]: Rework the RHN page a little

rbarry at redhat.com rbarry at redhat.com
Fri Nov 7 02:44:55 UTC 2014


Ryan Barry has uploaded a new change for review.

Change subject: Rework the RHN page a little
......................................................................

Rework the RHN page a little

In order to make room for an Organization field for Sat6, move
the proxy config to a dialog and add the field. Look for
"organization" in the output and let users know they need it if
we catch it being prompted for.

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


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/09/34909/1

diff --git a/src/ovirt/node/setup/rhn/rhn_model.py b/src/ovirt/node/setup/rhn/rhn_model.py
index c9728cb..e1c1320 100644
--- a/src/ovirt/node/setup/rhn/rhn_model.py
+++ b/src/ovirt/node/setup/rhn/rhn_model.py
@@ -349,7 +349,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 +359,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:
diff --git a/src/ovirt/node/setup/rhn/rhn_page.py b/src/ovirt/node/setup/rhn/rhn_page.py
index 4967edb..eceb69c 100644
--- a/src/ovirt/node/setup/rhn/rhn_page.py
+++ b/src/ovirt/node/setup/rhn/rhn_page.py
@@ -163,6 +163,7 @@
                                   valid.URL() | valid.Empty()),
                 "rhn.proxyport": valid.Port() | valid.Empty(),
                 "rhn.proxyuser": valid.Text() | valid.Empty(),
+                "rhn.org": valid.Text() | valid.Empty(),
                 }
 
     def ui_content(self):
@@ -203,12 +204,8 @@
                   ui.Options("rhn.type", "Type", self._rhn_types),
                   ui.Entry("rhn.url", "URL:"),
                   ui.Entry("rhn.ca", "CA URL:"),
-                  ui.Header("header[1]", "HTTP Proxy Configuration"),
-                  ui.Row("row[0]", [ui.Entry("rhn.proxyhost", "Server:"),
-                                    ui.Entry("rhn.proxyport", "  Port:")]),
-                  ui.Entry("rhn.proxyuser", "Username:"),
-                  ui.PasswordEntry("rhn.proxypassword", "Password:"),
-                  ui.Divider("divider[1]"),
+                  ui.Entry("rhn.org", "Organization:"),
+                  ui.Button("button.proxy", "HTTP Proxy Configuration"),
                   ]
 
         page = ui.Page("page", ws)
@@ -224,6 +221,7 @@
                     self._fields_enabled = True
                     self.widgets["rhn.url"].enabled(True)
                     self.widgets["rhn.ca"].enabled(True)
+                    self.widgets["rhn.org"].enabled(True)
                     self.stash_pop_change("rhn.url", reuse_old=True)
                     self.stash_pop_change("rhn.ca", reuse_old=True)
             else:
@@ -232,6 +230,12 @@
                 self.widgets["rhn.ca"].enabled(False)
                 self.stash_change("rhn.url")
                 self.stash_change("rhn.ca")
+
+        # Don't run a transaction yet, just close it out, save if the
+        # normal save button is triggered
+        if "proxy.save" in changes:
+            self._dialog.close()
+            return
 
     def on_merge(self, effective_changes):
         self.logger.debug("Saving RHN page")
@@ -246,6 +250,14 @@
                     "rhn.type", "rhn.url", "rhn.ca", "rhn.proxyhost",
                     "rhn.proxyport", "rhn.proxyuser", "rhn.proxypassword",
                     "rhn.org", "rhn.activation_key"]
+
+        if "button.proxy" in changes:
+            description = ("Please enter the proxy details to use " +
+                           "for contacting the management server ")
+            self._dialog = ProxyDialog("Input proxy information",
+                                       description, self)
+            self.widgets.add(self._dialog)
+            return self._dialog
 
         txs = utils.Transaction("Updating RHN configuration")
 
@@ -301,3 +313,33 @@
                                                                txs, self)
                 progress_dialog.run()
         return self.ui_content()
+
+class ProxyDialog(ui.Dialog):
+    """A dialog to input proxy information
+    """
+    def __init__(self, title, description, plugin):
+        self.keys = ["rhn.proxyhost", "rhn.proxyport", "rhn.proxyuser",
+                     "rhn.proxypassword"]
+
+        def clear_invalid(dialog, changes):
+            [plugin.stash_change(prefix) for prefix in self.keys]
+
+        title = _("RHN Proxy Information")
+
+        entries = [ui.Entry("rhn.proxyhost", "Server:"),
+                   ui.Entry("rhn.proxyport", "Port:"),
+                   ui.Entry("rhn.proxyuser", "Username:"),
+                   ui.PasswordEntry("rhn.proxypassword", "Password:")]
+        children = [ui.Label("label[0]", description),
+                    ui.Divider("divider[0]")]
+        children.extend(entries)
+        super(ProxyDialog, self).__init__("proxy.dialog", title, children)
+        self.buttons = [ui.CloseButton("proxy.save", _("Save"),
+                                      enabled=True),
+                        ui.CloseButton("proxy.close",
+                                       _("Cancel"))]
+
+        b = plugins.UIElements(self.buttons)
+        b["proxy.close"].on_activate.clear()
+        b["proxy.close"].on_activate.connect(ui.CloseAction())
+        b["proxy.close"].on_activate.connect(clear_invalid)


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

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