Revision e8d61457
b/daemons/ganeti-noded | ||
---|---|---|
609 | 609 |
return backend.GetNodeInfo(vgname, hypervisor_type) |
610 | 610 |
|
611 | 611 |
@staticmethod |
612 |
def perspective_node_add(params): |
|
613 |
"""Complete the registration of this node in the cluster. |
|
614 |
|
|
615 |
""" |
|
616 |
return backend.AddNode(params[0], params[1], params[2], |
|
617 |
params[3], params[4], params[5]) |
|
618 |
|
|
619 |
@staticmethod |
|
620 | 612 |
def perspective_node_verify(params): |
621 | 613 |
"""Run a verify sequence on this node. |
622 | 614 |
|
b/lib/backend.py | ||
---|---|---|
349 | 349 |
result.cmd, result.exit_code, result.output) |
350 | 350 |
|
351 | 351 |
|
352 |
def AddNode(dsa, dsapub, rsa, rsapub, sshkey, sshpub): |
|
353 |
"""Joins this node to the cluster. |
|
354 |
|
|
355 |
This does the following: |
|
356 |
- updates the hostkeys of the machine (rsa and dsa) |
|
357 |
- adds the ssh private key to the user |
|
358 |
- adds the ssh public key to the users' authorized_keys file |
|
359 |
|
|
360 |
@type dsa: str |
|
361 |
@param dsa: the DSA private key to write |
|
362 |
@type dsapub: str |
|
363 |
@param dsapub: the DSA public key to write |
|
364 |
@type rsa: str |
|
365 |
@param rsa: the RSA private key to write |
|
366 |
@type rsapub: str |
|
367 |
@param rsapub: the RSA public key to write |
|
368 |
@type sshkey: str |
|
369 |
@param sshkey: the SSH private key to write |
|
370 |
@type sshpub: str |
|
371 |
@param sshpub: the SSH public key to write |
|
372 |
@rtype: boolean |
|
373 |
@return: the success of the operation |
|
374 |
|
|
375 |
""" |
|
376 |
sshd_keys = [(constants.SSH_HOST_RSA_PRIV, rsa, 0600), |
|
377 |
(constants.SSH_HOST_RSA_PUB, rsapub, 0644), |
|
378 |
(constants.SSH_HOST_DSA_PRIV, dsa, 0600), |
|
379 |
(constants.SSH_HOST_DSA_PUB, dsapub, 0644)] |
|
380 |
for name, content, mode in sshd_keys: |
|
381 |
utils.WriteFile(name, data=content, mode=mode) |
|
382 |
|
|
383 |
try: |
|
384 |
priv_key, pub_key, auth_keys = ssh.GetUserFiles(constants.GANETI_RUNAS, |
|
385 |
mkdir=True) |
|
386 |
except errors.OpExecError, err: |
|
387 |
_Fail("Error while processing user ssh files: %s", err, exc=True) |
|
388 |
|
|
389 |
for name, content in [(priv_key, sshkey), (pub_key, sshpub)]: |
|
390 |
utils.WriteFile(name, data=content, mode=0600) |
|
391 |
|
|
392 |
utils.AddAuthorizedKey(auth_keys, sshpub) |
|
393 |
|
|
394 |
result = utils.RunCmd([constants.DAEMON_UTIL, "reload-ssh-keys"]) |
|
395 |
if result.failed: |
|
396 |
_Fail("Unable to reload SSH keys (command %r, exit code %s, output %r)", |
|
397 |
result.cmd, result.exit_code, result.output) |
|
398 |
|
|
399 |
|
|
400 | 352 |
def LeaveCluster(modify_ssh_setup): |
401 | 353 |
"""Cleans up and remove the current node. |
402 | 354 |
|
b/lib/cmdlib.py | ||
---|---|---|
1249 | 1249 |
|
1250 | 1250 |
""" |
1251 | 1251 |
master = self.cfg.GetMasterNode() |
1252 |
modify_ssh_setup = self.cfg.GetClusterInfo().modify_ssh_setup |
|
1253 | 1252 |
|
1254 | 1253 |
# Run post hooks on master node before it's removed |
1255 | 1254 |
hm = self.proc.hmclass(self.rpc.call_hooks_runner, self) |
... | ... | |
1262 | 1261 |
result = self.rpc.call_node_stop_master(master, False) |
1263 | 1262 |
result.Raise("Could not disable the master role") |
1264 | 1263 |
|
1265 |
if modify_ssh_setup: |
|
1266 |
priv_key, pub_key, _ = ssh.GetUserFiles(constants.GANETI_RUNAS) |
|
1267 |
utils.CreateBackup(priv_key) |
|
1268 |
utils.CreateBackup(pub_key) |
|
1269 |
|
|
1270 | 1264 |
return master |
1271 | 1265 |
|
1272 | 1266 |
|
... | ... | |
3828 | 3822 |
" node version %s" % |
3829 | 3823 |
(constants.PROTOCOL_VERSION, result.payload)) |
3830 | 3824 |
|
3831 |
# setup ssh on node |
|
3832 |
if self.cfg.GetClusterInfo().modify_ssh_setup: |
|
3833 |
logging.info("Copy ssh key to node %s", node) |
|
3834 |
priv_key, pub_key, _ = ssh.GetUserFiles(constants.GANETI_RUNAS) |
|
3835 |
keyarray = [] |
|
3836 |
keyfiles = [constants.SSH_HOST_DSA_PRIV, constants.SSH_HOST_DSA_PUB, |
|
3837 |
constants.SSH_HOST_RSA_PRIV, constants.SSH_HOST_RSA_PUB, |
|
3838 |
priv_key, pub_key] |
|
3839 |
|
|
3840 |
for i in keyfiles: |
|
3841 |
keyarray.append(utils.ReadFile(i)) |
|
3842 |
|
|
3843 |
result = self.rpc.call_node_add(node, keyarray[0], keyarray[1], |
|
3844 |
keyarray[2], keyarray[3], keyarray[4], |
|
3845 |
keyarray[5]) |
|
3846 |
result.Raise("Cannot transfer ssh keys to the new node") |
|
3847 |
|
|
3848 | 3825 |
# Add node to our /etc/hosts, and add key to known_hosts |
3849 | 3826 |
if self.cfg.GetClusterInfo().modify_etc_hosts: |
3850 | 3827 |
# FIXME: this should be done via an rpc call to node daemon |
b/lib/rpc.py | ||
---|---|---|
874 | 874 |
[vg_name, hypervisor_type]) |
875 | 875 |
|
876 | 876 |
@_RpcTimeout(_TMO_NORMAL) |
877 |
def call_node_add(self, node, dsa, dsapub, rsa, rsapub, ssh, sshpub): |
|
878 |
"""Add a node to the cluster. |
|
879 |
|
|
880 |
This is a single-node call. |
|
881 |
|
|
882 |
""" |
|
883 |
return self._SingleNodeCall(node, "node_add", |
|
884 |
[dsa, dsapub, rsa, rsapub, ssh, sshpub]) |
|
885 |
|
|
886 |
@_RpcTimeout(_TMO_NORMAL) |
|
887 | 877 |
def call_node_verify(self, node_list, checkdict, cluster_name): |
888 | 878 |
"""Request verification of given parameters. |
889 | 879 |
|
Also available in: Unified diff