Skip to content

Commit

Permalink
Merge pull request #106 from grycap/devel
Browse files Browse the repository at this point in the history
Devel
  • Loading branch information
micafer authored Aug 3, 2024
2 parents c0cb4a8 + 7adb352 commit 287a0ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 11 deletions.
15 changes: 9 additions & 6 deletions imclient/imclient.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ def run(radl, show_only=False):
ops = CmdSsh._connect_password(radl)

if show_only:
print(" ".join(ops))
for op in ops:
if "ProxyCommand" in op:
op = "'" + op + "'"
print(op, end=" ")
else:
os.execlp(ops[0], *ops)
except OSError as e:
Expand Down Expand Up @@ -199,12 +202,13 @@ def _connect_password(radl):
ssh_args = CmdSsh._get_proxy_command(radl, ip, s.getValue("disk.0.os.credentials.username"))

res = ["sshpass", "-p%s" % s.getValue("disk.0.os.credentials.password"),
"ssh", "-p", ssh_port, "-o", "UserKnownHostsFile=/dev/null", "-o", "StrictHostKeyChecking=no",
"%s@%s" % (s.getValue("disk.0.os.credentials.username"), ip)]
"ssh", "-p", ssh_port, "-o", "UserKnownHostsFile=/dev/null", "-o", "StrictHostKeyChecking=no"]

if ssh_args:
res.extend(ssh_args)

res.append("%s@%s" % (s.getValue("disk.0.os.credentials.username"), ip))

return res

@staticmethod
Expand All @@ -222,11 +226,10 @@ def _connect_key(radl):
ssh_args = CmdSsh._get_proxy_command(radl, ip, s.getValue("disk.0.os.credentials.username"))

res = ["ssh", "-p", ssh_port, "-i", f.name, "-o", "UserKnownHostsFile=/dev/null",
"-o", "StrictHostKeyChecking=no",
"%s@%s" % (s.getValue("disk.0.os.credentials.username"), ip)]

"-o", "StrictHostKeyChecking=no"]
if ssh_args:
res.extend(ssh_args)
res.append("%s@%s" % (s.getValue("disk.0.os.credentials.username"), ip))

return res

Expand Down
10 changes: 5 additions & 5 deletions test/unit/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1086,8 +1086,8 @@ def test_sshvm(self, server_proxy):
self.assertEquals(res, True)
output = out.getvalue().strip()
self.assertIn("sshpass -pyoyoyo ssh -p 22 -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no "
"[email protected] -o ProxyCommand=sshpass -p passwd ssh -W %h:%p -p 22"
" -o StrictHostKeyChecking=no [email protected]", output)
"-o 'ProxyCommand=sshpass -p passwd ssh -W %h:%p -p 22"
" -o StrictHostKeyChecking=no [email protected]' [email protected]", output)
sys.stdout = oldstdout
sys.stderr = oldstderr

Expand Down Expand Up @@ -1146,9 +1146,9 @@ def test_sshvm_via_master(self, server_proxy):
self.assertEquals(res, True)
output = out.getvalue().strip()
self.assertIn("ssh -p 22 -i /tmp/", output)
self.assertIn(" -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no [email protected]"
" -o ProxyCommand=ssh -W %h:%p -i /var/tmp/ubuntu_ubuntu_10.0.0.2.pem -p 22"
" -o StrictHostKeyChecking=no [email protected]", output)
self.assertIn(" -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
" -o 'ProxyCommand=ssh -W %h:%p -i /var/tmp/ubuntu_ubuntu_10.0.0.2.pem -p 22"
" -o StrictHostKeyChecking=no [email protected]' [email protected]", output)
sys.stdout = oldstdout
sys.stderr = oldstderr

Expand Down

0 comments on commit 287a0ce

Please sign in to comment.