From e8d61457f16974cbf0d77479f9d06f4c6345a02e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Nussbaumer?= Date: Tue, 20 Jul 2010 14:00:11 +0200 Subject: [PATCH] Removing all ssh setup code from the core MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: René Nussbaumer Reviewed-by: Iustin Pop --- daemons/ganeti-noded | 8 -------- lib/backend.py | 48 -------------------------------------------- lib/cmdlib.py | 23 --------------------- lib/rpc.py | 10 --------- 4 files changed, 89 deletions(-) diff --git a/daemons/ganeti-noded b/daemons/ganeti-noded index 4fe2fd08d..147d88db2 100755 --- a/daemons/ganeti-noded +++ b/daemons/ganeti-noded @@ -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. diff --git a/lib/backend.py b/lib/backend.py index a4105dbba..aa6e70549 100644 --- a/lib/backend.py +++ b/lib/backend.py @@ -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. diff --git a/lib/cmdlib.py b/lib/cmdlib.py index 84d6f05a6..18433117f 100644 --- a/lib/cmdlib.py +++ b/lib/cmdlib.py @@ -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 diff --git a/lib/rpc.py b/lib/rpc.py index 6373e1a25..3e1e63240 100644 --- a/lib/rpc.py +++ b/lib/rpc.py @@ -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. -- GitLab