[node-patches] Change in ovirt-node[master]: Restore kdump config on ctrl+c, don't disable

rbarry at redhat.com rbarry at redhat.com
Thu Dec 18 19:11:10 UTC 2014


Ryan Barry has uploaded a new change for review.

Change subject: Restore kdump config on ctrl+c, don't disable
......................................................................

Restore kdump config on ctrl+c, don't disable

Since we already do this on an exception, it's pretty easy to
move it out. If users press ctrl+c, restore kdump. Move the
restoring to a method so it's reusable.

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


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/90/36290/1

diff --git a/src/ovirt/node/setup/core/kdump_page.py b/src/ovirt/node/setup/core/kdump_page.py
old mode 100644
new mode 100755
index c0fa7a5..164d978
--- a/src/ovirt/node/setup/core/kdump_page.py
+++ b/src/ovirt/node/setup/core/kdump_page.py
@@ -186,34 +186,31 @@
                 console.wait_for_keypress()
         except KeyboardInterrupt:
             def _handler(signum, frame):
-                console.writeln("\nWait for configuration to be reset\n")
+                console.writeln("\nWait for configuration to be restored\n")
             with self.application.ui.suspended():
                 _original_sigint = signal.getsignal(signal.SIGINT)
                 signal.signal(signal.SIGINT, _handler)
-                model.configure_disable()
-                txs = model.transaction()
-                txs()
-                console.reset()
-                console.writeln("\nDisabled kdump and Removed related " +
-                                "configuration")
-                console.writeln("\nPlease press any key to continue")
-                console.wait_for_keypress()
+                self.restore_config(saved_model)
                 signal.signal(signal.SIGINT, _original_sigint)
+                return InfoDialog("dialog.restore", "Restored the "
+                                  "configuration on keyboard interrupt")
         except Exception as e:
-            # Restore the configuration
-            if saved_model["kdump.type"] == "nfs":
-                model.configure_nfs(saved_model["kdump.nfs_location"])
-            elif saved_model["kdump.type"] == "kdump.ssh_location":
-                if self.model()["kdump.ssh_key"]:
-                    model.configure_ssh(saved_model['kdump.ssh_location'],
-                                        saved_model['kdump.ssh_key'])
-                else:
-                    model.configure_ssh(saved_model['kdump.ssh_location'])
-            elif saved_model["kdump.type"] == "local":
-                model.configure_local()
-            else:
-                model.configure_disable()
+            self.restore_config(saved_model)
             self.logger.exception("Exception while configuring kdump")
             self.application.show(self.ui_content())
             return InfoDialog("dialog.info", "An error occurred", e.message)
         return self.ui_content()
+
+    def restore_config(self, saved_model):
+        if saved_model["kdump.type"] == "nfs":
+            model.configure_nfs(saved_model["kdump.nfs_location"])
+        elif saved_model["kdump.type"] == "kdump.ssh_location":
+            if self.model()["kdump.ssh_key"]:
+                model.configure_ssh(saved_model['kdump.ssh_location'],
+                                    saved_model['kdump.ssh_key'])
+            else:
+                model.configure_ssh(saved_model['kdump.ssh_location'])
+        elif saved_model["kdump.type"] == "local":
+            model.configure_local()
+        else:
+            model.configure_disable()


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

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