Lines Matching +full:host +full:- +full:command
1 # SPDX-License-Identifier: GPL-2.0
27 Execute a command on local or remote host.
32 Use bkg() instead to run a command in the background.
35 host=None, timeout=5, ksft_wait=None):
45 if host:
46 self.proc = host.cmd(comm)
86 self.stdout = stdout.decode("utf-8")
87 self.stderr = stderr.decode("utf-8")
93 if len(stderr) > 0 and stderr[-1] == "\n":
94 stderr = stderr[:-1]
95 raise CmdExitFailure("Command failed: %s\nSTDOUT: %s\nSTDERR: %s" %
101 Run a command in the background.
105 Run a command on remote host, and wait for it to finish.
107 the command has initialized:
109 with bkg("socat ...", exit_wait=True, host=cfg.remote) as nc:
112 Run a command and expect it to let us know that it's ready
114 Command will be terminated when we exit the context manager:
118 def __init__(self, comm, shell=None, fail=None, ns=None, host=None,
121 shell=shell, fail=fail, ns=ns, host=host,
146 raise Exception("defer created with un-callable object, did you call the function instead of passing its name?")
172 def tool(name, args, json=None, ns=None, host=None):
175 cmd_str += '--json '
177 cmd_obj = cmd(cmd_str, ns=ns, host=host)
183 def bpftool(args, json=None, ns=None, host=None):
184 return tool('bpftool', args, json=json, ns=ns, host=host)
187 def ip(args, json=None, ns=None, host=None):
189 args = f'-netns {ns} ' + args
190 return tool('ip', args, json=json, host=host)
193 def ethtool(args, json=None, ns=None, host=None):
194 return tool('ethtool', args, json=json, ns=ns, host=host)
197 def bpftrace(expr, json=None, ns=None, host=None, timeout=None):
208 # Throw in --quiet if json, otherwise the output has two objects
210 cmd_arr += ['-f', 'json', '-q']
213 cmd_arr += ['-e', expr]
214 cmd_obj = cmd(cmd_arr, ns=ns, host=host, shell=False)
241 def wait_port_listen(port, proto="tcp", ns=None, host=None, sleep=0.005, deadline=5):
250 data = cmd(f'cat /proc/net/{proto}*', ns=ns, host=host, shell=True).stdout
259 def wait_file(fname, test_fn, sleep=0.005, deadline=5, encoding='utf-8'):