pub_key_file=pathutils.SSH_PUB_KEYS,
ssconf_store=None,
noded_cert_file=pathutils.NODED_CERT_FILE,
- run_cmd_fn=ssh.RunSshCmdWithStdin):
+ run_cmd_fn=ssh.RunSshCmdWithStdin,
+ ssh_update_debug=False,
+ ssh_update_verbose=False):
"""Distributes a node's public SSH key across the cluster.
Note that this function should only be executed on the master node, which
pub_key_file=pub_key_file,
ssconf_store=ssconf_store,
noded_cert_file=noded_cert_file,
- run_cmd_fn=run_cmd_fn)
+ run_cmd_fn=run_cmd_fn,
+ ssh_update_debug=ssh_update_debug,
+ ssh_update_verbose=ssh_update_verbose)
# Node info named tuple specifically for the use with AddNodeSshKeyBulk
pub_key_file=pathutils.SSH_PUB_KEYS,
ssconf_store=None,
noded_cert_file=pathutils.NODED_CERT_FILE,
- run_cmd_fn=ssh.RunSshCmdWithStdin):
+ run_cmd_fn=ssh.RunSshCmdWithStdin,
+ ssh_update_debug=False,
+ ssh_update_verbose=False):
"""Distributes a node's public SSH key across the cluster.
Note that this function should only be executed on the master node, which
errors.SshUpdateError,
run_cmd_fn, cluster_name, node_info.name, pathutils.SSH_UPDATE,
ssh_port_map.get(node_info.name), node_data,
- debug=False, verbose=False, use_cluster_key=False,
- ask_key=False, strict_host_check=False)
+ debug=ssh_update_debug, verbose=ssh_update_verbose,
+ use_cluster_key=False, ask_key=False, strict_host_check=False)
except errors.SshUpdateError as e:
# Clean up the master's public key file if adding key fails
if node_info.to_public_keys:
errors.SshUpdateError,
run_cmd_fn, cluster_name, node, pathutils.SSH_UPDATE,
ssh_port_map.get(node), pot_mc_data,
- debug=False, verbose=False, use_cluster_key=False,
- ask_key=False, strict_host_check=False)
+ debug=ssh_update_debug, verbose=ssh_update_verbose,
+ use_cluster_key=False, ask_key=False, strict_host_check=False)
except errors.SshUpdateError as last_exception:
error_msg = ("When adding the key of node '%s', updating SSH key"
" files of node '%s' failed after %s retries."
if to_authorized_keys:
run_cmd_fn(cluster_name, node, pathutils.SSH_UPDATE,
ssh_port_map.get(node), base_data,
- debug=False, verbose=False, use_cluster_key=False,
- ask_key=False, strict_host_check=False)
+ debug=ssh_update_debug, verbose=ssh_update_verbose,
+ use_cluster_key=False, ask_key=False,
+ strict_host_check=False)
return node_errors
+# TODO: will be fixed with pending patch series.
+# pylint: disable=R0913
def RemoveNodeSshKey(node_uuid, node_name,
master_candidate_uuids,
potential_master_candidates,
ssconf_store=None,
noded_cert_file=pathutils.NODED_CERT_FILE,
readd=False,
- run_cmd_fn=ssh.RunSshCmdWithStdin):
+ run_cmd_fn=ssh.RunSshCmdWithStdin,
+ ssh_update_debug=False,
+ ssh_update_verbose=False):
"""Removes the node's SSH keys from the key files and distributes those.
Note that at least one of the flags C{from_authorized_keys},
ssconf_store=ssconf_store,
noded_cert_file=noded_cert_file,
readd=readd,
- run_cmd_fn=run_cmd_fn)
+ run_cmd_fn=run_cmd_fn,
+ ssh_update_debug=ssh_update_debug,
+ ssh_update_verbose=ssh_update_verbose)
# Node info named tuple specifically for the use with RemoveNodeSshKeyBulk
ssconf_store=None,
noded_cert_file=pathutils.NODED_CERT_FILE,
readd=False,
- run_cmd_fn=ssh.RunSshCmdWithStdin):
+ run_cmd_fn=ssh.RunSshCmdWithStdin,
+ ssh_update_debug=False,
+ ssh_update_verbose=False):
"""Removes the node's SSH keys from the key files and distributes those.
Note that at least one of the flags C{from_authorized_keys},
errors.SshUpdateError,
run_cmd_fn, cluster_name, node, pathutils.SSH_UPDATE,
ssh_port, pot_mc_data,
- debug=False, verbose=False, use_cluster_key=False,
- ask_key=False, strict_host_check=False)
+ debug=ssh_update_debug, verbose=ssh_update_verbose,
+ use_cluster_key=False, ask_key=False, strict_host_check=False)
except errors.SshUpdateError as last_exception:
error_msg = error_msg_final % (
node_info.name, node, last_exception)
errors.SshUpdateError,
run_cmd_fn, cluster_name, node, pathutils.SSH_UPDATE,
ssh_port, base_data,
- debug=False, verbose=False, use_cluster_key=False,
- ask_key=False, strict_host_check=False)
+ debug=ssh_update_debug, verbose=ssh_update_verbose,
+ use_cluster_key=False, ask_key=False, strict_host_check=False)
except errors.SshUpdateError as last_exception:
error_msg = error_msg_final % (
node_info.name, node, last_exception)
errors.SshUpdateError,
run_cmd_fn, cluster_name, node_info.name, pathutils.SSH_UPDATE,
ssh_port, data,
- debug=False, verbose=False, use_cluster_key=False,
- ask_key=False, strict_host_check=False)
+ debug=ssh_update_debug, verbose=ssh_update_verbose,
+ use_cluster_key=False, ask_key=False, strict_host_check=False)
except errors.SshUpdateError as last_exception:
result_msgs.append(
(node_info.name,
ssh.RemovePublicKey(node_uuid, key_file=pub_key_file)
return result_msgs
+# pylint: enable=R0913
def _GenerateNodeSshKey(node_uuid, node_name, ssh_port_map, ssh_key_type,
ssconf_store=None,
noded_cert_file=pathutils.NODED_CERT_FILE,
run_cmd_fn=ssh.RunSshCmdWithStdin,
- suffix=""):
+ suffix="",
+ ssh_update_debug=False,
+ ssh_update_verbose=False):
"""Generates the root SSH key pair on the node.
@type node_uuid: str
run_cmd_fn(cluster_name, node_name, pathutils.SSH_UPDATE,
ssh_port_map.get(node_name), data,
- debug=False, verbose=False, use_cluster_key=False,
- ask_key=False, strict_host_check=False)
+ debug=ssh_update_debug, verbose=ssh_update_verbose,
+ use_cluster_key=False, ask_key=False, strict_host_check=False)
def _GetMasterNodeUUID(node_uuid_name_map, master_node_name):
ganeti_pub_keys_file=pathutils.SSH_PUB_KEYS,
ssconf_store=None,
noded_cert_file=pathutils.NODED_CERT_FILE,
- run_cmd_fn=ssh.RunSshCmdWithStdin):
+ run_cmd_fn=ssh.RunSshCmdWithStdin,
+ ssh_update_debug=False,
+ ssh_update_verbose=False):
"""Renews all SSH keys and updates authorized_keys and ganeti_pub_keys.
@type node_uuids: list of str
node_info_to_remove,
master_candidate_uuids,
potential_master_candidates,
- master_uuid=master_node_uuid)
+ master_uuid=master_node_uuid,
+ ssh_update_debug=ssh_update_debug,
+ ssh_update_verbose=ssh_update_verbose)
if node_errors:
all_node_errors = all_node_errors + node_errors
new_key_bits, pub_key_file=ganeti_pub_keys_file,
ssconf_store=ssconf_store,
noded_cert_file=noded_cert_file,
- run_cmd_fn=run_cmd_fn)
+ run_cmd_fn=run_cmd_fn,
+ ssh_update_verbose=ssh_update_verbose,
+ ssh_update_debug=ssh_update_debug)
try:
logging.debug("Fetching newly created SSH key from node '%s'.", node_name)
node_keys_to_add, potential_master_candidates,
pub_key_file=ganeti_pub_keys_file, ssconf_store=ssconf_store,
noded_cert_file=noded_cert_file,
- run_cmd_fn=run_cmd_fn)
+ run_cmd_fn=run_cmd_fn,
+ ssh_update_debug=ssh_update_debug,
+ ssh_update_verbose=ssh_update_verbose)
if node_errors:
all_node_errors = all_node_errors + node_errors
ssconf_store=ssconf_store,
noded_cert_file=noded_cert_file,
run_cmd_fn=run_cmd_fn,
- suffix=constants.SSHS_MASTER_SUFFIX)
+ suffix=constants.SSHS_MASTER_SUFFIX,
+ ssh_update_debug=ssh_update_debug,
+ ssh_update_verbose=ssh_update_verbose)
# Read newly created master key
new_master_key_dict = _GetNewMasterKey(root_keyfiles, master_node_uuid)
to_authorized_keys=True, to_public_keys=True,
get_public_keys=False, pub_key_file=ganeti_pub_keys_file,
ssconf_store=ssconf_store, noded_cert_file=noded_cert_file,
- run_cmd_fn=run_cmd_fn)
+ run_cmd_fn=run_cmd_fn,
+ ssh_update_debug=ssh_update_debug,
+ ssh_update_verbose=ssh_update_verbose)
if node_errors:
all_node_errors = all_node_errors + node_errors
potential_master_candidates,
keys_to_remove=old_master_keys_by_uuid, from_authorized_keys=True,
from_public_keys=False, clear_authorized_keys=False,
- clear_public_keys=False)
+ clear_public_keys=False,
+ ssh_update_debug=ssh_update_debug,
+ ssh_update_verbose=ssh_update_verbose)
if node_errors:
all_node_errors = all_node_errors + node_errors