Revision 1de1cd0c qa/qa_utils.py
b/qa/qa_utils.py | ||
---|---|---|
228 | 228 |
fail=fail, node=node, log_cmd=log_cmd) |
229 | 229 |
|
230 | 230 |
|
231 |
def GetSSHCommand(node, cmd, strict=True, opts=None, tty=None): |
|
231 |
def GetSSHCommand(node, cmd, strict=True, opts=None, tty=None, |
|
232 |
use_multiplexer=True): |
|
232 | 233 |
"""Builds SSH command to be executed. |
233 | 234 |
|
234 | 235 |
@type node: string |
... | ... | |
242 | 243 |
@param opts: list of additional options |
243 | 244 |
@type tty: boolean or None |
244 | 245 |
@param tty: if we should use tty; if None, will be auto-detected |
246 |
@type use_multiplexer: boolean |
|
247 |
@param use_multiplexer: if the multiplexer for the node should be used |
|
245 | 248 |
|
246 | 249 |
""" |
247 | 250 |
args = ["ssh", "-oEscapeChar=none", "-oBatchMode=yes", "-lroot"] |
... | ... | |
261 | 264 |
args.append("-oForwardAgent=yes") |
262 | 265 |
if opts: |
263 | 266 |
args.extend(opts) |
264 |
if node in _MULTIPLEXERS: |
|
267 |
if node in _MULTIPLEXERS and use_multiplexer:
|
|
265 | 268 |
spath = _MULTIPLEXERS[node][0] |
266 | 269 |
args.append("-oControlPath=%s" % spath) |
267 | 270 |
args.append("-oControlMaster=no") |
... | ... | |
338 | 341 |
utils.RemoveFile(sname) |
339 | 342 |
|
340 | 343 |
|
341 |
def GetCommandOutput(node, cmd, tty=None, fail=False): |
|
344 |
def GetCommandOutput(node, cmd, tty=None, use_multiplexer=True, |
|
345 |
fail=False): |
|
342 | 346 |
"""Returns the output of a command executed on the given node. |
343 | 347 |
|
344 | 348 |
@type node: string |
... | ... | |
347 | 351 |
@param cmd: command to be executed in the node (cannot be empty or None) |
348 | 352 |
@type tty: bool or None |
349 | 353 |
@param tty: if we should use tty; if None, it will be auto-detected |
354 |
@type use_multiplexer: bool |
|
355 |
@param use_multiplexer: if the SSH multiplexer provided by the QA should be |
|
356 |
used or not |
|
350 | 357 |
@type fail: bool |
351 | 358 |
@param fail: whether the command is expected to fail |
352 | 359 |
""" |
353 | 360 |
assert cmd |
354 |
p = StartLocalCommand(GetSSHCommand(node, cmd, tty=tty), |
|
361 |
p = StartLocalCommand(GetSSHCommand(node, cmd, tty=tty, |
|
362 |
use_multiplexer=use_multiplexer), |
|
355 | 363 |
stdout=subprocess.PIPE) |
356 | 364 |
rcode = p.wait() |
357 | 365 |
_AssertRetCode(rcode, fail, cmd, node) |
Also available in: Unified diff