Revision b989b9d9 lib/cmdlib.py
b/lib/cmdlib.py | ||
---|---|---|
867 | 867 |
|
868 | 868 |
""" |
869 | 869 |
master = self.cfg.GetMasterNode() |
870 |
modify_ssh_setup = self.cfg.GetClusterInfo().modify_ssh_setup |
|
870 | 871 |
|
871 | 872 |
# Run post hooks on master node before it's removed |
872 | 873 |
hm = self.proc.hmclass(self.rpc.call_hooks_runner, self) |
... | ... | |
877 | 878 |
|
878 | 879 |
result = self.rpc.call_node_stop_master(master, False) |
879 | 880 |
result.Raise("Could not disable the master role") |
880 |
priv_key, pub_key, _ = ssh.GetUserFiles(constants.GANETI_RUNAS) |
|
881 |
utils.CreateBackup(priv_key) |
|
882 |
utils.CreateBackup(pub_key) |
|
881 |
|
|
882 |
if modify_ssh_setup: |
|
883 |
priv_key, pub_key, _ = ssh.GetUserFiles(constants.GANETI_RUNAS) |
|
884 |
utils.CreateBackup(priv_key) |
|
885 |
utils.CreateBackup(pub_key) |
|
886 |
|
|
883 | 887 |
return master |
884 | 888 |
|
885 | 889 |
|
... | ... | |
2340 | 2344 |
logging.info("Stopping the node daemon and removing configs from node %s", |
2341 | 2345 |
node.name) |
2342 | 2346 |
|
2347 |
modify_ssh_setup = self.cfg.GetClusterInfo().modify_ssh_setup |
|
2348 |
|
|
2343 | 2349 |
# Promote nodes to master candidate as needed |
2344 | 2350 |
_AdjustCandidatePool(self, exceptions=[node.name]) |
2345 | 2351 |
self.context.RemoveNode(node.name) |
... | ... | |
2351 | 2357 |
except: |
2352 | 2358 |
self.LogWarning("Errors occurred running hooks on %s" % node.name) |
2353 | 2359 |
|
2354 |
result = self.rpc.call_node_leave_cluster(node.name) |
|
2360 |
result = self.rpc.call_node_leave_cluster(node.name, modify_ssh_setup)
|
|
2355 | 2361 |
msg = result.fail_msg |
2356 | 2362 |
if msg: |
2357 | 2363 |
self.LogWarning("Errors encountered on the remote node while leaving" |
... | ... | |
2900 | 2906 |
(constants.PROTOCOL_VERSION, result.payload)) |
2901 | 2907 |
|
2902 | 2908 |
# setup ssh on node |
2903 |
logging.info("Copy ssh key to node %s", node) |
|
2904 |
priv_key, pub_key, _ = ssh.GetUserFiles(constants.GANETI_RUNAS) |
|
2905 |
keyarray = [] |
|
2906 |
keyfiles = [constants.SSH_HOST_DSA_PRIV, constants.SSH_HOST_DSA_PUB, |
|
2907 |
constants.SSH_HOST_RSA_PRIV, constants.SSH_HOST_RSA_PUB, |
|
2908 |
priv_key, pub_key] |
|
2909 |
|
|
2910 |
for i in keyfiles: |
|
2911 |
keyarray.append(utils.ReadFile(i)) |
|
2912 |
|
|
2913 |
result = self.rpc.call_node_add(node, keyarray[0], keyarray[1], |
|
2914 |
keyarray[2], |
|
2915 |
keyarray[3], keyarray[4], keyarray[5]) |
|
2916 |
result.Raise("Cannot transfer ssh keys to the new node") |
|
2909 |
if self.cfg.GetClusterInfo().modify_ssh_setup: |
|
2910 |
logging.info("Copy ssh key to node %s", node) |
|
2911 |
priv_key, pub_key, _ = ssh.GetUserFiles(constants.GANETI_RUNAS) |
|
2912 |
keyarray = [] |
|
2913 |
keyfiles = [constants.SSH_HOST_DSA_PRIV, constants.SSH_HOST_DSA_PUB, |
|
2914 |
constants.SSH_HOST_RSA_PRIV, constants.SSH_HOST_RSA_PUB, |
|
2915 |
priv_key, pub_key] |
|
2916 |
|
|
2917 |
for i in keyfiles: |
|
2918 |
keyarray.append(utils.ReadFile(i)) |
|
2919 |
|
|
2920 |
result = self.rpc.call_node_add(node, keyarray[0], keyarray[1], |
|
2921 |
keyarray[2], keyarray[3], keyarray[4], |
|
2922 |
keyarray[5]) |
|
2923 |
result.Raise("Cannot transfer ssh keys to the new node") |
|
2917 | 2924 |
|
2918 | 2925 |
# Add node to our /etc/hosts, and add key to known_hosts |
2919 | 2926 |
if self.cfg.GetClusterInfo().modify_etc_hosts: |
Also available in: Unified diff