[node-patches] Change in ovirt-node[master]: Flag the appropriate kdump field if empty

rbarry at redhat.com rbarry at redhat.com
Thu Dec 12 19:01:12 UTC 2013


Ryan Barry has uploaded a new change for review.

Change subject: Flag the appropriate kdump field if empty
......................................................................

Flag the appropriate kdump field if empty

It was possible to attempt to configure kdump with an empty nfs or
ssh entry field after the appropriate checkboxes were ticked. Now,
we should dynamically determine which validator to use, remove the
ability to leave it empty, and present a warning.

Change-Id: Id3331d37771304d642515c9cb24b7a4ac9fd2f4c
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1017083
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M src/ovirt/node/setup/core/kdump_page.py
1 file changed, 36 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/57/22357/1

diff --git a/src/ovirt/node/setup/core/kdump_page.py b/src/ovirt/node/setup/core/kdump_page.py
index 58a4038..b154e0e 100644
--- a/src/ovirt/node/setup/core/kdump_page.py
+++ b/src/ovirt/node/setup/core/kdump_page.py
@@ -42,7 +42,7 @@
         return _("Kdump")
 
     def rank(self):
-        return 60
+        return -5
 
     def model(self):
         """Returns the model of this plugin
@@ -133,6 +133,25 @@
 
             w = "kdump.%s_location" % changes["kdump.type"]
             if w in net_types and w in self.widgets:
+
+                # Decide which validator to use dynamically
+                self.validators = lambda: self.__validators(
+                    changes["kdump.type"])
+
+                resubmit = [self._NodePlugin__invalid_changes,
+                            self._NodePlugin__changes]
+
+                d = {}
+                for change in resubmit:
+                    d.update(dict((k, v) for (k, v) in change.iteritems()))
+                for k, v in d.iteritems():
+                    self._on_ui_change({k: v})
+
+                # If nothing's been entered yet, pass an empty string to so we
+                # can validate or flag the field and set the right notice
+                if not w in self._NodePlugin__invalid_changes and not w in \
+                            self._NodePlugin__changes:
+                    self._on_ui_change({w: ""})
                 self.widgets[w].enabled(True)
                 if w == "kdump.ssh_location":
                     self.widgets["kdump.ssh_key"].enabled(True)
@@ -194,14 +213,14 @@
         except Exception as e:
             # Restore the configuration
             if saved_model["kdump.type"] == "nfs":
-                model.update(saved_model["kdump.nfs_location"], None, None, 
+                model.update(saved_model["kdump.nfs_location"], None, None,
                              None)
             elif saved_model["kdump.type"] == "kdump.ssh_location":
                 if self.model()["kdump.ssh_key"] is not "":
-                    model.update(None, saved_model['kdump.ssh_location'], 
+                    model.update(None, saved_model['kdump.ssh_location'],
                                  saved_model['kdump.ssh_key'], None)
                 else:
-                    model.update(None, saved_model['kdump.ssh_location'], 
+                    model.update(None, saved_model['kdump.ssh_location'],
                                  None, None)
             elif saved_model["kdump.type"] == "local":
                 model.update(None, None, None, True)
@@ -211,3 +230,16 @@
             self.application.show(self.ui_content())
             return InfoDialog("dialog.info", _("An error occurred"), e.message)
         return self.ui_content()
+
+    def __validators(self, type):
+        return {"kdump.type": valid.Options(dict(self._types).keys()),
+                "kdump.ssh_location":  (valid.SSHAddress(allow_ipv6=False)) if
+                                        type == "ssh" else
+                                        (valid.Empty() | \
+                                        valid.SSHAddress(allow_ipv6=False)),
+                "kdump.ssh_key": valid.Empty() | valid.URL(),
+                "kdump.nfs_location": (valid.NFSAddress(allow_ipv6=False)) if
+                                       type == "nfs" else
+                                       (valid.Empty() | \
+                                       valid.NFSAddress(allow_ipv6=False)),
+               }


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

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