1 from subprocess import PIPE, Popen
2 from invirt.config import structs as config
5 def bcast(cmd, hosts = [h.hostname for h in config.hosts]):
7 Given a command and a list of hostnames or IPs, issue the command to all
8 the nodes and return a list of (host, output) pairs (the order should be
9 the same as the order of the hosts).
12 Popen(['remctl', host, 'remote', 'web', cmd], stdout=PIPE, stderr=PIPE))
14 outputs = dict((s, p.communicate()) for (s, p) in pipes)
17 if outputs[s][1].startswith('remctl: cannot connect to %s' % s):
20 raise RuntimeError("remctl to host %s returned non-zero exit status %d; stderr:\n%s"
21 % (s, p.returncode, outputs[s][1]))
22 return [(s, yaml.load(o[0], yaml.CSafeLoader)) for (s, o) in outputs.iteritems()]