Commit e8d61457 authored by René Nussbaumer's avatar René Nussbaumer

Removing all ssh setup code from the core

Signed-off-by: default avatarRené Nussbaumer <rn@google.com>
Reviewed-by: default avatarIustin Pop <iustin@google.com>
parent 9486f6ae
......@@ -608,14 +608,6 @@ class NodeHttpServer(http.server.HttpServer):
vgname, hypervisor_type = params
return backend.GetNodeInfo(vgname, hypervisor_type)
@staticmethod
def perspective_node_add(params):
"""Complete the registration of this node in the cluster.
"""
return backend.AddNode(params[0], params[1], params[2],
params[3], params[4], params[5])
@staticmethod
def perspective_node_verify(params):
"""Run a verify sequence on this node.
......
......@@ -349,54 +349,6 @@ def StopMaster(stop_daemons):
result.cmd, result.exit_code, result.output)
def AddNode(dsa, dsapub, rsa, rsapub, sshkey, sshpub):
"""Joins this node to the cluster.
This does the following:
- updates the hostkeys of the machine (rsa and dsa)
- adds the ssh private key to the user
- adds the ssh public key to the users' authorized_keys file
@type dsa: str
@param dsa: the DSA private key to write
@type dsapub: str
@param dsapub: the DSA public key to write
@type rsa: str
@param rsa: the RSA private key to write
@type rsapub: str
@param rsapub: the RSA public key to write
@type sshkey: str
@param sshkey: the SSH private key to write
@type sshpub: str
@param sshpub: the SSH public key to write
@rtype: boolean
@return: the success of the operation
"""
sshd_keys = [(constants.SSH_HOST_RSA_PRIV, rsa, 0600),
(constants.SSH_HOST_RSA_PUB, rsapub, 0644),
(constants.SSH_HOST_DSA_PRIV, dsa, 0600),
(constants.SSH_HOST_DSA_PUB, dsapub, 0644)]
for name, content, mode in sshd_keys:
utils.WriteFile(name, data=content, mode=mode)
try:
priv_key, pub_key, auth_keys = ssh.GetUserFiles(constants.GANETI_RUNAS,
mkdir=True)
except errors.OpExecError, err:
_Fail("Error while processing user ssh files: %s", err, exc=True)
for name, content in [(priv_key, sshkey), (pub_key, sshpub)]:
utils.WriteFile(name, data=content, mode=0600)
utils.AddAuthorizedKey(auth_keys, sshpub)
result = utils.RunCmd([constants.DAEMON_UTIL, "reload-ssh-keys"])
if result.failed:
_Fail("Unable to reload SSH keys (command %r, exit code %s, output %r)",
result.cmd, result.exit_code, result.output)
def LeaveCluster(modify_ssh_setup):
"""Cleans up and remove the current node.
......
......@@ -1249,7 +1249,6 @@ class LUDestroyCluster(LogicalUnit):
"""
master = self.cfg.GetMasterNode()
modify_ssh_setup = self.cfg.GetClusterInfo().modify_ssh_setup
# Run post hooks on master node before it's removed
hm = self.proc.hmclass(self.rpc.call_hooks_runner, self)
......@@ -1262,11 +1261,6 @@ class LUDestroyCluster(LogicalUnit):
result = self.rpc.call_node_stop_master(master, False)
result.Raise("Could not disable the master role")
if modify_ssh_setup:
priv_key, pub_key, _ = ssh.GetUserFiles(constants.GANETI_RUNAS)
utils.CreateBackup(priv_key)
utils.CreateBackup(pub_key)
return master
......@@ -3828,23 +3822,6 @@ class LUAddNode(LogicalUnit):
" node version %s" %
(constants.PROTOCOL_VERSION, result.payload))
# setup ssh on node
if self.cfg.GetClusterInfo().modify_ssh_setup:
logging.info("Copy ssh key to node %s", node)
priv_key, pub_key, _ = ssh.GetUserFiles(constants.GANETI_RUNAS)
keyarray = []
keyfiles = [constants.SSH_HOST_DSA_PRIV, constants.SSH_HOST_DSA_PUB,
constants.SSH_HOST_RSA_PRIV, constants.SSH_HOST_RSA_PUB,
priv_key, pub_key]
for i in keyfiles:
keyarray.append(utils.ReadFile(i))
result = self.rpc.call_node_add(node, keyarray[0], keyarray[1],
keyarray[2], keyarray[3], keyarray[4],
keyarray[5])
result.Raise("Cannot transfer ssh keys to the new node")
# Add node to our /etc/hosts, and add key to known_hosts
if self.cfg.GetClusterInfo().modify_etc_hosts:
# FIXME: this should be done via an rpc call to node daemon
......
......@@ -873,16 +873,6 @@ class RpcRunner(object):
return self._MultiNodeCall(node_list, "node_info",
[vg_name, hypervisor_type])
@_RpcTimeout(_TMO_NORMAL)
def call_node_add(self, node, dsa, dsapub, rsa, rsapub, ssh, sshpub):
"""Add a node to the cluster.
This is a single-node call.
"""
return self._SingleNodeCall(node, "node_add",
[dsa, dsapub, rsa, rsapub, ssh, sshpub])
@_RpcTimeout(_TMO_NORMAL)
def call_node_verify(self, node_list, checkdict, cluster_name):
"""Request verification of given parameters.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment