MCPcopy Create free account
hub / github.com/apache/cloudstack / _execute_ssh_command

Function _execute_ssh_command

tools/marvin/marvin/lib/utils.py:65–82  ·  view source on GitHub ↗
(hostip, port, username, password, ssh_command, timeout=5)

Source from the content-addressed store, hash-verified

63
64
65def _execute_ssh_command(hostip, port, username, password, ssh_command, timeout=5):
66 #SSH to the machine
67 ssh = SshClient(hostip, port, username, password)
68 # Ensure the SSH login is successful
69 while True:
70 res = ssh.execute(ssh_command)
71 if len(res) == 0:
72 return res
73 elif "Connection refused".lower() in res[0].lower():
74 pass
75 elif res[0] != "Host key verification failed.":
76 break
77 elif timeout == 0:
78 break
79
80 time.sleep(5)
81 timeout = timeout - 1
82 return res
83
84def restart_mgmt_server(server):
85 """Restarts the management server"""

Callers 4

setUpClassMethod · 0.90
execute_command_in_hostFunction · 0.85
get_process_statusFunction · 0.85

Calls 3

executeMethod · 0.95
SshClientClass · 0.90
sleepMethod · 0.45

Tested by 2

setUpClassMethod · 0.72