Commit a1b805fb authored by Iustin Pop's avatar Iustin Pop
Browse files

Return error messages in node add ssh handling

When the rpc call node_add fails, we don't have any error message. This
patch changes the call to return (status, data) so that the user can see
the correct error message.

Reviewed-by: imsnah
parent e9d622bc
......@@ -260,8 +260,9 @@ def AddNode(dsa, dsapub, rsa, rsapub, sshkey, sshpub):
priv_key, pub_key, auth_keys = ssh.GetUserFiles(constants.GANETI_RUNAS,
mkdir=True)
except errors.OpExecError, err:
logging.exception("Error while processing user ssh files")
return False
msg = "Error while processing user ssh files"
logging.exception(msg)
return (False, "%s: %s" % (msg, err))
for name, content in [(priv_key, sshkey), (pub_key, sshpub)]:
utils.WriteFile(name, data=content, mode=0600)
......@@ -270,7 +271,7 @@ def AddNode(dsa, dsapub, rsa, rsapub, sshkey, sshpub):
utils.RunCmd([constants.SSH_INITD_SCRIPT, "restart"])
return True
return (True, "Node added successfully")
def LeaveCluster():
......
......@@ -2129,8 +2129,10 @@ class LUAddNode(LogicalUnit):
keyarray[2],
keyarray[3], keyarray[4], keyarray[5])
if result.failed or not result.data:
raise errors.OpExecError("Cannot transfer ssh keys to the new node")
msg = result.RemoteFailMsg()
if msg:
raise errors.OpExecError("Cannot transfer ssh keys to the"
" new node: %s" % msg)
# Add node to our /etc/hosts, and add key to known_hosts
utils.AddHostToEtcHosts(new_node.name)
......
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