def detach_destroy_volumes(api):
 volumes = api.list_volumes()
 retry = 0
 action_type = u'agent:blockdevice:cleanup:details'
 with start_action(action_type=action_type):
  while ((retry < CLEANUP_RETRY_LIMIT) and (len(volumes) > 0)):
   for volume in volumes:
    try:
     if (volume.attached_to is not None):
      api.detach_volume(volume.blockdevice_id)
     api.destroy_volume(volume.blockdevice_id)
    except:
     write_traceback(_logger)
   time.sleep(1.0)
   volumes = api.list_volumes()
   retry += 1
  if (len(volumes) > 0):
   Message.new(u'agent:blockdevice:failedcleanup:volumes', volumes=volumes).write()

def detach_destroy_volumes ( api ) : volumes = api . list_volumes ( ) retry = 0 action_type = u'agent:blockdevice:cleanup:details' with start_action ( action_type = action_type ) : while ( ( retry < CLEANUP_RETRY_LIMIT ) and ( len ( volumes ) > 0 ) ) : for volume in volumes : try : if ( volume . attached_to is not None ) : api . detach_volume ( volume . blockdevice_id ) api . destroy_volume ( volume . blockdevice_id ) except : write_traceback ( _logger ) time . sleep ( 1.0 ) volumes = api . list_volumes ( ) retry += 1 if ( len ( volumes ) > 0 ) : Message . new ( u'agent:blockdevice:failedcleanup:volumes' , volumes = volumes ) . write ( )
detach and destroy all volumes known to this api .