@param file_name: Path to output file
"""
- utils.WriteFile(file_name, data=utils.GenerateSecret(), mode=0400)
+ utils.WriteFile(file_name, data="%s\n" % utils.GenerateSecret(), mode=0400)
def _InitGanetiServerSetup(master_name):
if not os.path.exists(constants.HMAC_CLUSTER_KEY):
GenerateHmacKey(constants.HMAC_CLUSTER_KEY)
- result = utils.RunCmd([constants.NODE_INITD_SCRIPT, "restart"])
-
+ result = utils.RunCmd([constants.DAEMON_UTIL, "start", constants.NODED])
if result.failed:
raise errors.OpExecError("Could not start the node daemon, command %s"
" had exitcode %s and error %s" %
(result.cmd, result.exit_code, result.output))
- # Wait for node daemon to become responsive
+ _WaitForNodeDaemon(master_name)
+
+
+def _WaitForNodeDaemon(node_name):
+ """Wait for node daemon to become responsive.
+
+ """
def _CheckNodeDaemon():
- result = rpc.RpcRunner.call_version([master_name])[master_name]
+ result = rpc.RpcRunner.call_version([node_name])[node_name]
if result.fail_msg:
raise utils.RetryAgain()
try:
utils.Retry(_CheckNodeDaemon, 1.0, 10.0)
except utils.RetryTimeout:
- raise errors.OpExecError("Node daemon didn't answer queries within"
- " 10 seconds")
+ raise errors.OpExecError("Node daemon on %s didn't answer queries within"
+ " 10 seconds" % node_name)
+
def InitCluster(cluster_name, mac_prefix,
master_netdev, file_storage_dir, candidate_pool_size,
" entries: %s" % invalid_hvs,
errors.ECODE_INVAL)
- hostname = utils.HostInfo()
+ hostname = utils.GetHostInfo()
if hostname.ip.startswith("127."):
raise errors.OpPrereqError("This host's IP resolves to the private"
" belong to this host. Aborting." %
hostname.ip, errors.ECODE_ENVIRON)
- clustername = utils.HostInfo(cluster_name)
+ clustername = utils.GetHostInfo(utils.HostInfo.NormalizeName(cluster_name))
if utils.TcpPing(clustername.ip, constants.DEFAULT_NODED_PORT,
timeout=5):
(master_netdev,
result.output.strip()), errors.ECODE_INVAL)
- if not (os.path.isfile(constants.NODE_INITD_SCRIPT) and
- os.access(constants.NODE_INITD_SCRIPT, os.X_OK)):
- raise errors.OpPrereqError("Init.d script '%s' missing or not"
- " executable." % constants.NODE_INITD_SCRIPT,
- errors.ECODE_ENVIRON)
-
dirs = [(constants.RUN_GANETI_DIR, constants.RUN_DIRS_MODE)]
utils.EnsureDirs(dirs)
result = rpc.RpcRunner.call_node_stop_master(master, True)
msg = result.fail_msg
if msg:
- logging.warning("Could not disable the master role: %s" % msg)
+ logging.warning("Could not disable the master role: %s", msg)
result = rpc.RpcRunner.call_node_leave_cluster(master, modify_ssh_setup)
msg = result.fail_msg
if msg:
"cat > '%s' << '!EOF.' && \n"
"%s!EOF.\n"
"chmod 0400 %s %s %s && "
- "%s restart" %
+ "%s start %s" %
(constants.SSL_CERT_FILE, noded_cert,
constants.RAPI_CERT_FILE, rapi_cert,
constants.HMAC_CLUSTER_KEY, hmac_key,
constants.SSL_CERT_FILE, constants.RAPI_CERT_FILE,
constants.HMAC_CLUSTER_KEY,
- constants.NODE_INITD_SCRIPT))
+ constants.DAEMON_UTIL, constants.NODED))
result = sshrunner.Run(node, 'root', mycommand, batch=False,
ask_key=ssh_key_check,
" output: %s" %
(node, result.fail_reason, result.output))
+ _WaitForNodeDaemon(node)
+
def MasterFailover(no_voting=False):
"""Failover the master node.