app/controllers/application_controller/ci_processing.rb
# Delete all selected or single displayed datastore(s)
Delete all selected or single displayed datastore(s)
Delete all selected or single displayed datastore ( s )
def deletestorages
    assert_privileges("storage_delete")
    datastores = []
    if @lastaction == "show_list" || (@lastaction == "show" && @layout != "storage")  
      datastores = find_checked_items
      if datastores.empty?
        add_flash(_("No %{model} were selected for %{task}") % {:model => ui_lookup(:tables => "storage"), :task => display_name}, :error)
      end
      ds_to_delete = []
      datastores.each do |s|
        ds = Storage.find_by_id(s)
        if ds.vms_and_templates.length <= 0 && ds.hosts.length <= 0
          ds_to_delete.push(s)
        else
          add_flash(_("\"%{datastore_name}\": cannot be removed, has vms or hosts") %
            {:datastore_name => ds.name}, :warning)
        end
      end
      process_storage(ds_to_delete, "destroy")  unless ds_to_delete.empty?
    else 
      if params[:id].nil? || Storage.find_by_id(params[:id]).nil?
        add_flash(_("%{record} no longer exists") % {:record => ui_lookup(:tables => "storage")}, :error)
      else
        datastores.push(params[:id])
      end
      process_storage(datastores, "destroy")  unless datastores.empty?
      @single_delete = true unless flash_errors?
      add_flash(_("The selected %{record} was deleted") %
        {:record => ui_lookup(:table => "storages")}) if @flash_array.nil?
    end
    if @lastaction == "show_list"
      show_list
      @refresh_partial = "layouts/gtl"
    end
  end
def deletestorages assert_privileges ( "storage_delete" ) datastores = [ ] if @lastaction == "show_list" || ( @lastaction == "show" && @layout != "storage" ) datastores = find_checked_items if datastores . empty? add_flash ( _ ( "No %{model} were selected for %{task}" ) % { :model => ui_lookup ( :tables => "storage" ) , :task => display_name } , :error ) end ds_to_delete = [ ] datastores . each do | s | ds = Storage . find_by_id ( s ) if ds . vms_and_templates . length <= 0 && ds . hosts . length <= 0 ds_to_delete . push ( s ) else add_flash ( _ ( "\"%{datastore_name}\": cannot be removed, has vms or hosts" ) % { :datastore_name => ds . name } , :warning ) end end process_storage ( ds_to_delete , "destroy" ) unless ds_to_delete . empty? else if params [ :id ] . nil? || Storage . find_by_id ( params [ :id ] ) . nil? add_flash ( _ ( "%{record} no longer exists" ) % { :record => ui_lookup ( :tables => "storage" ) } , :error ) else datastores . push ( params [ :id ] ) end process_storage ( datastores , "destroy" ) unless datastores . empty? @single_delete = true unless flash_errors? add_flash ( _ ( "The selected %{record} was deleted" ) % { :record => ui_lookup ( :table => "storages" ) } ) if @flash_array . nil? end if @lastaction == "show_list" show_list @refresh_partial = "layouts/gtl" end end
Delete all selected or single displayed datastore(s)
Delete all selected or single displayed datastore ( s )
# showing a list, scan all selected hosts # showing 1 datastore, delete it