Don't fail to execute remctls if a single server is down invirt-remote-server/0.0.15
authorEvan Broder <broder@mit.edu>
Mon, 10 Nov 2008 20:20:05 +0000 (15:20 -0500)
committerEvan Broder <broder@mit.edu>
Mon, 10 Nov 2008 20:20:05 +0000 (15:20 -0500)
svn path=/trunk/packages/invirt-remote-server/; revision=1598

debian/changelog
python/remote/bcast.py

index 8a3e564..a9e15bd 100644 (file)
@@ -1,8 +1,10 @@
 invirt-remote-server (0.0.15) unstable; urgency=low
 
   * Include invirt.remote Python module
 invirt-remote-server (0.0.15) unstable; urgency=low
 
   * Include invirt.remote Python module
+  * Ignore erroneous responses from a server if it's because the server is
+    down
 
 
- -- Evan Broder <broder@mit.edu>  Mon, 10 Nov 2008 15:15:13 -0500
+ -- Evan Broder <broder@mit.edu>  Mon, 10 Nov 2008 15:19:28 -0500
 
 invirt-remote-server (0.0.14) unstable; urgency=low
 
 
 invirt-remote-server (0.0.14) unstable; urgency=low
 
index 0d7dba2..ca69818 100644 (file)
@@ -9,11 +9,14 @@ def bcast(cmd, hosts = [h.hostname for h in config.hosts]):
     the same as the order of the hosts).
     """
     pipes = [(host,
     the same as the order of the hosts).
     """
     pipes = [(host,
-              Popen(['remctl', host, 'remote', 'web', cmd], stdout=PIPE))
+              Popen(['remctl', host, 'remote', 'web', cmd], stdout=PIPE, stderr=PIPE))
              for host in hosts]
              for host in hosts]
-    outputs = [(s, p.communicate()[0]) for (s, p) in pipes]
+    outputs = dict((s, p.communicate()) for (s, p) in pipes)
     for (s, p) in pipes:
         if p.returncode != 0:
     for (s, p) in pipes:
         if p.returncode != 0:
-            raise RuntimeError("remctl to host %s returned non-zero exit status %d"
-                               % (s, p.returncode))
-    return [(s, yaml.load(o, yaml.CSafeLoader)) for (s, o) in outputs]
+            if outputs[s][1].startswith('remctl: cannot connect to %s' % s):
+                del outputs[s]
+            else:
+                raise RuntimeError("remctl to host %s returned non-zero exit status %d"
+                                   % (s, p.returncode))
+    return [(s, yaml.load(o[1], yaml.CSafeLoader)) for (s, o) in outputs.iteritems()]