def prepare_instances(instances, test, cmd, log, tty=False): procs = [] for p in instances: p.update(True) if ec2.run_ssh_command(p.public_dns_name, test) != 0: print log + " on instance " + p.id + " (" + p.public_dns_name + ")." procs.append(ec2.run_ssh_command_bg(p.public_dns_name, cmd, tty)) for p in procs: p.wait()
kill() if invoke or invokebg: running = ec2.get_running_instances( tag=['role', filter] if filter else None) if invokebg: procs = [ ec2.run_ssh_command_bg(r.public_dns_name, invokebg, tty=sshtty) for r in running ] for p in procs: p.wait() else: [ ec2.run_ssh_command(r.public_dns_name, invoke, tty=sshtty) for r in running ] exit(0) running = [] newmachines = [] def startup_instances(num, cluster, type, roletag): global running, newmachines if num == 0: return [] machines = int(math.ceil(num / float(cluster)))
exit(0) ec2.connect() if justkill: kill() if invoke or invokebg: running = ec2.get_running_instances(tag=['role', filter] if filter else None) if invokebg: procs = [ec2.run_ssh_command_bg(r.public_dns_name, invokebg, tty=sshtty) for r in running] for p in procs: p.wait() else: [ec2.run_ssh_command(r.public_dns_name, invoke, tty=sshtty) for r in running] exit(0) running = [] newmachines = [] def startup_instances(num, cluster, type, roletag): global running, newmachines if num == 0: return [] machines = int(math.ceil(num / float(cluster))) running_ = ec2.get_running_instances(type, ['role', roletag]) pending_ = []