<s> '''<STR_LIT>''' <EOL> from eucaops import Eucaops <EOL> from eutester import Eutester <EOL> from eutester . eutestcase import EutesterTestCase <EOL> from argparse import ArgumentError <EOL> from boto . ec2 . blockdevicemapping import BlockDeviceMapping , BlockDeviceType <EOL> import time <EOL> import types <EOL> import httplib <EOL> import copy <EOL> import math <EOL> import re <EOL> class FixedBlockDeviceMapping ( BlockDeviceMapping ) : <EOL> def _build_list_params ( self , params , prefix = '<STR_LIT>' ) : <EOL> i = <NUM_LIT:1> <EOL> for dev_name in self : <EOL> pre = '<STR_LIT>' % ( prefix , i ) <EOL> params [ '<STR_LIT>' % pre ] = dev_name <EOL> block_dev = self [ dev_name ] <EOL> if block_dev . ephemeral_name : <EOL> params [ '<STR_LIT>' % pre ] = block_dev . ephemeral_name <EOL> else : <EOL> if block_dev . no_device : <EOL> params [ '<STR_LIT>' % pre ] = '<STR_LIT:true>' <EOL> else : <EOL> if block_dev . snapshot_id : <EOL> params [ '<STR_LIT>' % pre ] = block_dev . snapshot_id <EOL> if block_dev . size : <EOL> params [ '<STR_LIT>' % pre ] = block_dev . size <EOL> if block_dev . delete_on_termination : <EOL> params [ '<STR_LIT>' % pre ] = '<STR_LIT:true>' <EOL> else : <EOL> params [ '<STR_LIT>' % pre ] = '<STR_LIT:false>' <EOL> if block_dev . volume_type : <EOL> params [ '<STR_LIT>' % pre ] = block_dev . volume_type <EOL> if block_dev . iops is not None : <EOL> params [ '<STR_LIT>' % pre ] = block_dev . iops <EOL> if block_dev . encrypted is not None : <EOL> if block_dev . encrypted : <EOL> params [ '<STR_LIT>' % pre ] = '<STR_LIT:true>' <EOL> else : <EOL> params [ '<STR_LIT>' % pre ] = '<STR_LIT:false>' <EOL> i += <NUM_LIT:1> <EOL> def build_list_params ( self , params , prefix = '<STR_LIT>' ) : <EOL> return self . _build_list_params ( params = params , prefix = prefix ) <EOL> class Block_Device_Mapping_Tests ( EutesterTestCase ) : <EOL> gig = <NUM_LIT> <EOL> def __init__ ( self , url = None , tester = None , instance_password = None , ** kwargs ) : <EOL> self . setuptestcase ( ) <EOL> self . setup_parser ( ) <EOL> self . parser . add_argument ( '<STR_LIT>' , <EOL> action = '<STR_LIT:store_true>' , default = False , <EOL> help = '<STR_LIT>' ) <EOL> self . parser . add_argument ( "<STR_LIT>" , <EOL> dest = "<STR_LIT:url>" , <EOL> help = "<STR_LIT>" , <EOL> default = None ) <EOL> self . tester = tester <EOL> self . url = url <EOL> self . get_args ( ) <EOL> for kw in kwargs : <EOL> print '<STR_LIT>' + str ( kw ) + "<STR_LIT>" + str ( kwargs [ kw ] ) <EOL> self . set_arg ( kw , kwargs [ kw ] ) <EOL> self . show_args ( ) <EOL> Eutester . _EUTESTER_FORCE_ANSI_ESCAPE = self . args . use_color <EOL> if not self . tester : <EOL> try : <EOL> self . tester = self . do_with_args ( Eucaops ) <EOL> except Exception , e : <EOL> raise Exception ( '<STR_LIT>' '<STR_LIT>' + str ( e ) ) <EOL> self . tester . debug = lambda msg : self . debug ( msg , traceback = <NUM_LIT:2> , linebyline = False ) <EOL> if not self . url : <EOL> if not self . args . url : <EOL> raise ArgumentError ( None , '<STR_LIT>' ) <EOL> else : <EOL> self . url = self . args . url <EOL> self . reservation = None <EOL> self . instance = None <EOL> self . volumes = [ ] <EOL> self . image_bytes = None <EOL> self . image_gigs = None <EOL> self . build_image_volume = None <EOL> self . build_image_volume_tag_name = '<STR_LIT>' <EOL> self . build_image_snapshot = None <EOL> self . build_image_snapshot_tag_name = '<STR_LIT>' <EOL> self . block_device_map = None <EOL> self . base_test_volume = None <EOL> self . base_test_volume_tag_name = '<STR_LIT>' <EOL> self . base_test_snapshot = None <EOL> self . base_test_snapshot_tag_name = '<STR_LIT>' <EOL> self . test_image1 = None <EOL> self . test_image1_tag_name = '<STR_LIT>' <EOL> self . test_image2 = None <EOL> self . test_image2_tag_name = '<STR_LIT>' <EOL> self . test_image3 = None <EOL> self . test_image3_tag_name = '<STR_LIT>' <EOL> self . test_image4 = None <EOL> self . test_image4_tag_name = '<STR_LIT>' <EOL> self . snapshots = [ ] <EOL> self . images = [ ] <EOL> self . instance_password = instance_password <EOL> if self . args . zone : <EOL> self . zone = str ( self . args . zone ) <EOL> else : <EOL> zones = self . tester . get_zones ( ) <EOL> if zones : <EOL> self . zone = zones [ <NUM_LIT:0> ] <EOL> else : <EOL> raise RuntimeError ( '<STR_LIT>' ) <EOL> self . groupname = '<STR_LIT>' <EOL> self . group = self . tester . add_group ( self . groupname ) <EOL> self . tester . authorize_group ( self . group ) <EOL> self . tester . authorize_group ( self . group , protocol = '<STR_LIT>' , port = '<STR_LIT>' ) <EOL> if self . instance_password : <EOL> self . keypair = None <EOL> else : <EOL> try : <EOL> keys = self . tester . get_all_current_local_keys ( ) <EOL> if keys : <EOL> self . keypair = keys [ <NUM_LIT:0> ] <EOL> else : <EOL> self . keypair = self . tester . add_keypair ( '<STR_LIT>' + str ( time . time ( ) ) ) <EOL> except Exception , ke : <EOL> raise Exception ( "<STR_LIT>" + str ( ke ) ) <EOL> if self . args . emi : <EOL> self . image = self . tester . get_emi ( emi = str ( self . args . emi ) ) <EOL> else : <EOL> images = self . tester . get_images ( basic_image = True , not_platform = '<STR_LIT>' , <EOL> root_device_type = '<STR_LIT>' ) <EOL> if images : <EOL> self . image = images [ <NUM_LIT:0> ] <EOL> if not self . image : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> self . clean_method = self . cleanup <EOL> def cleanup ( self ) : <EOL> '''<STR_LIT>''' <EOL> id_list = [ ] <EOL> delete_list = [ ] <EOL> for snap in self . tester . test_resources [ '<STR_LIT>' ] : <EOL> if self . base_test_snapshot and re . search ( snap . id , self . base_test_snapshot . id ) : <EOL> self . debug ( '<STR_LIT>' ) <EOL> elif self . build_image_snapshot and re . search ( snap . id , self . build_image_snapshot . id ) : <EOL> self . debug ( '<STR_LIT>' ) <EOL> else : <EOL> delete_list . append ( snap ) <EOL> self . tester . test_resources [ '<STR_LIT>' ] = delete_list <EOL> self . tester . cleanup_artifacts ( ) <EOL> def get_remote_file_size_via_http ( self , url = None ) : <EOL> url = url or self . url <EOL> try : <EOL> url = url . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> host = url . split ( '<STR_LIT:/>' ) [ <NUM_LIT:0> ] <EOL> path = url . replace ( host , '<STR_LIT>' ) <EOL> self . debug ( "<STR_LIT>" + host + "<STR_LIT>" + path + "<STR_LIT:)>" ) <EOL> conn = httplib . HTTPConnection ( host ) <EOL> conn . request ( "<STR_LIT>" , path ) <EOL> res = conn . getresponse ( ) <EOL> image_bytes = int ( res . getheader ( '<STR_LIT>' ) ) <EOL> self . debug ( "<STR_LIT>" + str ( self . image_bytes ) ) <EOL> conn . close ( ) <EOL> except Exception , e : <EOL> self . debug ( "<STR_LIT>" ) <EOL> raise e <EOL> self . status ( '<STR_LIT>' + str ( url ) + "<STR_LIT>" + str ( image_bytes ) ) <EOL> return image_bytes <EOL> def get_existing_test_snapshot_by_tag_key ( self , tagkey ) : <EOL> snapshots = self . tester . get_snapshots ( filters = { '<STR_LIT>' : str ( tagkey ) } ) <EOL> for snapshot in snapshots : <EOL> if '<STR_LIT>' in snapshot . tags and '<STR_LIT>' in snapshot . tags : <EOL> return snapshot <EOL> return None <EOL> def get_existing_test_volume_by_tag_key ( self , tagkey ) : <EOL> volumes = self . tester . get_volumes ( filters = { '<STR_LIT>' : str ( tagkey ) } ) <EOL> for volume in volumes : <EOL> if '<STR_LIT>' in volume . tags and '<STR_LIT>' in volume . tags : <EOL> return volume <EOL> return None <EOL> def get_existing_test_image_by_tag_key ( self , tagkey ) : <EOL> try : <EOL> return self . tester . get_emi ( filters = { '<STR_LIT>' : str ( tagkey ) } ) <EOL> except : <EOL> return None <EOL> def setup_bfebs_instance_volume_and_snapshots_from_url ( self , url = None , create_test_vol = True , time_per_gig = <NUM_LIT:100> ) : <EOL> url = url or self . url <EOL> volumes = [ ] <EOL> self . image_bytes = self . get_remote_file_size_via_http ( url = url ) <EOL> self . image_gigs = int ( math . ceil ( float ( self . image_bytes ) / self . gig ) or <NUM_LIT:1> ) <EOL> curl_timeout = self . image_gigs * time_per_gig <EOL> self . status ( '<STR_LIT>' ) <EOL> instance = self . tester . run_image ( self . image , <EOL> keypair = self . keypair . name , <EOL> type = self . args . vmtype , <EOL> group = self . group . name , <EOL> zone = self . zone ) [ <NUM_LIT:0> ] <EOL> self . current_test_instance = instance <EOL> self . status ( '<STR_LIT>' ) <EOL> self . build_image_volume = self . tester . create_volumes ( self . zone , size = self . image_gigs , monitor_to_state = None ) [ <NUM_LIT:0> ] <EOL> volumes . append ( self . build_image_volume ) <EOL> self . build_image_volume . add_tag ( self . build_image_volume_tag_name ) <EOL> if create_test_vol : <EOL> self . base_test_volume = self . tester . create_volumes ( self . zone , size = <NUM_LIT:1> , monitor_to_state = None ) [ <NUM_LIT:0> ] <EOL> volumes . append ( self . base_test_volume ) <EOL> self . base_test_volume . add_tag ( self . base_test_volume_tag_name ) <EOL> self . tester . monitor_created_euvolumes_to_state ( volumes = volumes ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . attach_volume ( self . build_image_volume ) <EOL> instance . sys ( "<STR_LIT>" + url + "<STR_LIT>" + self . build_image_volume . guestdev + "<STR_LIT>" , timeout = curl_timeout ) <EOL> instance . md5_attached_euvolume ( self . build_image_volume ) <EOL> self . build_image_snapshot = self . tester . create_snapshots ( volume = self . build_image_volume ) [ <NUM_LIT:0> ] <EOL> self . build_image_snapshot . add_tag ( self . build_image_snapshot_tag_name ) <EOL> self . build_image_snapshot . add_tag ( '<STR_LIT>' , self . build_image_volume . md5 ) <EOL> self . build_image_snapshot . add_tag ( '<STR_LIT>' , self . build_image_volume . md5len ) <EOL> self . build_image_snapshot . add_tag ( '<STR_LIT>' , str ( url ) ) <EOL> self . build_image_volume . add_tag ( '<STR_LIT>' , str ( url ) ) <EOL> self . build_image_volume . add_tag ( '<STR_LIT>' , self . build_image_volume . md5 ) <EOL> self . build_image_volume . add_tag ( '<STR_LIT>' , self . build_image_volume . md5len ) <EOL> self . status ( '<STR_LIT>' ) <EOL> if create_test_vol : <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . attach_volume ( self . base_test_volume ) <EOL> instance . vol_write_random_data_get_md5 ( self . base_test_volume , overwrite = True ) <EOL> self . base_test_snapshot = self . tester . create_snapshots ( volume = self . base_test_volume ) [ <NUM_LIT:0> ] <EOL> self . base_test_snapshot . add_tag ( self . base_test_snapshot_tag_name ) <EOL> self . base_test_volume . add_tag ( '<STR_LIT>' , self . base_test_volume . md5 ) <EOL> self . base_test_volume . add_tag ( '<STR_LIT>' , self . base_test_volume . md5len ) <EOL> self . base_test_snapshot . add_tag ( '<STR_LIT>' , self . base_test_volume . md5 ) <EOL> self . base_test_snapshot . add_tag ( '<STR_LIT>' , self . base_test_volume . md5len ) <EOL> instance . terminate_and_verify ( ) <EOL> return self . build_image_snapshot <EOL> def add_block_device_types_to_mapping ( self , <EOL> device_name , <EOL> ephemeral_name = None , <EOL> snapshot_id = None , <EOL> size = None , <EOL> no_device = False , <EOL> delete_on_terminate = True , <EOL> block_device_map = None ) : <EOL> block_device_map = block_device_map or FixedBlockDeviceMapping ( ) <EOL> block_dev_type = BlockDeviceType ( ) <EOL> block_dev_type . delete_on_termination = delete_on_terminate <EOL> block_dev_type . no_device = no_device <EOL> block_dev_type . size = size <EOL> if snapshot_id : <EOL> if isinstance ( snapshot_id , types . StringTypes ) : <EOL> snapshot_id = snapshot_id <EOL> else : <EOL> snapshot_id = snapshot_id . id <EOL> block_dev_type . snapshot_id = snapshot_id <EOL> elif ephemeral_name : <EOL> block_dev_type . ephemeral_name = ephemeral_name <EOL> block_device_map [ device_name ] = block_dev_type <EOL> return block_device_map <EOL> def create_bfebs_image ( self , <EOL> snapshot , <EOL> root_device_name = '<STR_LIT>' , <EOL> name = None , <EOL> delete_on_terminate = True , <EOL> size = None , <EOL> block_device_map = None ) : <EOL> if isinstance ( snapshot , types . StringTypes ) : <EOL> snapshot_id = snapshot <EOL> else : <EOL> snapshot_id = snapshot . id <EOL> image_id = self . tester . register_snapshot_by_id ( snap_id = snapshot_id , <EOL> root_device_name = root_device_name , <EOL> size = size , <EOL> dot = delete_on_terminate , <EOL> name = name , <EOL> block_device_map = block_device_map <EOL> ) <EOL> new_image = self . tester . get_emi ( emi = image_id ) <EOL> self . images . append ( new_image ) <EOL> return new_image <EOL> def populate_self_from_existing_test_resources ( self , build_image = True , base_test = True ) : <EOL> if build_image : <EOL> self . build_image_snapshot = self . get_existing_test_snapshot_by_tag_key ( tagkey = self . build_image_snapshot_tag_name ) <EOL> if self . build_image_snapshot : <EOL> self . build_image_snapshot . eutest_volume_md5 = self . build_image_snapshot . tags . get ( '<STR_LIT>' ) <EOL> self . build_image_snapshot . eutest_volume_md5len = int ( self . build_image_snapshot . tags . get ( '<STR_LIT>' ) ) <EOL> self . build_image_volume = self . get_existing_test_volume_by_tag_key ( tagkey = self . build_image_volume_tag_name ) <EOL> if self . build_image_volume : <EOL> self . build_image_volume . md5 = self . build_image_volume . tags . get ( '<STR_LIT>' ) <EOL> self . build_image_volume . md5len = int ( self . build_image_volume . tags . get ( '<STR_LIT>' ) ) <EOL> if base_test : <EOL> self . base_test_snapshot = self . get_existing_test_snapshot_by_tag_key ( tagkey = self . base_test_snapshot_tag_name ) <EOL> if self . base_test_snapshot : <EOL> self . base_test_snapshot . eutest_volume_md5 = self . base_test_snapshot . tags . get ( '<STR_LIT>' ) <EOL> self . base_test_snapshot . eutest_volume_md5len = int ( self . base_test_snapshot . tags . get ( '<STR_LIT>' ) ) <EOL> self . base_test_volume = self . get_existing_test_volume_by_tag_key ( self . base_test_volume_tag_name ) <EOL> if self . base_test_volume : <EOL> self . base_test_volume . md5 = self . base_test_volume . tags . get ( '<STR_LIT>' ) <EOL> self . base_test_volume . md5len = int ( self . base_test_volume . tags . get ( '<STR_LIT>' ) ) <EOL> self . test_image1 = self . get_existing_test_image_by_tag_key ( self . test_image1_tag_name ) <EOL> self . test_image2 = self . get_existing_test_image_by_tag_key ( self . test_image2_tag_name ) <EOL> self . test_image3 = self . get_existing_test_image_by_tag_key ( self . test_image3_tag_name ) <EOL> self . test_image4 = self . get_existing_test_image_by_tag_key ( self . test_image4_tag_name ) <EOL> def try_existing_resources_else_create_them ( self , url = None ) : <EOL> self . populate_self_from_existing_test_resources ( ) <EOL> if not self . build_image_snapshot or not self . base_test_snapshot : <EOL> self . debug ( '<STR_LIT>' + <EOL> '<STR_LIT>' + str ( self . build_image_volume ) + <EOL> '<STR_LIT>' + str ( self . build_image_snapshot ) + <EOL> '<STR_LIT>' + str ( self . base_test_snapshot ) + <EOL> '<STR_LIT>' + str ( self . base_test_volume ) + "<STR_LIT:\n>" ) <EOL> self . debug ( '<STR_LIT>' ) <EOL> url = url or self . url <EOL> if not url : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> self . setup_bfebs_instance_volume_and_snapshots_from_url ( url = url ) <EOL> if not self . build_image_volume : <EOL> self . build_test_volume = self . tester . create_volume ( zone = self . zone , snapshot = self . build_image_snapshot ) <EOL> self . build_image_volume . md5 = self . build_image_snapshot . md5 = self . build_image_snapshot . eutest_volume_md5 <EOL> self . build_image_volume . md5len = self . build_image_snapshot . eutest_volume_md5len <EOL> self . build_image_volume . add_tag ( '<STR_LIT>' , self . build_image_volume . md5 ) <EOL> self . build_image_volume . add_tag ( '<STR_LIT>' , self . build_image_volume . md5len ) <EOL> if not self . base_test_volume : <EOL> self . status ( '<STR_LIT>' ) <EOL> self . base_test_volume = self . tester . create_volume ( zone = self . zone , snapshot = self . base_test_snapshot ) <EOL> self . base_test_volume . md5 = self . base_test_snapshot . md5 = self . build_image_snapshot . eutest_volume_md5 <EOL> self . base_test_volume . md5len = self . base_test_snapshot . eutest_volume_md5len <EOL> self . base_test_volume . add_tag ( '<STR_LIT>' , self . base_test_volume . md5 ) <EOL> self . base_test_volume . add_tag ( '<STR_LIT>' , self . base_test_volume . md5len ) <EOL> def find_volume_on_euinstance ( self , euinstance , map_device_name , md5 = None , md5len = None , euvolume = None , ) : <EOL> '''<STR_LIT>''' <EOL> md5 = md5 or euvolume . md5 <EOL> md5len = md5len or euvolume . md5len <EOL> return euinstance . get_guest_dev_for_block_device_map_device ( md5 = md5 , md5len = md5len , map_device = map_device_name ) <EOL> def register_n_run_test1_bfebs_image_w_dot_is_true ( self ) : <EOL> '''<STR_LIT>''' <EOL> errmsg = "<STR_LIT>" <EOL> image_name = self . test_image1_tag_name + "<STR_LIT:_>" + str ( self . build_image_snapshot . id ) <EOL> image = self . create_bfebs_image ( snapshot = self . build_image_snapshot , name = image_name , delete_on_terminate = True ) <EOL> if not image . block_device_mapping . get ( image . root_device_name ) . delete_on_termination : <EOL> raise Exception ( '<STR_LIT>' + <EOL> str ( image . block_device_mapping . get ( image . root_device_name . delete_on_termination ) ) ) <EOL> self . status ( '<STR_LIT>' + str ( image . id ) + '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( image . block_device_mapping ) <EOL> self . test_image1 = image <EOL> self . test_image1 . add_tag ( self . test_image1_tag_name ) <EOL> instance = self . tester . run_image ( image = image , keypair = self . keypair , group = self . group ) [ <NUM_LIT:0> ] <EOL> try : <EOL> self . current_test_instance = instance <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( instance . block_device_mapping ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . find_volume_on_euinstance ( instance , <EOL> instance . root_device_name , <EOL> md5 = self . build_image_snapshot . eutest_volume_md5 , <EOL> md5len = self . build_image_snapshot . eutest_volume_md5len ) <EOL> self . status ( '<STR_LIT>' ) <EOL> try : <EOL> instance . get_ephemeral_dev ( ) <EOL> except : <EOL> self . debug ( '<STR_LIT>' ) <EOL> else : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . check_instance_meta_data_for_block_device_mapping ( ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . stop_instance_and_verify ( ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . start_instance_and_verify ( checkvolstatus = True ) <EOL> self . status ( '<STR_LIT>' ) <EOL> except Exception , e : <EOL> tb = self . tester . get_traceback ( ) <EOL> errmsg = str ( tb ) + '<STR_LIT>' + str ( e ) <EOL> self . endfailure ( errmsg ) <EOL> finally : <EOL> instance . terminate_and_verify ( ) <EOL> if errmsg : <EOL> raise Exception ( errmsg ) <EOL> def register_n_run_test2_bfebs_image_w_dot_is_false ( self ) : <EOL> '''<STR_LIT>''' <EOL> errmsg = "<STR_LIT>" <EOL> image_name = self . test_image2_tag_name + "<STR_LIT:_>" + str ( self . build_image_snapshot . id ) <EOL> image = self . create_bfebs_image ( snapshot = self . build_image_snapshot , name = image_name , delete_on_terminate = False ) <EOL> if image . block_device_mapping . get ( image . root_device_name ) . delete_on_termination : <EOL> raise Exception ( '<STR_LIT>' + <EOL> str ( image . block_device_mapping . get ( image . root_device_name . delete_on_termination ) ) ) <EOL> self . status ( '<STR_LIT>' + str ( image . id ) + '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( image . block_device_mapping ) <EOL> self . test_image2 = image <EOL> self . test_image2 . add_tag ( self . test_image2_tag_name ) <EOL> instance = self . tester . run_image ( image = image , keypair = self . keypair , group = self . group ) [ <NUM_LIT:0> ] <EOL> try : <EOL> self . current_test_instance = instance <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( instance . block_device_mapping ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . find_volume_on_euinstance ( instance , <EOL> instance . root_device_name , <EOL> md5 = self . build_image_snapshot . eutest_volume_md5 , <EOL> md5len = self . build_image_snapshot . eutest_volume_md5len ) <EOL> self . status ( '<STR_LIT>' ) <EOL> try : <EOL> instance . get_ephemeral_dev ( ) <EOL> except : <EOL> self . debug ( '<STR_LIT>' ) <EOL> else : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . check_instance_meta_data_for_block_device_mapping ( ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . stop_instance_and_verify ( ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . start_instance_and_verify ( checkvolstatus = True ) <EOL> self . status ( '<STR_LIT>' ) <EOL> except Exception , e : <EOL> tb = self . tester . get_traceback ( ) <EOL> errmsg = str ( tb ) + '<STR_LIT>' + str ( e ) <EOL> self . endfailure ( errmsg ) <EOL> finally : <EOL> instance . terminate_and_verify ( ) <EOL> if errmsg : <EOL> raise Exception ( errmsg ) <EOL> def register_n_run_test3_bfebs_image_w_ephemeral_map_snap_map_and_ebsvol_map_dot_is_true ( self ) : <EOL> '''<STR_LIT>''' <EOL> errmsg = "<STR_LIT>" <EOL> image_name = self . test_image3_tag_name + "<STR_LIT:_>" + str ( self . build_image_snapshot . id ) <EOL> bdm_emptyvol_dev = '<STR_LIT>' <EOL> bdm_snapshot_dev = '<STR_LIT>' <EOL> bdm_ephemeral_dev = '<STR_LIT>' <EOL> bdm_ephemeral_name = '<STR_LIT>' <EOL> bdm_emptyvol_size = <NUM_LIT:2> <EOL> self . status ( '<STR_LIT>' ) <EOL> bdm = self . add_block_device_types_to_mapping ( snapshot_id = self . base_test_snapshot . id , <EOL> device_name = bdm_snapshot_dev , <EOL> delete_on_terminate = True ) <EOL> self . add_block_device_types_to_mapping ( size = bdm_emptyvol_size , <EOL> device_name = bdm_emptyvol_dev , <EOL> delete_on_terminate = True , <EOL> block_device_map = bdm ) <EOL> eph_dev = BlockDeviceType ( ) <EOL> eph_dev . device_name = bdm_ephemeral_dev <EOL> eph_dev . ephemeral_name = bdm_ephemeral_name <EOL> bdm [ bdm_ephemeral_dev ] = eph_dev <EOL> self . tester . show_block_device_map ( bdm ) <EOL> image = self . create_bfebs_image ( snapshot = self . build_image_snapshot , <EOL> block_device_map = bdm , <EOL> name = image_name , <EOL> delete_on_terminate = True ) <EOL> self . tester . show_block_device_map ( image . block_device_mapping ) <EOL> self . test_image3 = image <EOL> self . test_image3 . add_tag ( self . test_image3_tag_name ) <EOL> self . status ( '<STR_LIT>' + str ( image . id ) + '<STR_LIT>' ) <EOL> instance = self . tester . run_image ( image = image , keypair = self . keypair , group = self . group ) [ <NUM_LIT:0> ] <EOL> try : <EOL> self . current_test_instance = instance <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( instance . block_device_mapping ) <EOL> self . status ( '<STR_LIT>' + <EOL> '<STR_LIT>' + <EOL> '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_root_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . build_image_snapshot . eutest_volume_md5 , <EOL> md5len = self . build_image_snapshot . eutest_volume_md5len , <EOL> map_device = instance . root_device_name ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_snap_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . base_test_snapshot . eutest_volume_md5 , <EOL> md5len = self . base_test_snapshot . eutest_volume_md5len , <EOL> map_device = bdm_snapshot_dev ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_ephemeral_dev = instance . check_ephemeral_against_vmtype ( ) <EOL> self . status ( "<STR_LIT>" ) <EOL> remaining_devs = self . find_remaining_devices ( instance , [ guest_root_dev , guest_snap_dev , guest_ephemeral_dev ] ) <EOL> if len ( remaining_devs ) != <NUM_LIT:1> : <EOL> raise Exception ( '<STR_LIT>' + str ( "<STR_LIT:U+002C>" ) . join ( remaining_devs ) ) <EOL> guest_emptyvol_device = '<STR_LIT>' + str ( remaining_devs [ <NUM_LIT:0> ] ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' + str ( guest_emptyvol_device ) + '<STR_LIT>' ) <EOL> vol_size = instance . get_blockdev_size_in_bytes ( guest_emptyvol_device ) / self . gig <EOL> if vol_size != bdm_emptyvol_size : <EOL> raise Exception ( '<STR_LIT>' + str ( vol_size ) + <EOL> "<STR_LIT>" + str ( bdm_emptyvol_size ) ) <EOL> self . status ( '<STR_LIT>' ) <EOL> empty_vol = self . tester . get_volume ( instance . block_device_mapping . get ( bdm_emptyvol_dev ) . volume_id ) <EOL> empty_vol . guestdev = guest_emptyvol_device <EOL> if not empty_vol in instance . attached_vols : <EOL> instance . attached_vols . append ( empty_vol ) <EOL> instance . vol_write_random_data_get_md5 ( empty_vol ) <EOL> self . status ( '<STR_LIT>' ) <EOL> meta_bdm = instance . block_device_mapping <EOL> if not meta_bdm . has_key ( bdm_ephemeral_dev ) : <EOL> self . resulterr ( '<STR_LIT>' ) <EOL> meta_bdm [ bdm_ephemeral_dev ] = eph_dev <EOL> instance . check_instance_meta_data_for_block_device_mapping ( root_dev = image . root_device_name , bdm = meta_bdm ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . stop_instance_and_verify ( ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . start_instance_and_verify ( checkvolstatus = True ) <EOL> self . status ( '<STR_LIT>' ) <EOL> except Exception , e : <EOL> tb = self . tester . get_traceback ( ) <EOL> errmsg = str ( tb ) + '<STR_LIT>' + str ( e ) <EOL> self . endfailure ( errmsg ) <EOL> finally : <EOL> instance . terminate_and_verify ( ) <EOL> if errmsg : <EOL> raise Exception ( errmsg ) <EOL> def register_n_run_test4_bfebs_image_w_ephemeral_map_snap_map_and_ebsvol_map_dot_is_false ( self ) : <EOL> '''<STR_LIT>''' <EOL> errmsg = "<STR_LIT>" <EOL> image_name = self . test_image4_tag_name + "<STR_LIT:_>" + str ( self . build_image_snapshot . id ) <EOL> bdm_emptyvol_dev = '<STR_LIT>' <EOL> bdm_snapshot_dev = '<STR_LIT>' <EOL> bdm_ephemeral_dev = '<STR_LIT>' <EOL> bdm_ephemeral_name = '<STR_LIT>' <EOL> bdm_emptyvol_size = <NUM_LIT:2> <EOL> self . status ( '<STR_LIT>' ) <EOL> bdm = self . add_block_device_types_to_mapping ( snapshot_id = self . base_test_snapshot . id , <EOL> device_name = bdm_snapshot_dev , <EOL> delete_on_terminate = False ) <EOL> self . add_block_device_types_to_mapping ( device_name = bdm_emptyvol_dev , <EOL> size = bdm_emptyvol_size , <EOL> delete_on_terminate = False , <EOL> block_device_map = bdm ) <EOL> eph_dev = BlockDeviceType ( ) <EOL> eph_dev . device_name = bdm_ephemeral_dev <EOL> eph_dev . ephemeral_name = bdm_ephemeral_name <EOL> bdm [ bdm_ephemeral_dev ] = eph_dev <EOL> self . tester . show_block_device_map ( bdm ) <EOL> image = self . create_bfebs_image ( snapshot = self . build_image_snapshot , <EOL> block_device_map = bdm , <EOL> name = image_name , <EOL> delete_on_terminate = False ) <EOL> self . tester . show_block_device_map ( image . block_device_mapping ) <EOL> self . test_image4 = image <EOL> self . test_image4 . add_tag ( self . test_image4_tag_name ) <EOL> self . status ( '<STR_LIT>' + str ( image . id ) + '<STR_LIT>' ) <EOL> instance = self . tester . run_image ( image = image , keypair = self . keypair , group = self . group ) [ <NUM_LIT:0> ] <EOL> try : <EOL> self . current_test_instance = instance <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( instance . block_device_mapping ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_root_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . build_image_snapshot . eutest_volume_md5 , <EOL> md5len = self . build_image_snapshot . eutest_volume_md5len , <EOL> map_device = instance . root_device_name ) <EOL> guest_snap_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . base_test_snapshot . eutest_volume_md5 , <EOL> md5len = self . base_test_snapshot . eutest_volume_md5len , <EOL> map_device = bdm_snapshot_dev ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_ephemeral_dev = instance . check_ephemeral_against_vmtype ( ) <EOL> self . status ( "<STR_LIT>" ) <EOL> remaining_devs = self . find_remaining_devices ( instance , [ guest_root_dev , guest_snap_dev , guest_ephemeral_dev ] ) <EOL> if len ( remaining_devs ) != <NUM_LIT:1> : <EOL> raise Exception ( '<STR_LIT>' + str ( "<STR_LIT:U+002C>" ) . join ( remaining_devs ) ) <EOL> guest_emptyvol_device = '<STR_LIT>' + str ( remaining_devs [ <NUM_LIT:0> ] ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' + str ( guest_emptyvol_device ) + '<STR_LIT>' ) <EOL> vol_size = instance . get_blockdev_size_in_bytes ( guest_emptyvol_device ) / self . gig <EOL> if vol_size != bdm_emptyvol_size : <EOL> raise Exception ( '<STR_LIT>' + str ( vol_size ) + <EOL> "<STR_LIT>" + str ( bdm_emptyvol_size ) ) <EOL> self . status ( '<STR_LIT>' ) <EOL> empty_vol = self . tester . get_volume ( instance . block_device_mapping . get ( bdm_emptyvol_dev ) . volume_id ) <EOL> empty_vol . guestdev = guest_emptyvol_device <EOL> if not empty_vol in instance . attached_vols : <EOL> instance . attached_vols . append ( empty_vol ) <EOL> instance . vol_write_random_data_get_md5 ( empty_vol ) <EOL> self . status ( '<STR_LIT>' ) <EOL> meta_bdm = instance . block_device_mapping <EOL> if not meta_bdm . has_key ( bdm_ephemeral_dev ) : <EOL> self . resulterr ( '<STR_LIT>' ) <EOL> meta_bdm [ bdm_ephemeral_dev ] = eph_dev <EOL> instance . check_instance_meta_data_for_block_device_mapping ( root_dev = image . root_device_name , bdm = meta_bdm ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . stop_instance_and_verify ( ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . start_instance_and_verify ( checkvolstatus = True ) <EOL> self . status ( '<STR_LIT>' ) <EOL> except Exception , e : <EOL> tb = self . tester . get_traceback ( ) <EOL> errmsg = str ( tb ) + '<STR_LIT>' + str ( e ) <EOL> self . endfailure ( errmsg ) <EOL> finally : <EOL> instance . terminate_and_verify ( ) <EOL> if errmsg : <EOL> raise Exception ( errmsg ) <EOL> def run_time_test1_image1_overwrite_root_vol_size_and_set_dot_to_false ( self ) : <EOL> '''<STR_LIT>''' <EOL> errmsg = "<STR_LIT>" <EOL> image = self . test_image1 <EOL> bdm_rootsnap_size = image . block_device_mapping . get ( image . root_device_name ) . size + <NUM_LIT:1> <EOL> dot_value = ( not image . block_device_mapping . get ( image . root_device_name ) . delete_on_termination ) <EOL> self . status ( '<STR_LIT>' + str ( self . test_image1 . id ) + "<STR_LIT>" + <EOL> str ( bdm_rootsnap_size ) + "<STR_LIT>" ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( image . block_device_mapping ) <EOL> bdm = self . add_block_device_types_to_mapping ( device_name = image . root_device_name , <EOL> size = bdm_rootsnap_size , <EOL> delete_on_terminate = dot_value ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( bdm ) <EOL> instance = self . tester . run_image ( image = image , block_device_map = bdm , keypair = self . keypair , group = self . group ) [ <NUM_LIT:0> ] <EOL> try : <EOL> self . current_test_instance = instance <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( instance . block_device_mapping ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_root_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . build_image_snapshot . eutest_volume_md5 , <EOL> md5len = self . build_image_snapshot . eutest_volume_md5len , <EOL> map_device = instance . root_device_name ) <EOL> self . status ( '<STR_LIT>' ) <EOL> root_dev_size = instance . get_blockdev_size_in_bytes ( guest_root_dev ) / self . gig <EOL> if root_dev_size != bdm_rootsnap_size : <EOL> raise Exception ( '<STR_LIT>' + str ( root_dev_size ) + <EOL> '<STR_LIT>' + str ( bdm_rootsnap_size ) + <EOL> "<STR_LIT>" + str ( image . block_device_mapping . get ( image . root_device_name ) . size ) ) <EOL> self . status ( '<STR_LIT>' ) <EOL> try : <EOL> instance . get_ephemeral_dev ( ) <EOL> except : <EOL> self . debug ( '<STR_LIT>' ) <EOL> else : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . check_instance_meta_data_for_block_device_mapping ( root_dev = image . root_device_name , bdm = bdm ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . stop_instance_and_verify ( ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . start_instance_and_verify ( checkvolstatus = True ) <EOL> self . status ( '<STR_LIT>' ) <EOL> except Exception , e : <EOL> tb = self . tester . get_traceback ( ) <EOL> errmsg = str ( tb ) + '<STR_LIT>' + str ( e ) <EOL> self . endfailure ( errmsg ) <EOL> finally : <EOL> instance . terminate_and_verify ( ) <EOL> if errmsg : <EOL> raise Exception ( errmsg ) <EOL> def run_time_test2_image1_add_ephemeral_map_snap_map_emptyvol_map_at_run_time_dot_true ( self ) : <EOL> '''<STR_LIT>''' <EOL> errmsg = "<STR_LIT>" <EOL> image = self . test_image1 <EOL> bdm_emptyvol_dev = '<STR_LIT>' <EOL> bdm_snapshot_dev = '<STR_LIT>' <EOL> bdm_ephemeral_dev = '<STR_LIT>' <EOL> bdm_ephemeral_name = '<STR_LIT>' <EOL> bdm_rootsnap_size = image . block_device_mapping . get ( image . root_device_name ) . size <EOL> bdm_emptyvol_size = <NUM_LIT:1> <EOL> bdm_snap_size = self . base_test_snapshot . volume_size + <NUM_LIT:1> <EOL> self . status ( '<STR_LIT>' + str ( self . test_image1 . id ) + "<STR_LIT>" ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( image . block_device_mapping ) <EOL> bdm = self . add_block_device_types_to_mapping ( snapshot_id = self . base_test_snapshot . id , <EOL> size = bdm_snap_size , <EOL> device_name = bdm_snapshot_dev , <EOL> delete_on_terminate = False ) <EOL> self . add_block_device_types_to_mapping ( device_name = bdm_emptyvol_dev , <EOL> size = bdm_emptyvol_size , <EOL> delete_on_terminate = False , <EOL> block_device_map = bdm ) <EOL> eph_dev = BlockDeviceType ( ) <EOL> eph_dev . device_name = bdm_ephemeral_dev <EOL> eph_dev . ephemeral_name = bdm_ephemeral_name <EOL> bdm [ bdm_ephemeral_dev ] = eph_dev <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( bdm ) <EOL> instance = self . tester . run_image ( image = image , block_device_map = bdm , keypair = self . keypair , group = self . group ) [ <NUM_LIT:0> ] <EOL> try : <EOL> self . current_test_instance = instance <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( instance . block_device_mapping ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_ephemeral_dev = instance . check_ephemeral_against_vmtype ( ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_root_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . build_image_snapshot . eutest_volume_md5 , <EOL> md5len = self . build_image_snapshot . eutest_volume_md5len , <EOL> map_device = instance . root_device_name ) <EOL> root_dev_size = instance . get_blockdev_size_in_bytes ( guest_root_dev ) / self . gig <EOL> if root_dev_size != bdm_rootsnap_size : <EOL> raise Exception ( '<STR_LIT>' + str ( root_dev_size ) + <EOL> '<STR_LIT>' + str ( bdm_rootsnap_size ) + <EOL> "<STR_LIT>" + str ( image . block_device_mapping . get ( image . root_device_name ) . size ) ) <EOL> guest_snap_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . base_test_snapshot . eutest_volume_md5 , <EOL> md5len = self . base_test_snapshot . eutest_volume_md5len , <EOL> map_device = bdm_snapshot_dev ) <EOL> guest_snapvol_size = instance . get_blockdev_size_in_bytes ( guest_snap_dev ) / self . gig <EOL> if guest_snapvol_size != bdm_snap_size : <EOL> raise Exception ( '<STR_LIT>' + str ( guest_snapvol_size ) + '<STR_LIT>' + str ( bdm_snap_size ) + <EOL> '<STR_LIT>' + str ( self . base_test_snapshot . id ) ) <EOL> self . status ( "<STR_LIT>" ) <EOL> remaining_devs = self . find_remaining_devices ( instance , [ guest_root_dev , guest_snap_dev , guest_ephemeral_dev ] ) <EOL> if len ( remaining_devs ) != <NUM_LIT:1> : <EOL> raise Exception ( '<STR_LIT>' + str ( "<STR_LIT:U+002C>" ) . join ( remaining_devs ) ) <EOL> guest_emptyvol_device = '<STR_LIT>' + str ( remaining_devs [ <NUM_LIT:0> ] ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' + str ( guest_emptyvol_device ) + '<STR_LIT>' ) <EOL> vol_size = instance . get_blockdev_size_in_bytes ( guest_emptyvol_device ) / self . gig <EOL> if vol_size != bdm_emptyvol_size : <EOL> raise Exception ( '<STR_LIT>' + str ( vol_size ) + <EOL> "<STR_LIT>" + str ( bdm_emptyvol_size ) ) <EOL> self . status ( '<STR_LIT>' ) <EOL> empty_vol = self . tester . get_volume ( instance . block_device_mapping . get ( bdm_emptyvol_dev ) . volume_id ) <EOL> empty_vol . guestdev = guest_emptyvol_device <EOL> if not empty_vol in instance . attached_vols : <EOL> instance . attached_vols . append ( empty_vol ) <EOL> instance . vol_write_random_data_get_md5 ( empty_vol ) <EOL> self . status ( '<STR_LIT>' ) <EOL> meta_bdm = instance . block_device_mapping <EOL> if not meta_bdm . has_key ( bdm_ephemeral_dev ) : <EOL> self . resulterr ( '<STR_LIT>' ) <EOL> meta_bdm [ bdm_ephemeral_dev ] = eph_dev <EOL> instance . check_instance_meta_data_for_block_device_mapping ( root_dev = image . root_device_name , bdm = meta_bdm ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . stop_instance_and_verify ( ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . start_instance_and_verify ( checkvolstatus = True ) <EOL> self . status ( '<STR_LIT>' ) <EOL> except Exception , e : <EOL> tb = self . tester . get_traceback ( ) <EOL> errmsg = str ( tb ) + '<STR_LIT>' + str ( e ) <EOL> self . endfailure ( errmsg ) <EOL> finally : <EOL> instance . terminate_and_verify ( ) <EOL> if errmsg : <EOL> raise Exception ( errmsg ) <EOL> def run_time_test3_image3_overwrite_all_non_root_w_no_device ( self ) : <EOL> errmsg = "<STR_LIT>" <EOL> image = self . test_image3 <EOL> bdm_emptyvol_dev = '<STR_LIT>' <EOL> bdm_snapshot_dev = '<STR_LIT>' <EOL> bdm_ephemeral_dev = '<STR_LIT>' <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( image . block_device_mapping ) <EOL> bdm = self . add_block_device_types_to_mapping ( device_name = bdm_ephemeral_dev , <EOL> no_device = True ) <EOL> self . add_block_device_types_to_mapping ( device_name = bdm_snapshot_dev , <EOL> no_device = True , <EOL> block_device_map = bdm ) <EOL> self . add_block_device_types_to_mapping ( device_name = bdm_emptyvol_dev , <EOL> no_device = True , <EOL> block_device_map = bdm ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( bdm ) <EOL> instance = self . tester . run_image ( image = image , block_device_map = bdm , keypair = self . keypair , group = self . group ) [ <NUM_LIT:0> ] <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( instance . block_device_mapping ) <EOL> self . status ( '<STR_LIT>' ) <EOL> try : <EOL> instance . get_ephemeral_dev ( ) <EOL> except : <EOL> self . debug ( '<STR_LIT>' ) <EOL> else : <EOL> raise Exception ( '<STR_LIT>' ) <EOL> guest_root_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . build_image_snapshot . eutest_volume_md5 , <EOL> md5len = self . build_image_snapshot . eutest_volume_md5len , <EOL> map_device = instance . root_device_name ) <EOL> self . status ( '<STR_LIT>' ) <EOL> remaining_devs = self . find_remaining_devices ( instance = instance , known_dev_list = [ guest_root_dev ] ) <EOL> if remaining_devs : <EOL> raise Exception ( '<STR_LIT>' + <EOL> str ( '<STR_LIT:U+002C>' ) . join ( remaining_devs ) ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . check_instance_meta_data_for_block_device_mapping ( ) <EOL> try : <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . stop_instance_and_verify ( ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . start_instance_and_verify ( checkvolstatus = True ) <EOL> self . status ( '<STR_LIT>' ) <EOL> except Exception , e : <EOL> tb = self . tester . get_traceback ( ) <EOL> errmsg = str ( tb ) + '<STR_LIT>' + str ( e ) <EOL> self . endfailure ( errmsg ) <EOL> finally : <EOL> instance . terminate_and_verify ( ) <EOL> if errmsg : <EOL> raise Exception ( errmsg ) <EOL> def run_time_test4_image4_overwrite_misc_attributes_and_mixed_dot_at_run_time ( self ) : <EOL> errmsg = "<STR_LIT>" <EOL> image = self . test_image4 <EOL> bdm_emptyvol_dev = '<STR_LIT>' <EOL> bdm_snapshot_dev = '<STR_LIT>' <EOL> bdm_ephemeral_dev = '<STR_LIT>' <EOL> bdm_emptyvol_size = image . block_device_mapping . get ( bdm_emptyvol_dev ) . size + <NUM_LIT:1> <EOL> bdm_emptyvol_dot = ( not image . block_device_mapping . get ( bdm_emptyvol_dev ) . delete_on_termination ) <EOL> bdm_snapshot_size = image . block_device_mapping . get ( bdm_snapshot_dev ) . size + <NUM_LIT:1> <EOL> bdm_root_size = image . block_device_mapping . get ( image . root_device_name ) . size + <NUM_LIT:1> <EOL> bdm_dot_value = ( not image . block_device_mapping . get ( image . root_device_name ) . delete_on_termination ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( image . block_device_mapping ) <EOL> bdm = self . add_block_device_types_to_mapping ( device_name = image . root_device_name , <EOL> size = bdm_root_size , <EOL> delete_on_terminate = bdm_dot_value ) <EOL> self . add_block_device_types_to_mapping ( snapshot_id = self . base_test_snapshot . id , <EOL> device_name = bdm_snapshot_dev , <EOL> delete_on_terminate = False , <EOL> size = bdm_snapshot_size , <EOL> block_device_map = bdm ) <EOL> self . add_block_device_types_to_mapping ( device_name = bdm_emptyvol_dev , <EOL> size = bdm_emptyvol_size , <EOL> delete_on_terminate = bdm_emptyvol_dot , <EOL> block_device_map = bdm ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( bdm ) <EOL> instance = self . tester . run_image ( image = image , block_device_map = bdm , keypair = self . keypair , group = self . group ) [ <NUM_LIT:0> ] <EOL> try : <EOL> self . current_test_instance = instance <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( instance . block_device_mapping ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_ephemeral_dev = instance . check_ephemeral_against_vmtype ( ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_root_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . build_image_snapshot . eutest_volume_md5 , <EOL> md5len = self . build_image_snapshot . eutest_volume_md5len , <EOL> map_device = instance . root_device_name ) <EOL> guest_root_size = instance . get_blockdev_size_in_bytes ( guest_root_dev ) / self . gig <EOL> if guest_root_size != bdm_root_size : <EOL> raise Exception ( '<STR_LIT>' + str ( guest_root_size ) + '<STR_LIT>' + str ( bdm_root_size ) + <EOL> '<STR_LIT>' ) <EOL> guest_snap_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . base_test_snapshot . eutest_volume_md5 , <EOL> md5len = self . base_test_snapshot . eutest_volume_md5len , <EOL> map_device = bdm_snapshot_dev ) <EOL> guest_snapvol_size = instance . get_blockdev_size_in_bytes ( guest_snap_dev ) / self . gig <EOL> if guest_snapvol_size != bdm_snapshot_size : <EOL> raise Exception ( '<STR_LIT>' + str ( guest_snapvol_size ) + '<STR_LIT>' + str ( bdm_snapshot_size ) + <EOL> '<STR_LIT>' + str ( self . base_test_snapshot . id ) ) <EOL> self . status ( "<STR_LIT>" ) <EOL> remaining_devs = self . find_remaining_devices ( instance , [ guest_root_dev , guest_snap_dev , guest_ephemeral_dev ] ) <EOL> if len ( remaining_devs ) != <NUM_LIT:1> : <EOL> raise Exception ( '<STR_LIT>' + str ( "<STR_LIT:U+002C>" ) . join ( remaining_devs ) ) <EOL> guest_emptyvol_device = '<STR_LIT>' + str ( remaining_devs [ <NUM_LIT:0> ] ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' + str ( guest_emptyvol_device ) + '<STR_LIT>' ) <EOL> guest_emptyvol_size = instance . get_blockdev_size_in_bytes ( guest_emptyvol_device ) / self . gig <EOL> if guest_emptyvol_size != bdm_emptyvol_size : <EOL> raise Exception ( '<STR_LIT>' + str ( guest_emptyvol_size ) + <EOL> "<STR_LIT>" + str ( bdm_emptyvol_size ) ) <EOL> self . status ( '<STR_LIT>' ) <EOL> empty_vol = self . tester . get_volume ( instance . block_device_mapping . get ( bdm_emptyvol_dev ) . volume_id ) <EOL> empty_vol . guestdev = guest_emptyvol_device <EOL> if not empty_vol in instance . attached_vols : <EOL> instance . attached_vols . append ( empty_vol ) <EOL> instance . vol_write_random_data_get_md5 ( empty_vol ) <EOL> self . status ( '<STR_LIT>' ) <EOL> meta_bdm = instance . block_device_mapping <EOL> if not meta_bdm . has_key ( bdm_ephemeral_dev ) : <EOL> self . resulterr ( '<STR_LIT>' ) <EOL> eph_dev = BlockDeviceType ( ) <EOL> eph_dev . device_name = bdm_ephemeral_dev <EOL> eph_dev . ephemeral_name = '<STR_LIT>' <EOL> meta_bdm [ bdm_ephemeral_dev ] = eph_dev <EOL> instance . check_instance_meta_data_for_block_device_mapping ( root_dev = image . root_device_name , bdm = meta_bdm ) <EOL> self . status ( '<STR_LIT>' ) <EOL> except Exception , e : <EOL> tb = self . tester . get_traceback ( ) <EOL> errmsg = str ( tb ) + '<STR_LIT>' + str ( e ) <EOL> self . endfailure ( errmsg ) <EOL> finally : <EOL> instance . terminate_and_verify ( ) <EOL> if errmsg : <EOL> raise Exception ( errmsg ) <EOL> def run_time_test5_image1_add_snap_map_attach_a_vol_to_running_instance ( self ) : <EOL> '''<STR_LIT>''' <EOL> errmsg = "<STR_LIT>" <EOL> image = self . test_image1 <EOL> bdm_emptyvol_dev = '<STR_LIT>' <EOL> bdm_snapshot_dev = '<STR_LIT>' <EOL> bdm_ephemeral_dev = '<STR_LIT>' <EOL> bdm_ephemeral_name = '<STR_LIT>' <EOL> bdm_root_size = image . block_device_mapping . get ( image . root_device_name ) . size <EOL> bdm_emptyvol_size = <NUM_LIT:1> <EOL> bdm_snap_size = self . base_test_snapshot . volume_size + <NUM_LIT:1> <EOL> self . status ( '<STR_LIT>' + str ( self . test_image1 . id ) + "<STR_LIT>" ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( image . block_device_mapping ) <EOL> bdm = self . add_block_device_types_to_mapping ( snapshot_id = self . base_test_snapshot . id , <EOL> device_name = bdm_snapshot_dev , <EOL> size = bdm_snap_size , <EOL> delete_on_terminate = True ) <EOL> eph_dev = BlockDeviceType ( ) <EOL> eph_dev . device_name = bdm_ephemeral_dev <EOL> eph_dev . ephemeral_name = bdm_ephemeral_name <EOL> bdm [ bdm_ephemeral_dev ] = eph_dev <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( bdm ) <EOL> instance = self . tester . run_image ( image = image , block_device_map = bdm , keypair = self . keypair , group = self . group ) [ <NUM_LIT:0> ] <EOL> try : <EOL> self . current_test_instance = instance <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( instance . block_device_mapping ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . get_ephemeral_dev ( ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_root_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . build_image_snapshot . eutest_volume_md5 , <EOL> md5len = self . build_image_snapshot . eutest_volume_md5len , <EOL> map_device = instance . root_device_name ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_root_size = instance . get_blockdev_size_in_bytes ( guest_root_dev ) / self . gig <EOL> if guest_root_size != bdm_root_size : <EOL> raise Exception ( '<STR_LIT>' + str ( guest_root_size ) + '<STR_LIT>' + str ( bdm_root_size ) + <EOL> '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_snap_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . base_test_snapshot . eutest_volume_md5 , <EOL> md5len = self . base_test_snapshot . eutest_volume_md5len , <EOL> map_device = bdm_snapshot_dev ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_snapvol_size = instance . get_blockdev_size_in_bytes ( guest_snap_dev ) / self . gig <EOL> if guest_snapvol_size != bdm_snap_size : <EOL> raise Exception ( '<STR_LIT>' + str ( guest_snapvol_size ) + '<STR_LIT>' + str ( bdm_snap_size ) + <EOL> '<STR_LIT>' + str ( self . base_test_snapshot . id ) ) <EOL> meta_bdm = instance . block_device_mapping <EOL> if not meta_bdm . has_key ( bdm_ephemeral_dev ) : <EOL> self . resulterr ( '<STR_LIT>' ) <EOL> meta_bdm [ bdm_ephemeral_dev ] = eph_dev <EOL> new_vol = self . tester . create_volume ( zone = self . zone , size = <NUM_LIT:1> , timepergig = <NUM_LIT> ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . attach_euvolume ( new_vol , timeout = <NUM_LIT> , overwrite = False ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . update ( ) <EOL> self . tester . show_block_device_map ( instance . block_device_mapping ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . detach_euvolume ( new_vol ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . update ( ) <EOL> self . tester . show_block_device_map ( instance . block_device_mapping ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . attach_euvolume ( new_vol , timeout = <NUM_LIT> , overwrite = True ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . update ( ) <EOL> self . tester . show_block_device_map ( instance . block_device_mapping ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . check_instance_meta_data_for_block_device_mapping ( root_dev = image . root_device_name , bdm = meta_bdm ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . stop_instance_and_verify ( ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . start_instance_and_verify ( checkvolstatus = True ) <EOL> self . status ( '<STR_LIT>' ) <EOL> except Exception , e : <EOL> tb = self . tester . get_traceback ( ) <EOL> errmsg = str ( tb ) + '<STR_LIT>' + str ( e ) <EOL> self . endfailure ( errmsg ) <EOL> finally : <EOL> instance . terminate_and_verify ( ) <EOL> if errmsg : <EOL> raise Exception ( errmsg ) <EOL> def misc_test1_exceed_max_vol_size_storage_property_per_block_dev_map ( self ) : <EOL> '''<STR_LIT>''' <EOL> errmsg = "<STR_LIT>" <EOL> bdm_snapshot_dev = '<STR_LIT>' <EOL> bdm_snap_size = <NUM_LIT:6> <EOL> maxprop = self . tester . property_manager . get_euproperty_by_name ( '<STR_LIT>' ) <EOL> orig_maxsize = maxprop . value <EOL> try : <EOL> maxprop . set ( <NUM_LIT:1> ) <EOL> image = self . test_image1 <EOL> self . status ( '<STR_LIT>' + str ( self . test_image1 . id ) + "<STR_LIT>" ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( image . block_device_mapping ) <EOL> bdm = self . add_block_device_types_to_mapping ( snapshot_id = self . base_test_snapshot . id , <EOL> device_name = bdm_snapshot_dev , <EOL> size = bdm_snap_size , <EOL> delete_on_terminate = True ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( bdm ) <EOL> try : <EOL> instance = self . tester . run_image ( image = image , block_device_map = bdm , keypair = self . keypair , group = self . group ) [ <NUM_LIT:0> ] <EOL> self . current_test_instance = instance <EOL> except : <EOL> self . status ( '<STR_LIT>' ) <EOL> else : <EOL> try : <EOL> instance . terminate_and_verify ( ) <EOL> except : pass <EOL> raise Exception ( '<STR_LIT>' ) <EOL> except Exception , e : <EOL> tb = self . tester . get_traceback ( ) <EOL> errmsg = str ( tb ) + '<STR_LIT>' + str ( e ) <EOL> self . endfailure ( errmsg ) <EOL> finally : <EOL> maxprop . set ( orig_maxsize ) <EOL> if errmsg : <EOL> raise Exception ( errmsg ) <EOL> def misc_test2_exceed_max_total_storage_property_per_block_dev_map ( self ) : <EOL> '''<STR_LIT>''' <EOL> errmsg = "<STR_LIT>" <EOL> bdm_snapshot_dev = '<STR_LIT>' <EOL> bdm_snap_size = <NUM_LIT:6> <EOL> maxtotal_prop = self . tester . property_manager . get_euproperty_by_name ( '<STR_LIT>' ) <EOL> orig_maxtotal = maxtotal_prop . value <EOL> try : <EOL> maxtotal_prop . set ( <NUM_LIT:5> ) <EOL> image = self . test_image1 <EOL> self . status ( '<STR_LIT>' + str ( self . test_image1 . id ) + "<STR_LIT>" ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( image . block_device_mapping ) <EOL> bdm = self . add_block_device_types_to_mapping ( snapshot_id = self . base_test_snapshot . id , <EOL> device_name = bdm_snapshot_dev , <EOL> size = bdm_snap_size , <EOL> delete_on_terminate = True ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( bdm ) <EOL> try : <EOL> instance = self . tester . run_image ( image = image , block_device_map = bdm , keypair = self . keypair , group = self . group ) [ <NUM_LIT:0> ] <EOL> self . current_test_instance = instance <EOL> except : <EOL> self . status ( '<STR_LIT>' ) <EOL> else : <EOL> try : <EOL> instance . terminate_and_verify ( ) <EOL> except : pass <EOL> raise Exception ( '<STR_LIT>' ) <EOL> except Exception , e : <EOL> tb = self . tester . get_traceback ( ) <EOL> errmsg = str ( tb ) + '<STR_LIT>' + str ( e ) <EOL> self . endfailure ( errmsg ) <EOL> finally : <EOL> maxtotal_prop . set ( orig_maxtotal ) <EOL> if errmsg : <EOL> raise Exception ( errmsg ) <EOL> def misc_test3_run_image1_check_attached_volume_states_during_stop_start ( self , can_detach_block_dev_map = False ) : <EOL> '''<STR_LIT>''' <EOL> errmsg = "<STR_LIT>" <EOL> image = self . test_image1 <EOL> bdm_snapshot_dev = '<STR_LIT>' <EOL> bdm_snap_size = self . base_test_snapshot . volume_size <EOL> bdm_root_size = image . block_device_mapping . get ( image . root_device_name ) . size <EOL> try : <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( image . block_device_mapping ) <EOL> bdm = self . add_block_device_types_to_mapping ( snapshot_id = self . base_test_snapshot . id , <EOL> device_name = bdm_snapshot_dev , <EOL> size = bdm_snap_size , <EOL> delete_on_terminate = True ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( bdm ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance = self . tester . run_image ( image = image , <EOL> block_device_map = bdm , <EOL> keypair = self . keypair , <EOL> password = self . instance_password , <EOL> group = self . group ) [ <NUM_LIT:0> ] <EOL> self . current_test_instance = instance <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( instance . block_device_mapping ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_root_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . build_image_snapshot . eutest_volume_md5 , <EOL> md5len = self . build_image_snapshot . eutest_volume_md5len , <EOL> map_device = instance . root_device_name ) <EOL> self . status ( '<STR_LIT>' ) <EOL> root_dev_size = instance . get_blockdev_size_in_bytes ( guest_root_dev ) / self . gig <EOL> if root_dev_size != bdm_root_size : <EOL> raise Exception ( '<STR_LIT>' + str ( root_dev_size ) + <EOL> '<STR_LIT>' + str ( bdm_root_size ) + <EOL> "<STR_LIT>" + str ( bdm_root_size ) ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_snap_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . base_test_snapshot . eutest_volume_md5 , <EOL> md5len = self . base_test_snapshot . eutest_volume_md5len , <EOL> map_device = bdm_snapshot_dev ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_snapvol_size = instance . get_blockdev_size_in_bytes ( guest_snap_dev ) / self . gig <EOL> if guest_snapvol_size != bdm_snap_size : <EOL> raise Exception ( '<STR_LIT>' + str ( guest_snapvol_size ) + '<STR_LIT>' + str ( bdm_snap_size ) + <EOL> '<STR_LIT>' + str ( self . base_test_snapshot . id ) ) <EOL> meta_bdm = instance . block_device_mapping <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . attach_euvolume ( self . base_test_volume , timeout = <NUM_LIT> , overwrite = False ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . update ( ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . check_instance_meta_data_for_block_device_mapping ( root_dev = image . root_device_name , bdm = meta_bdm ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . stop_instance_and_verify ( ) <EOL> self . status ( '<STR_LIT>' ) <EOL> start = time . time ( ) <EOL> elapsed = <NUM_LIT:0> <EOL> errmsg = '<STR_LIT>' <EOL> while elapsed < <NUM_LIT> : <EOL> elapsed = int ( time . time ( ) - start ) <EOL> for vol in instance . attached_vols : <EOL> vol . update ( ) <EOL> if vol . status != '<STR_LIT>' : <EOL> err = str ( vol . id ) + "<STR_LIT>" + str ( instance . id ) + '<STR_LIT>' + str ( elapsed ) + "<STR_LIT:\n>" <EOL> self . debug ( err ) <EOL> errmsg += err <EOL> if instance . state != '<STR_LIT>' : <EOL> err = str ( instance . id ) + "<STR_LIT>" + str ( instance . state ) + "<STR_LIT>" + str ( elapsed ) + "<STR_LIT:\n>" <EOL> self . debug ( err ) <EOL> errmsg += err <EOL> self . tester . show_volumes ( instance . attached_vols ) <EOL> time . sleep ( <NUM_LIT:10> ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . detach_euvolume ( self . base_test_volume , timeout = <NUM_LIT> ) <EOL> try : <EOL> self . status ( '<STR_LIT>' ) <EOL> except Exception , e : <EOL> err = ( '<STR_LIT>' + str ( self . base_test_volume . id ) <EOL> + "<STR_LIT>" + str ( instance . id ) + "<STR_LIT>" + str ( e ) ) + '<STR_LIT:\n>' <EOL> if can_detach_block_dev_map : <EOL> errmsg += err <EOL> else : <EOL> self . debug ( '<STR_LIT>' + err + "<STR_LIT:\n>" + <EOL> '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . start_instance_and_verify ( checkvolstatus = True ) <EOL> self . status ( '<STR_LIT>' ) <EOL> except Exception , e : <EOL> tb = self . tester . get_traceback ( ) <EOL> errmsg = str ( tb ) + '<STR_LIT>' + str ( e ) <EOL> self . endfailure ( errmsg ) <EOL> finally : <EOL> instance . terminate_and_verify ( ) <EOL> if errmsg : <EOL> raise Exception ( errmsg ) <EOL> def misc_test4_run_image1_terminate_during_stopped_verify_volume_dot ( self ) : <EOL> '''<STR_LIT>''' <EOL> self . status ( '<STR_LIT>' ) <EOL> image = self . test_image1 <EOL> bdm_snapshot_dev = '<STR_LIT>' <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( image . block_device_mapping ) <EOL> bdm = self . add_block_device_types_to_mapping ( snapshot_id = self . base_test_snapshot . id , <EOL> device_name = bdm_snapshot_dev , <EOL> delete_on_terminate = False ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( bdm ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance = self . tester . run_image ( image = image , block_device_map = bdm , keypair = self . keypair , group = self . group ) [ <NUM_LIT:0> ] <EOL> self . current_test_instance = instance <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_snap_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . base_test_snapshot . eutest_volume_md5 , <EOL> md5len = self . base_test_snapshot . eutest_volume_md5len , <EOL> map_device = bdm_snapshot_dev ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . stop_instance_and_verify ( ) <EOL> self . status ( '<STR_LIT>' + <EOL> str ( bdm_snapshot_dev ) ) <EOL> instance . terminate_and_verify ( ) <EOL> def misc_test5_run_image1_with_multiple_bdm_terminate_in_stopped_state ( self , can_detach_block_dev_map = False ) : <EOL> '''<STR_LIT>''' <EOL> errmsg = "<STR_LIT>" <EOL> image = self . test_image1 <EOL> bdm_snapshot_dev = '<STR_LIT>' <EOL> bdm_snap_size = self . base_test_snapshot . volume_size <EOL> bdm_root_size = image . block_device_mapping . get ( image . root_device_name ) . size <EOL> try : <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( image . block_device_mapping ) <EOL> bdm = self . add_block_device_types_to_mapping ( snapshot_id = self . base_test_snapshot . id , <EOL> device_name = bdm_snapshot_dev , <EOL> size = bdm_snap_size , <EOL> delete_on_terminate = True ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( bdm ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance = self . tester . run_image ( image = image , <EOL> block_device_map = bdm , <EOL> keypair = self . keypair , <EOL> password = self . instance_password , <EOL> group = self . group ) [ <NUM_LIT:0> ] <EOL> self . current_test_instance = instance <EOL> self . status ( '<STR_LIT>' ) <EOL> self . tester . show_block_device_map ( instance . block_device_mapping ) <EOL> self . status ( '<STR_LIT>' ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_root_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . build_image_snapshot . eutest_volume_md5 , <EOL> md5len = self . build_image_snapshot . eutest_volume_md5len , <EOL> map_device = instance . root_device_name ) <EOL> self . status ( '<STR_LIT>' ) <EOL> root_dev_size = instance . get_blockdev_size_in_bytes ( guest_root_dev ) / self . gig <EOL> if root_dev_size != bdm_root_size : <EOL> raise Exception ( '<STR_LIT>' + str ( root_dev_size ) + <EOL> '<STR_LIT>' + str ( bdm_root_size ) + <EOL> "<STR_LIT>" + str ( bdm_root_size ) ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_snap_dev = instance . get_guest_dev_for_block_device_map_device ( md5 = self . base_test_snapshot . eutest_volume_md5 , <EOL> md5len = self . base_test_snapshot . eutest_volume_md5len , <EOL> map_device = bdm_snapshot_dev ) <EOL> self . status ( '<STR_LIT>' ) <EOL> guest_snapvol_size = instance . get_blockdev_size_in_bytes ( guest_snap_dev ) / self . gig <EOL> if guest_snapvol_size != bdm_snap_size : <EOL> raise Exception ( '<STR_LIT>' + str ( guest_snapvol_size ) + '<STR_LIT>' + str ( bdm_snap_size ) + <EOL> '<STR_LIT>' + str ( self . base_test_snapshot . id ) ) <EOL> meta_bdm = instance . block_device_mapping <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . attach_euvolume ( self . base_test_volume , timeout = <NUM_LIT> , overwrite = False ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . update ( ) <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . check_instance_meta_data_for_block_device_mapping ( root_dev = image . root_device_name , bdm = meta_bdm ) <EOL> self . status ( '<STR_LIT>' + str ( instance . id ) ) <EOL> instance . stop_instance_and_verify ( ) <EOL> self . status ( '<STR_LIT>' ) <EOL> start = time . time ( ) <EOL> elapsed = <NUM_LIT:0> <EOL> errmsg = '<STR_LIT>' <EOL> except Exception , e : <EOL> tb = self . tester . get_traceback ( ) <EOL> errmsg = str ( tb ) + '<STR_LIT>' + str ( e ) <EOL> self . endfailure ( errmsg ) <EOL> finally : <EOL> try : <EOL> self . status ( '<STR_LIT>' ) <EOL> instance . terminate_and_verify ( ) <EOL> except Exception , tv : <EOL> tb = self . tester . get_traceback ( ) <EOL> errmsg = errmsg + "<STR_LIT:\n>" + str ( tb ) + "<STR_LIT>" + str ( tv ) <EOL> if errmsg : <EOL> raise Exception ( errmsg ) <EOL> def find_remaining_devices ( self , instance , known_dev_list ) : <EOL> self . debug ( '<STR_LIT>' + str ( '<STR_LIT:U+002C>' ) . join ( known_dev_list ) ) <EOL> dev_dir = instance . get_dev_dir ( ) <EOL> remove_devs = [ ] <EOL> for dev in dev_dir : <EOL> dev_string = '<STR_LIT>' + str ( dev ) . replace ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> for known_dev in known_dev_list : <EOL> if dev_string . startswith ( known_dev ) : <EOL> self . debug ( str ( dev ) + '<STR_LIT>' + str ( dev_string ) + '<STR_LIT>' ) <EOL> if not dev in remove_devs : <EOL> remove_devs . append ( dev ) <EOL> continue <EOL> for dev in remove_devs : <EOL> self . debug ( '<STR_LIT>' + str ( dev ) ) <EOL> dev_dir . remove ( dev ) <EOL> self . debug ( '<STR_LIT>' + str ( '<STR_LIT:U+002C>' ) . join ( dev_dir ) ) <EOL> return dev_dir <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> testcase = Block_Device_Mapping_Tests ( ) <EOL> if testcase . args . tests : <EOL> list = testcase . args . tests . splitlines ( '<STR_LIT:U+002C>' ) <EOL> else : <EOL> if testcase . args . use_previous : <EOL> list = [ '<STR_LIT>' ] <EOL> else : <EOL> if not testcase . args . url : <EOL> print '<STR_LIT>' <EOL> testcase . parser . print_help ( ) <EOL> exit ( <NUM_LIT:1> ) <EOL> list = [ '<STR_LIT>' ] <EOL> list . extend ( [ '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<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 , eof = False , clean_on_exit = True ) <EOL> exit ( result ) </s>
