[node-patches] Change in ovirt-node[master]: kdump:No need "service kdump propagate" to generate a key pa...
hadong0720 at gmail.com
hadong0720 at gmail.com
Fri Jul 11 11:27:49 UTC 2014
hadong has uploaded a new change for review.
Change subject: kdump:No need "service kdump propagate" to generate a key pair for ssh+sshkey
......................................................................
kdump:No need "service kdump propagate" to generate a key pair for ssh+sshkey
Change-Id: I6e749d785485d7c6bd68dc126bd1c56cb7754338
Signed-off-by: hadong <hadong at redhat.com>
---
M src/ovirt/node/config/defaults.py
1 file changed, 34 insertions(+), 17 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/40/29940/1
diff --git a/src/ovirt/node/config/defaults.py b/src/ovirt/node/config/defaults.py
index 01c21c3..293e76a 100644
--- a/src/ovirt/node/config/defaults.py
+++ b/src/ovirt/node/config/defaults.py
@@ -1107,7 +1107,8 @@
self.logger.warning("Failed to fetch SSH key: %s" %
err_str)
- os.mkdir("/tmp/kdump-ssh")
+ if not os.path.exists("/tmp/kdump-ssh"):
+ os.mkdir("/tmp/kdump-ssh")
os.chmod("/tmp/kdump-ssh", 0600)
with open("/tmp/kdump-ssh/id", "w") as f:
f.write(buf.getvalue())
@@ -1118,9 +1119,23 @@
'/tmp/kdump-ssh/id', ssh, 'true']
utils.process.check_call(cmd)
copy2("/tmp/kdump-ssh/id", "/root/.ssh/kdump_id_rsa")
+ conf = Config()
+ conf.persist("/root/.ssh/kdump_id_rsa")
except utils.process.CalledProcessError as e:
self.logger.warning("Failed to authenticate using SSH "
"key: %s" % e)
+
+ class RemoveSshKdumpConfig(utils.Transaction.Element):
+ title = "Removing kdump SSH config"
+
+ def commit(self):
+ conf = Config()
+ for confpath in ("/root/.ssh/kdump_id_rsa.pub",
+ "/root/.ssh/kdump_id_rsa",
+ "/root/.ssh/known_hosts",
+ "/root/.ssh/config"):
+ conf.unpersist(confpath)
+ conf.delete(confpath)
class CreateSshKdumpConfig(utils.Transaction.Element):
title = "Creating kdump SSH config"
@@ -1130,24 +1145,25 @@
okdump.write_kdump_config(ssh, "ssh")
- kdumpctl_cmd = system.which("kdumpctl")
- if kdumpctl_cmd:
- cmd = [kdumpctl_cmd, "propagate"]
- else:
- cmd = ["service", "kdump", "propagate"]
+ if not ssh_key:
+ kdumpctl_cmd = system.which("kdumpctl")
+ if kdumpctl_cmd:
+ cmd = [kdumpctl_cmd, "propagate"]
+ else:
+ cmd = ["service", "kdump", "propagate"]
- try:
- utils.process.check_call(cmd)
+ try:
+ utils.process.check_call(cmd)
- conf = Config()
- for confpath in ("/root/.ssh/kdump_id_rsa.pub",
- "/root/.ssh/kdump_id_rsa",
- "/root/.ssh/known_hosts",
- "/root/.ssh/config"):
- conf.persist(confpath)
- except utils.process.CalledProcessError as e:
- self.logger.warning("Failed to activate KDump with " +
- "SSH: %s" % e)
+ conf = Config()
+ for confpath in ("/root/.ssh/kdump_id_rsa.pub",
+ "/root/.ssh/kdump_id_rsa",
+ "/root/.ssh/known_hosts",
+ "/root/.ssh/config"):
+ conf.persist(confpath)
+ except utils.process.CalledProcessError as e:
+ self.logger.warning("Failed to activate KDump with " +
+ "SSH: %s" % e)
class RemoveKdumpConfig(utils.Transaction.Element):
title = "Removing kdump backup"
@@ -1197,6 +1213,7 @@
if nfs:
tx.append(CreateNfsKdumpConfig())
elif ssh:
+ tx.append(RemoveSshKdumpConfig())
if ssh_key:
tx.append(PopulateSshKeys())
tx.append(CreateSshKdumpConfig())
--
To view, visit http://gerrit.ovirt.org/29940
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I6e749d785485d7c6bd68dc126bd1c56cb7754338
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: hadong <hadong0720 at gmail.com>
More information about the node-patches
mailing list