chiark / gitweb /
buildserver: run_via_vagrant_ssh() to run cmds via python-vagrant
authorHans-Christoph Steiner <hans@eds.org>
Thu, 23 Jun 2016 14:38:39 +0000 (16:38 +0200)
committerHans-Christoph Steiner <hans@eds.org>
Tue, 23 May 2017 18:04:08 +0000 (20:04 +0200)
This moves the last vagrant call in a subprocess.

makebuildserver

index 828b51fc4f8afd192564bf73bf917554de084178..6578e27c2d1f912399fb4f1fbc390c2cfece6b59 100755 (executable)
@@ -293,6 +293,14 @@ def sha256_for_file(path):
         return s.hexdigest()
 
 
+def run_via_vagrant_ssh(v, cmdlist):
+    if (isinstance(cmdlist, str) or isinstance(cmdlist, bytes)):
+        cmd = cmdlist
+    else:
+        cmd = ' '.join(cmdlist)
+    v._run_vagrant_command(['ssh', '-c', cmd])
+
+
 def main():
     global cachedir, cachefiles, config, tail
 
@@ -434,10 +442,7 @@ def main():
                          universal_newlines=True)
     buildserverid = p.communicate()[0].strip()
     print("...ID is " + buildserverid)
-    subprocess.call(
-        ['vagrant', 'ssh', '-c', 'sh -c "echo {0} >/home/vagrant/buildserverid"'
-            .format(buildserverid)],
-        cwd=serverdir)
+    run_via_vagrant_ssh(v, 'sh -c "echo %s >/home/vagrant/buildserverid"' % buildserverid)
 
     print("Stopping build server VM")
     v.halt()