<s> import sys <EOL> import time <EOL> from boto . ec2 . connection import EC2Connection <EOL> vminfo = { <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:win32>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : ( '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:win32>' ) , <EOL> } <EOL> def check_inst_state ( imgname , inst , start_state , sleeptime = <NUM_LIT:10> ) : <EOL> while True : <EOL> inst . update ( ) <EOL> print '<STR_LIT>' % ( imgname , inst . state ) <EOL> if inst . state != start_state : <EOL> break <EOL> time . sleep ( sleeptime ) <EOL> def start_instance ( name ) : <EOL> img = conn . get_image ( vminfo [ name ] [ <NUM_LIT:0> ] ) <EOL> print "<STR_LIT>" % ( name , img ) <EOL> print "<STR_LIT>" % ( name , img . location ) <EOL> print '<STR_LIT>' % name <EOL> reservation = img . run ( key_name = '<STR_LIT>' , security_groups = [ '<STR_LIT:default>' ] , <EOL> instance_type = vminfo [ name ] [ <NUM_LIT:1> ] ) <EOL> inst = reservation . instances [ <NUM_LIT:0> ] <EOL> check_inst_state ( name , inst , u'<STR_LIT>' ) <EOL> return ( img , inst ) <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> conn = EC2Connection ( ) <EOL> if len ( sys . argv ) < <NUM_LIT:2> : <EOL> for reservation in conn . get_all_instances ( ) : <EOL> print '<STR_LIT>' , reservation <EOL> for inst in reservation . instances : <EOL> print '<STR_LIT>' , inst <EOL> print '<STR_LIT>' , inst . state <EOL> if inst . state == u'<STR_LIT>' : <EOL> print vars ( inst ) <EOL> else : <EOL> name = sys . argv [ <NUM_LIT:1> ] <EOL> img , inst = start_instance ( name ) <EOL> print '<STR_LIT>' , inst . public_dns_name </s>
