Created
October 10, 2014 19:51
-
-
Save adam-stokes/633e75d020e93107c95b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def container_run(name, cmd, nowait=False): | |
""" run command in container | |
:param str name: name of container | |
:param str cmd: command to run | |
""" | |
ip = container_ip(name) | |
cmd = "sudo -H -u {3} TERM=xterm256-color ssh -t -q " \ | |
"-l ubuntu -o \"StrictHostKeyChecking=no\" " \ | |
"-o \"UserKnownHostsFile=/dev/null\" " \ | |
"-i {2} " \ | |
"{0} {1} >>/dev/null".format(ip, cmd, ssh_privkey(), install_user()) | |
if nowait: | |
log.debug("Running command without waiting for response.") | |
args = shlex.split(cmd) | |
Popen(args, stdout=DEVNULL, stderr=DEVNULL) | |
else: | |
os.system(cmd) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment