[node-patches] Change in ovirt-node[master]: Clean up kdump page

rbarry at redhat.com rbarry at redhat.com
Thu Dec 5 16:49:40 UTC 2013


Ryan Barry has uploaded a new change for review.

Change subject: Clean up kdump page
......................................................................

Clean up kdump page

Hide the implementation details of the kdump model in the model
itself, so we don't need to worry about passing the correct
number of arguments every time they change, and we can use have a
more logical flow in the view itself.

Change-Id: I2b1fe1c2303aa022e0064e431f930d5fc9226bec
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M src/ovirt/node/config/defaults.py
M src/ovirt/node/setup/core/kdump_page.py
2 files changed, 24 insertions(+), 14 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/03/22103/1

diff --git a/src/ovirt/node/config/defaults.py b/src/ovirt/node/config/defaults.py
index befacfd..9fa4a90 100644
--- a/src/ovirt/node/config/defaults.py
+++ b/src/ovirt/node/config/defaults.py
@@ -1015,6 +1015,18 @@
         return {"OVIRT_KDUMP_LOCAL": "true" if local else None
                 }
 
+    def configure_nfs(self, nfs_location):
+        self.update(nfs_location, None, None, None)
+
+    def configure_ssh(self, ssh_location, ssh_key=None):
+        self.update(None, ssh_location, ssh_key, None)
+
+    def configure_local(self):
+        self.update(None, None, None, True)
+
+    def disable_kdump(self):
+        self.update(None, None, None, None)
+
     def retrieve(self):
         cfg = dict(NodeConfigFileSection.retrieve(self))
         cfg.update({"local": True if cfg["local"] == "true" else None
diff --git a/src/ovirt/node/setup/core/kdump_page.py b/src/ovirt/node/setup/core/kdump_page.py
index 58a4038..799eb02 100644
--- a/src/ovirt/node/setup/core/kdump_page.py
+++ b/src/ovirt/node/setup/core/kdump_page.py
@@ -161,16 +161,16 @@
             ktype, sshloc, sshkey, nfsloc = effective_model.values_for(
                 kdump_keys)
             if ktype == "nfs":
-                model.update(nfsloc, None, None, None)
+                model.configure_nfs(nfsloc)
             elif ktype == "ssh":
                 if "kdump.ssh_key" in changes:
-                    model.update(None, sshloc, sshkey, None)
+                    model.configure_ssh(sshloc, ssh_key=sshkey)
                 else:
-                    model.update(None, sshloc, None, None)
+                    model.configure_ssh(sshloc)
             elif ktype == "local":
-                model.update(None, None, None, True)
+                model.configure_local()
             else:
-                model.update(None, None, None, None)
+                model.disable_kdump()
             txs += model.transaction()
 
         try:
@@ -183,7 +183,7 @@
                 console.wait_for_keypress()
         except KeyboardInterrupt:
             with self.application.ui.suspended():
-                model.update(None, None, None)
+                model.disable_kdump()
                 txs = model.transaction()
                 txs()
                 console.reset()
@@ -194,19 +194,17 @@
         except Exception as e:
             # Restore the configuration
             if saved_model["kdump.type"] == "nfs":
-                model.update(saved_model["kdump.nfs_location"], None, None, 
-                             None)
+                model.configure_nfs(saved_model["kdump.nfs_location"])
             elif saved_model["kdump.type"] == "kdump.ssh_location":
                 if self.model()["kdump.ssh_key"] is not "":
-                    model.update(None, saved_model['kdump.ssh_location'], 
-                                 saved_model['kdump.ssh_key'], None)
+                    model.configure_ssh(saved_model['kdump.ssh_location'],
+                                        ssh_key=saved_model['kdump.ssh_key'])
                 else:
-                    model.update(None, saved_model['kdump.ssh_location'], 
-                                 None, None)
+                    model.configure_ssh(saved_model['kdump.ssh_location'])
             elif saved_model["kdump.type"] == "local":
-                model.update(None, None, None, True)
+                model.configure_local()
             else:
-                model.update(None, None, None, None)
+                model.disable_kdump()
             self.logger.exception("Exception while configuring kdump")
             self.application.show(self.ui_content())
             return InfoDialog("dialog.info", _("An error occurred"), e.message)


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

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