[node-patches] Change in ovirt-node[master]: Don't overwrite the entirety of kdump.conf when we save
rbarry at redhat.com
rbarry at redhat.com
Fri Aug 1 15:42:36 UTC 2014
Ryan Barry has uploaded a new change for review.
Change subject: Don't overwrite the entirety of kdump.conf when we save
......................................................................
Don't overwrite the entirety of kdump.conf when we save
Be smarter about writing kdump.conf -- only clear and set values
which may be set by the TUI so we don't stomp on other people.
Change-Id: Ic53bab0b3a5602ac71028db5835a69005ac85a0c
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1122923
Signed-off-by: Ryan Barry <rbarry at redhat.com>
---
M src/ovirt/node/config/defaults.py
1 file changed, 50 insertions(+), 20 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/33/30933/1
diff --git a/src/ovirt/node/config/defaults.py b/src/ovirt/node/config/defaults.py
index a2fd278..1346b33 100644
--- a/src/ovirt/node/config/defaults.py
+++ b/src/ovirt/node/config/defaults.py
@@ -1060,8 +1060,16 @@
def transaction(self):
cfg = dict(self.retrieve())
- nfs, ssh, ssh_key, restore = (cfg["nfs"], cfg["ssh"], cfg["ssh_key"],
- cfg["local"])
+ nfs, ssh, ssh_key, local = (cfg["nfs"], cfg["ssh"], cfg["ssh_key"],
+ cfg["local"])
+
+ aug = AugeasWrapper()
+ prefix = "/files/etc/kdump.conf/"
+
+ def _set_values(vals):
+ for k, v in vals.iteritems():
+ aug.set(prefix + k, v)
+ aug.save()
class BackupKdumpConfig(utils.Transaction.Element):
title = "Backing up config files"
@@ -1073,19 +1081,35 @@
def commit(self):
self.backups.create(ignore_existing=True)
- class RestoreKdumpConfig(utils.Transaction.Element):
- title = "Restoring default kdump config"
+ class WipeKdumpConfig(utils.Transaction.Element):
+ title = "Removing set kdump options"
def commit(self):
- import ovirtnode.kdump as okdump
- okdump.restore_kdump_config()
+ self.logger.debug("SET RUNNING")
+ paths = ["default", "ext4", "path", "nfs", "ssh", "net"]
+
+ vals = aug.get_many(paths, basepath=prefix)
+ [aug.remove(v) for v in vals.keys() if vals[v] is not None]
+ aug.save()
+
+ class LocalKdumpConfig(utils.Transaction.Element):
+ title = "Setting local kdump config"
+
+ def commit(self):
+ vals = {"default": "reboot",
+ "ext4": "/dev/HostVG/Data",
+ "path": "/core"}
+
+ _set_values(vals)
class CreateNfsKdumpConfig(utils.Transaction.Element):
title = "Creating kdump NFS config"
def commit(self):
- import ovirtnode.kdump as okdump
- okdump.write_kdump_config(nfs, "nfs")
+ vals = {"default": "reboot",
+ "nfs": nfs}
+
+ _set_values(vals)
class PopulateSshKeys(utils.Transaction.Element):
title = "Fetching and testing SSH keys"
@@ -1127,10 +1151,10 @@
title = "Creating kdump SSH config"
def commit(self):
- import ovirtnode.kdump as okdump
- from ovirtnode.ovirtfunctions import ovirt_store_config
+ vals = {"default": "reboot",
+ "ssh": ssh}
- okdump.write_kdump_config(ssh, "ssh")
+ _set_values(vals)
kdumpctl_cmd = system.which("kdumpctl")
if kdumpctl_cmd:
@@ -1141,10 +1165,13 @@
try:
utils.process.check_call(cmd)
- ovirt_store_config(["/root/.ssh/kdump_id_rsa.pub",
- "/root/.ssh/kdump_id_rsa",
- "/root/.ssh/known_hosts",
- "/root/.ssh/config"])
+ files = ["/root/.ssh/kdump_id_rsa.pub",
+ "/root/.ssh/kdump_id_rsa",
+ "/root/.ssh/known_hosts",
+ "/root/.ssh/config"]
+
+ [utils.fs.Config().persist(file) for file in files]
+
except utils.process.CalledProcessError as e:
self.logger.warning("Failed to activate KDump with " +
"SSH: %s" % e)
@@ -1157,9 +1184,7 @@
super(RemoveKdumpConfig, self).__init__()
def commit(self):
- from ovirtnode.ovirtfunctions import remove_config
-
- remove_config("/etc/kdump.conf")
+ utils.fs.Config().unpersist("/etc/kdump.conf")
system.service("kdump", "stop")
fs.File('/etc/kdump.conf').touch()
@@ -1179,7 +1204,9 @@
try:
system.service("kdump", "restart")
except utils.process.CalledProcessError as e:
+ import shutil
self.logger.info("Failure while restarting kdump: %s" % e)
+ shutil.copy2("/etc/kdump.conf", "/tmp/kdump.conf")
unmount_config("/etc/kdump.conf")
self.backups.restore("/etc/kdump.conf")
system.service("kdump", "restart", do_raise=False)
@@ -1196,6 +1223,9 @@
backup_txe = BackupKdumpConfig()
tx.append(backup_txe)
+ wipe_txe = WipeKdumpConfig()
+ tx.append(wipe_txe)
+
final_txe = RestartKdumpService(backup_txe.backups)
if nfs:
tx.append(CreateNfsKdumpConfig())
@@ -1203,8 +1233,8 @@
if ssh_key:
tx.append(PopulateSshKeys())
tx.append(CreateSshKdumpConfig())
- elif restore in [True, False]:
- tx.append(RestoreKdumpConfig())
+ elif local in [True, False]:
+ tx.append(LocalKdumpConfig())
else:
final_txe = RemoveKdumpConfig(backup_txe.backups)
--
To view, visit http://gerrit.ovirt.org/30933
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic53bab0b3a5602ac71028db5835a69005ac85a0c
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