<s> import time <EOL> from eucaops import Eucaops <EOL> from eucaops import EC2ops <EOL> from eutester . eutestcase import EutesterTestCase <EOL> import os <EOL> import random <EOL> class ConsoleCleanUp ( EutesterTestCase ) : <EOL> def __init__ ( self , extra_args = None , ** kwargs ) : <EOL> self . setuptestcase ( ) <EOL> self . setup_parser ( ) <EOL> if extra_args : <EOL> for arg in extra_args : <EOL> self . parser . add_argument ( arg ) <EOL> self . get_args ( ) <EOL> for kwarg in kwargs : <EOL> self . args [ kwarg ] = kwarg [ kwarg ] <EOL> if self . args . region : <EOL> self . tester = EC2ops ( credpath = self . args . credpath , region = self . args . region ) <EOL> else : <EOL> self . tester = Eucaops ( credpath = self . args . credpath , config_file = self . args . config , password = self . args . password ) <EOL> self . tester . poll_count = <NUM_LIT> <EOL> def populate_resources_for_console_test ( self ) : <EOL> '''<STR_LIT>''' <EOL> zone = self . tester . ec2 . get_all_zones ( ) [ <NUM_LIT:0> ] . name <EOL> volume = self . tester . ec2 . create_volume ( <NUM_LIT:1> , zone ) <EOL> self . tester . wait_for_volume ( volume ) <EOL> snapshot = self . tester . create_snapshot_from_volume ( volume ) <EOL> self . tester . create_volume ( zone = zone , snapshot = snapshot ) <EOL> keypair = self . tester . ec2 . create_key_pair ( "<STR_LIT>" ) . name <EOL> s_group = self . tester . ec2 . create_security_group ( "<STR_LIT>" , "<STR_LIT>" ) . name <EOL> image = self . tester . get_images ( ) [ <NUM_LIT:0> ] <EOL> image_id = self . tester . get_images ( ) [ <NUM_LIT:0> ] . id <EOL> instance = self . tester . run_image ( image = image , keypair = "<STR_LIT>" , group = "<STR_LIT>" , auto_connect = False , zone = zone ) <EOL> instance_id = self . tester . get_instances ( '<STR_LIT>' ) [ <NUM_LIT:0> ] . id <EOL> ip = self . tester . allocate_address ( ) . public_ip <EOL> self . tester . allocate_address ( ) <EOL> self . tester . ec2 . associate_address ( instance_id , ip ) <EOL> self . tester . create_launch_config ( "<STR_LIT>" , image_id , keypair , [ s_group ] , instance_type = "<STR_LIT>" ) <EOL> self . tester . create_as_group ( "<STR_LIT>" , "<STR_LIT>" , self . tester . get_zones ( ) , min_size = <NUM_LIT:1> , max_size = <NUM_LIT:8> , desired_capacity = <NUM_LIT:2> ) <EOL> instance = self . tester . get_instances ( '<STR_LIT>' ) [ <NUM_LIT:0> ] <EOL> self . tester . attach_volume ( instance , volume , "<STR_LIT>" ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> testcase = ConsoleCleanUp ( ) <EOL> list = testcase . args . tests or [ "<STR_LIT>" ] <EOL> unit_list = [ ] <EOL> for test in list : <EOL> unit_list . append ( testcase . create_testunit_by_name ( test ) ) <EOL> result = testcase . run_test_case_list ( unit_list , clean_on_exit = False ) <EOL> exit ( result ) </s>
