[node-patches] Change in ovirt-node[master]: ui: Use ConfirmedEntry on CIM and SNMP page too

fabiand at fedoraproject.org fabiand at fedoraproject.org
Fri Jun 28 10:49:47 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: ui: Use ConfirmedEntry on CIM and SNMP page too
......................................................................

ui: Use ConfirmedEntry on CIM and SNMP page too

Change-Id: I25f75ee8254c3e6ccd6dcb2fc7ace1e084e799b4
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M src/ovirt/node/setup/cim/cim_page.py
M src/ovirt/node/setup/snmp/snmp_page.py
2 files changed, 9 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/21/16221/1

diff --git a/src/ovirt/node/setup/cim/cim_page.py b/src/ovirt/node/setup/cim/cim_page.py
index 776e0e9..7a5ee7d 100644
--- a/src/ovirt/node/setup/cim/cim_page.py
+++ b/src/ovirt/node/setup/cim/cim_page.py
@@ -18,7 +18,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.  A copy of the GNU General Public License is
 # also available at http://www.gnu.org/copyleft/gpl.html.
-from ovirt.node import plugins, valid, ui, utils, exceptions
+from ovirt.node import plugins, valid, ui, utils
 import cim_model
 from ovirt.node.plugins import Changeset
 
@@ -48,8 +48,8 @@
         self.logger.debug(cfg)
         model = {"cim.enabled": True if cfg["enabled"] else False,
                  "cim.password": "",
-                 "cim.password_confirmation": "",
                  }
+        model.update(self._model)
         return model
 
     def validators(self):
@@ -60,9 +60,7 @@
               ui.Checkbox("cim.enabled", "Enable CIM"),
               ui.Divider("divider[0]"),
               ui.Header("header[1]", "CIM Password"),
-              ui.PasswordEntry("cim.password", "Password:"),
-              ui.PasswordEntry("cim.password_confirmation",
-                               "Confirm Password:"),
+              ui.ConfirmedEntry("cim.password", "Password:", True)
               ]
 
         page = ui.Page("page", ws)
@@ -70,17 +68,8 @@
         return page
 
     def on_change(self, changes):
-        if changes.contains_any(["cim.password",
-                                 "cim.password_confirmation"]):
+        if changes.contains_any(["cim.password"]):
             self._model.update(changes)
-            root_pw, root_pw_conf = self._model.get("cim.password", ""), \
-                self._model.get("cim.password_confirmation", "")
-
-            if root_pw != root_pw_conf:
-                raise exceptions.InvalidData("Passwords must be the same.")
-            else:
-                self.widgets["cim.password"].valid(True)
-                self.widgets["cim.password_confirmation"].valid(True)
 
     def on_merge(self, effective_changes):
         self.logger.debug("Saving CIM page")
@@ -97,7 +86,7 @@
 
         if changes.contains_any(cim_keys):
             is_enabled = effective_model["cim.enabled"]
-            pw = effective_model["cim.password_confirmation"]
+            pw = effective_model["cim.password"]
 
             model = cim_model.CIM()
             model.update(is_enabled)
diff --git a/src/ovirt/node/setup/snmp/snmp_page.py b/src/ovirt/node/setup/snmp/snmp_page.py
index c31648d..fd8ecbd 100644
--- a/src/ovirt/node/setup/snmp/snmp_page.py
+++ b/src/ovirt/node/setup/snmp/snmp_page.py
@@ -18,7 +18,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.  A copy of the GNU General Public License is
 # also available at http://www.gnu.org/copyleft/gpl.html.
-from ovirt.node import plugins, valid, ui, utils, exceptions
+from ovirt.node import plugins, valid, ui, utils
 import snmp_model
 from ovirt.node.plugins import Changeset
 from ovirt.node.valid import RegexValidator
@@ -68,8 +68,8 @@
         self.logger.debug(cfg)
         model = {"snmp.enabled": True if cfg["password"] else False,
                  "snmp.password": "",
-                 "snmp.password_confirmation": "",
                  }
+        model.update(self._model)
         return model
 
     def validators(self):
@@ -81,9 +81,7 @@
               ui.Checkbox("snmp.enabled", "Enable SNMP"),
               ui.Divider("divider[0]"),
               ui.Header("header[1]", "SNMP Password"),
-              ui.PasswordEntry("snmp.password", "Password:"),
-              ui.PasswordEntry("snmp.password_confirmation",
-                               "Confirm Password:"),
+              ui.ConfirmedEntry("snmp.password", "Password:", True)
               ]
 
         page = ui.Page("page", ws)
@@ -91,17 +89,8 @@
         return page
 
     def on_change(self, changes):
-        if changes.contains_any(["snmp.password",
-                                 "snmp.password_confirmation"]):
+        if changes.contains_any(["snmp.password"]):
             self._model.update(changes)
-            root_pw, root_pw_conf = self._model.get("snmp.password", ""), \
-                self._model.get("snmp.password_confirmation", "")
-
-            if root_pw != root_pw_conf:
-                raise exceptions.InvalidData("Passwords must be the same.")
-            else:
-                self.widgets["snmp.password"].valid(True)
-                self.widgets["snmp.password_confirmation"].valid(True)
 
     def on_merge(self, effective_changes):
         self.logger.debug("Saving SNMP page")


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I25f75ee8254c3e6ccd6dcb2fc7ace1e084e799b4
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list