[node-patches] Change in ovirt-node[master]: Add parameters and code to back kdump autoinstall parameters

rbarry at redhat.com rbarry at redhat.com
Sun Aug 11 01:36:32 UTC 2013


Ryan Barry has uploaded a new change for review.

Change subject: Add parameters and code to back kdump autoinstall parameters
......................................................................

Add parameters and code to back kdump autoinstall parameters

Add backing code for local and SSH-based kdump installs

Change-Id: Ide8d438aa19f0189a4d3d37399ffd57cd8774584
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=960379
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M scripts/ovirt-auto-install.py
M scripts/ovirt-init-functions.sh.in
M src/ovirtnode/kdump.py
3 files changed, 62 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/94/17894/1

diff --git a/scripts/ovirt-auto-install.py b/scripts/ovirt-auto-install.py
index 05b58f1..7144dc4 100755
--- a/scripts/ovirt-auto-install.py
+++ b/scripts/ovirt-auto-install.py
@@ -25,6 +25,7 @@
 from ovirtnode.log import *
 from ovirtnode.kdump import *
 from ovirt.node.utils.console import TransactionProgress
+from ovirt.node.utils import process
 import logging
 import sys
 
@@ -100,7 +101,52 @@
     title = "Configuring KDump"
 
     def commit(self):
-        kdump_auto()
+        if "OVIRT_KDUMP_SSH" in OVIRT_VARS and \
+                "OVIRT_KDUMP_SSH_KEY" in OVIRT_VARS:
+            import pycurl
+            import cStringIO
+            import os
+            from ovirt.node.utils import system
+            from shutil import copy2
+
+            buf = cStringIO.StringIO()
+
+            curl = pycurl.Curl()
+            curl.setopt(curl.URL, OVIRT_VARS["OVIRT_KDUMP_SSH_KEY"])
+            curl.setopt(curl.WRITEFUNCTION, buf.write)
+            curl.perform()
+
+            os.mkdir("/tmp/kdump-ssh")
+            os.chmod("/tmp/kdump-ssh", 0600)
+            with open("/tmp/kdump-ssh/id", "w") as f:
+                f.write(buf.getvalue())
+            os.chmod("/tmp/kdump-ssh", 0600)
+
+            try:
+                ssh = process.check_call("ssh -o BatchMode=yes -i /tmp/"
+                                         "kdump-ssh/id %s true" %
+                                         OVIRT_VARS["
+                                         OVIRT_KDUMP_SSH"])
+                # If SSH works, go on
+                copy2("/tmp/kdump-ssh/id", "/root/.ssh/kdump_id_rsa")
+
+                ovirt_store_config(["root/.ssh/kdump_is_rsa",
+                                    "/root/.ssh/known_hosts",
+                                    "/root/.ssh/config"])
+                kdumpctl_cmd = system.which("kdumpctl")
+
+                if kdumpctl_cmd:
+                    cmd = [kdumpctl_cmd, "propagate"]
+                else:
+                    cmd = ["service", "kdump", "propagate"]
+                process.check_call(cmd)
+                okdump.write_kdump_config(OVIRT_VARS["OVIRT_KDUMP_SSH"])
+
+            except:
+                pass
+
+        else:
+            kdump_auto()
 
 
 class InstallBootloader(Transaction.Element):
diff --git a/scripts/ovirt-init-functions.sh.in b/scripts/ovirt-init-functions.sh.in
index 4e555d8..90113d3 100644
--- a/scripts/ovirt-init-functions.sh.in
+++ b/scripts/ovirt-init-functions.sh.in
@@ -692,6 +692,15 @@
             kdump_nfs=*)
             kdump_nfs=${i#kdump_nfs=}
             ;;
+            kdump_local=*)
+            kdump_local=${i#kdump_local=}
+            ;;
+            kdump_ssh=*)
+            kdump_ssh=${i#kdump_ssh=}
+            ;;
+            kdump_ssh_key=*)
+            kdump_ssh_key=${i#kdump_ssh_key=}
+            ;;
             iscsi_name=*)
             iscsi_name=${i#iscsi_name=}
             ;;
@@ -783,7 +792,7 @@
 
 
     # save boot parameters as defaults for ovirt-config-*
-    params="bootif init init_app vol_boot_size vol_efi_size vol_swap_size vol_root_size vol_config_size vol_logging_size vol_data_size vol_swap2_size vol_data2_size crypt_swap crypt_swap2 upgrade standalone overcommit ip_address ip_netmask ip_gateway ipv6 dns ntp vlan ssh_pwauth syslog_server syslog_port collectd_server collectd_port bootparams hostname firstboot runtime_mode kdump_nfs iscsi_name snmp_password install netconsole_server netconsole_port stateless cim_enabled wipe_fakeraid iscsi_init iscsi_target_name iscsi_target_host iscsi_target_port iscsi_install network_layout bond_name bond_slaves bond_options tuned_profile"
+    params="bootif init init_app vol_boot_size vol_efi_size vol_swap_size vol_root_size vol_config_size vol_logging_size vol_data_size vol_swap2_size vol_data2_size crypt_swap crypt_swap2 upgrade standalone overcommit ip_address ip_netmask ip_gateway ipv6 dns ntp vlan ssh_pwauth syslog_server syslog_port collectd_server collectd_port bootparams hostname firstboot runtime_mode kdump_nfs kdump_local kdump_ssh kdump_ssh_key iscsi_name snmp_password install netconsole_server netconsole_port stateless cim_enabled wipe_fakeraid iscsi_init iscsi_target_name iscsi_target_host iscsi_target_port iscsi_install network_layout bond_name bond_slaves bond_options tuned_profile"
     # mount /config unless firstboot is forced
     if [ "$firstboot" != "1" ]; then
         mount_config
diff --git a/src/ovirtnode/kdump.py b/src/ovirtnode/kdump.py
index ada48fe..60584d1 100644
--- a/src/ovirtnode/kdump.py
+++ b/src/ovirtnode/kdump.py
@@ -47,5 +47,10 @@
             _functions.ovirt_store_config("/etc/kdump.conf")
             _functions.logger.info("Syslog Configuration Completed")
             return True
+        if "OVIRT_KDUMP_LOCAL" in _functions.OVIRT_VARS:
+            restore_kdump_config()
+            _functions.ovirt_store_config("/etc/kdump.conf")
+            _functions.logger.info("Syslog Configuration Completed")
+            return True
     except:
         _functions.logger.error("KDump Configuration Failed")


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

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