Skip to content

Commit

Permalink
fix: force TTY allocation for no.x (execute command in the remote host)
Browse files Browse the repository at this point in the history
  • Loading branch information
Mario Hros committed Jan 14, 2020
1 parent 2e24fc8 commit 1d1e052
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions _ks.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,13 @@ def hlp_no_x(p, extra_args):
continue

cmd = []
if p.sudo:
if p.no_sudo != True:
cmd = ["sudo"]

cmd += [p.command]

subprocess.run(["ssh", "-o", "UserKnownHostsFile=/dev/null", "-o", "StrictHostKeyChecking=off", "-o", "LogLevel=error",
p.user+"@"+node_host] + cmd)
os.execvpe("ssh", ["ssh", "-t", "-o", "UserKnownHostsFile=/dev/null", "-o", "StrictHostKeyChecking=off", "-o", "LogLevel=error",
p.user+"@"+node_host] + cmd, env=os.environ)


def hlp_no_df(p, extra_args):
Expand All @@ -402,7 +402,7 @@ def hlp_no_df(p, extra_args):
continue

cmd = []
if p.sudo:
if p.no_sudo != True:
cmd = ["sudo"]

cmd += ["df", "-h"]
Expand Down Expand Up @@ -657,7 +657,7 @@ def name_from_def(defstr):
h.add_argument("-l", "--selector", help="node label selector")
h.add_argument(
"-u", "--user", help="user to connect via ssh to", default="admin")
h.add_argument("-s", "--sudo", help="use sudo before command", default=True)
h.add_argument("-S", "--no-sudo", help="do not use sudo before command", action="store_true")
h.add_argument("-x", "--command", "--execute",
help="remote command to execute", default="sh")

Expand All @@ -667,7 +667,7 @@ def name_from_def(defstr):
h.add_argument("-l", "--selector", help="node label selector")
h.add_argument(
"-u", "--user", help="user to connect via ssh to", default="admin")
h.add_argument("-s", "--sudo", help="use sudo after logging in", default=True)
h.add_argument("-S", "--no-sudo", help="do not use sudo before command", action="store_true")

h = register_helper(
"use", "set the working namespace or return the current one", namespaced=False, func=hlp_use)
Expand Down

0 comments on commit 1d1e052

Please sign in to comment.