#NEWLINE# def terminate_volumes( db , context , instance_id ) : #NEWLINE# #INDENT# 'delete volumes of delete_on_termination=True in block device mapping' #NEWLINE# volume_api = volume . API ( ) #NEWLINE# for bdm in db . block_device_mapping_get_all_by_instance ( context , instance_id ) : #NEWLINE# #INDENT# if ( db [ 'volume_id' ] and bdm [ 'delete_on_termination' ] ) : #NEWLINE# #INDENT# volume_api . delete ( context , bdm [ 'volume_id' ] ) #NEWLINE# #UNINDENT# db . block_device_mapping_destroy ( context , bdm [ 'id' ] )