gerrit: Allow sending data with ssh command
Some commands like git-upload-pack expect data on stdin. These
commands block further execution resulting in a blocked thread. This
adds the possibility to optionally provide data for stdin of the
command.
Change-Id: I21fa2cb310a0472845d216da860e7ce06bd17825
diff --git a/zuul/lib/gerrit.py b/zuul/lib/gerrit.py
index 6c7906b..025de3d 100644
--- a/zuul/lib/gerrit.py
+++ b/zuul/lib/gerrit.py
@@ -184,7 +184,7 @@
key_filename=self.keyfile)
self.client = client
- def _ssh(self, command):
+ def _ssh(self, command, stdin_data=None):
if not self.client:
self._open()
@@ -195,6 +195,9 @@
self._open()
stdin, stdout, stderr = self.client.exec_command(command)
+ if stdin_data:
+ stdin.write(stdin_data)
+
out = stdout.read()
self.log.debug("SSH received stdout:\n%s" % out)