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()
ec2.cancel_spot_requests(ec2.get_all_spot_requests()) 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 kill(): print "Going nuclear on EC2" ec2.terminate_machines([i for i in ec2.get_all_instances() if 'hold' not in i.tags]) ec2.cancel_spot_requests(ec2.get_all_spot_requests()) 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 []