def wait_for_ip(reservation_id): print options.YELLOW, "waiting for IP address", options.WHITE conn = boto.ec2.connect_to_region(options.get_region()) ip_address = None while ip_address == None: time.sleep(1) ip_address = conn.get_all_reservations(filters={"reservation-id": reservation_id})[0].instances[0].ip_address print options.GREEN, "Instance online", options.WHITE wait_for_ssh(ip_address) return ip_address
def wait_for_ip(reservation_id): print options.YELLOW, "waiting for IP address", options.WHITE conn = boto.ec2.connect_to_region(options.get_region()) ip_address = None while ip_address == None: time.sleep(1) ip_address = conn.get_all_reservations( filters={"reservation-id": reservation_id })[0].instances[0].ip_address print options.GREEN, "Instance online", options.WHITE wait_for_ssh(ip_address) return ip_address
#!/usr/bin/env python import boto import boto.ec2 import options import subprocess import os import time conn = boto.ec2.connect_to_region(options.get_region()) def setup_instance(): reservation = conn.run_instances( options.get_ami_id(), instance_type=options.get_instance_type(), key_name=options.get_ssh_key(), security_groups=[options.get_security_group()]) reservation.instances[0].add_tag('Name', value=options.get_instance_name()) return wait_for_ip(reservation.id) def wait_for_ssh(ip_address): print options.YELLOW, "waiting for SSH access", options.WHITE e_code = 1 while e_code != 0: p = subprocess.Popen([ "ssh", "-i", options.get_ssh_key() + ".pem", options.get_ssh_user() + "@" + ip_address, "hostname" ])
#!/usr/bin/env python import boto import boto.ec2 import options import subprocess import os import time conn = boto.ec2.connect_to_region(options.get_region()) def setup_instance(): reservation = conn.run_instances(options.get_ami_id(), instance_type=options.get_instance_type(), key_name=options.get_ssh_key(), security_groups=[options.get_security_group()]) reservation.instances[0].add_tag('Name', value=options.get_instance_name()) return wait_for_ip(reservation.id) def wait_for_ssh(ip_address): print options.YELLOW, "waiting for SSH access", options.WHITE e_code = 1 while e_code != 0: p = subprocess.Popen(["ssh", "-i", options.get_ssh_key() + ".pem", options.get_ssh_user() + "@" + ip_address, "hostname"]) e_code = p.wait() time.sleep(1) print options.GREEN, "SSH access obtained", options.GREEN def wait_for_ip(reservation_id): print options.YELLOW, "waiting for IP address", options.WHITE conn = boto.ec2.connect_to_region(options.get_region()) ip_address = None while ip_address == None: