700 |
700 |
" the node: %s", msg)
|
701 |
701 |
|
702 |
702 |
|
703 |
|
def SetupNodeDaemon(cluster_name, node, ssh_key_check):
|
|
703 |
def SetupNodeDaemon(opts, cluster_name, node):
|
704 |
704 |
"""Add a node to the cluster.
|
705 |
705 |
|
706 |
706 |
This function must be called before the actual opcode, and will ssh
|
... | ... | |
709 |
709 |
|
710 |
710 |
@param cluster_name: the cluster name
|
711 |
711 |
@param node: the name of the new node
|
712 |
|
@param ssh_key_check: whether to do a strict key check
|
713 |
712 |
|
714 |
713 |
"""
|
715 |
|
sstore = ssconf.SimpleStore()
|
716 |
|
family = sstore.GetPrimaryIPFamily()
|
717 |
|
sshrunner = ssh.SshRunner(cluster_name,
|
718 |
|
ipv6=(family == netutils.IP6Address.family))
|
719 |
|
|
720 |
|
# set up inter-node password and certificate and restarts the node daemon
|
721 |
|
# and then connect with ssh to set password and start ganeti-noded
|
722 |
|
# note that all the below variables are sanitized at this point,
|
723 |
|
# either by being constants or by the checks above
|
724 |
|
sshrunner.CopyFileToNode(node, pathutils.NODED_CERT_FILE)
|
725 |
|
sshrunner.CopyFileToNode(node, pathutils.RAPI_CERT_FILE)
|
726 |
|
sshrunner.CopyFileToNode(node, pathutils.SPICE_CERT_FILE)
|
727 |
|
sshrunner.CopyFileToNode(node, pathutils.SPICE_CACERT_FILE)
|
728 |
|
sshrunner.CopyFileToNode(node, pathutils.CONFD_HMAC_KEY)
|
729 |
|
for filename in sstore.GetFileList():
|
730 |
|
sshrunner.CopyFileToNode(node, filename)
|
731 |
|
mycommand = ("%s stop-all; %s start %s" %
|
732 |
|
(pathutils.DAEMON_UTIL, pathutils.DAEMON_UTIL, constants.NODED))
|
733 |
|
|
734 |
|
result = sshrunner.Run(node, constants.SSH_LOGIN_USER, mycommand, batch=False,
|
735 |
|
ask_key=ssh_key_check,
|
736 |
|
use_cluster_key=True,
|
737 |
|
strict_host_check=ssh_key_check)
|
738 |
|
if result.failed:
|
739 |
|
raise errors.OpExecError("Remote command on node %s, error: %s,"
|
740 |
|
" output: %s" %
|
741 |
|
(node, result.fail_reason, result.output))
|
|
714 |
data = {
|
|
715 |
constants.NDS_CLUSTER_NAME: cluster_name,
|
|
716 |
constants.NDS_NODE_DAEMON_CERTIFICATE:
|
|
717 |
utils.ReadFile(pathutils.NODED_CERT_FILE),
|
|
718 |
constants.NDS_SSCONF: ssconf.SimpleStore().ReadAll(),
|
|
719 |
constants.NDS_START_NODE_DAEMON: True,
|
|
720 |
}
|
|
721 |
|
|
722 |
RunNodeSetupCmd(cluster_name, node, pathutils.NODE_DAEMON_SETUP,
|
|
723 |
opts.debug, opts.verbose,
|
|
724 |
True, opts.ssh_key_check, opts.ssh_key_check, data)
|
742 |
725 |
|
743 |
726 |
_WaitForNodeDaemon(node)
|
744 |
727 |
|