def get_ssh_client(ip,<EOL>ssh_private_key_file,<EOL>ssh_user='<STR_LIT:root>',<EOL>port=<NUM_LIT>,<EOL>timeout=<NUM_LIT>,<EOL>wait_period=<NUM_LIT:10>):
if ip in CLIENT_CACHE:<EOL><INDENT>return CLIENT_CACHE[ip]<EOL><DEDENT>start = time.time()<EOL>end = start + timeout<EOL>client = None<EOL>while time.time() < end:<EOL><INDENT>try:<EOL><INDENT>client = establish_ssh_connection(<EOL>ip,<EOL>ssh_private_key_file,<EOL>ssh_user,<EOL>port,<EOL>timeout=wait_period<EOL>)<EOL>execute_ssh_command(client, '<STR_LIT>')<EOL><DEDENT>except:  <EOL><INDENT>if client:<EOL><INDENT>client.close()<EOL><DEDENT>wait_period += wait_period<EOL><DEDENT>else:<EOL><INDENT>CLIENT_CACHE[ip] = client<EOL>return client<EOL><DEDENT><DEDENT>raise IpaSSHException(<EOL>'<STR_LIT>'<EOL>)<EOL>
Attempt to establish and test ssh connection.