app/controllers/application_controller.rb
# moved this method here so it can be accessed from pxe_server controller as well
moved this method here so it can be accessed from pxe_server controller as well
moved this method here so it can be accessed from pxe_server controller as well
def log_depot_validate 
    @schedule = nil 
    if x_active_tree == :diagnostics_tree
      if @sb[:active_tab] == "diagnostics_database"
        pfx = "dbbackup"
        flash_div_num = "database"
      end
    else
      if session[:edit] && session[:edit].key?(:pxe_id)
        pfx = "pxe"
        flash_div_num = ""
      else
        pfx = "schedule"
        flash_div_num = ""
      end
    end
    id = params[:id] ? params[:id] : "new"
    if pfx == "pxe"
      return unless load_edit("#{pfx}_edit__#{id}")
      settings = {:username => @edit[:new][:log_userid], :password => @edit[:new][:log_password]}
      settings[:uri] = @edit[:new][:uri_prefix] + "://" + @edit[:new][:uri]
    else
      settings = {:username => params[:log_userid], :password => params[:log_password]}
      settings[:uri] = "#{params[:uri_prefix]}://#{params[:uri]}"
      settings[:uri_prefix] = params[:uri_prefix]
    end
    begin
      if pfx == "pxe"
        msg = _('PXE Credentials successfuly validated')
        PxeServer.verify_depot_settings(settings)
      else
        msg = _('Depot Settings successfuly validated')
        MiqSchedule.new.verify_file_depot(settings)
      end
    rescue StandardError => bang
      add_flash(_("Error during 'Validate': %{error_message}") % {:error_message => bang.message}, :error)
    else
      add_flash(msg)
    end
    @changed = (@edit[:new] != @edit[:current]) if pfx == "pxe"
    render :update do |page|
      page.replace("flash_msg_div#{flash_div_num}", :partial => "layouts/flash_msg", :locals => {:div_num => flash_div_num})
    end
  end
def log_depot_validate @schedule = nil if x_active_tree == :diagnostics_tree if @sb [ :active_tab ] == "diagnostics_database" pfx = "dbbackup" flash_div_num = "database" end else if session [ :edit ] && session [ :edit ] . key? ( :pxe_id ) pfx = "pxe" flash_div_num = "" else pfx = "schedule" flash_div_num = "" end end id = params [ :id ] ? params [ :id ] : "new" if pfx == "pxe" return unless load_edit ( "#{pfx}_edit__#{id}" ) settings = { :username => @edit [ :new ] [ :log_userid ] , :password => @edit [ :new ] [ :log_password ] } settings [ :uri ] = @edit [ :new ] [ :uri_prefix ] + "://" + @edit [ :new ] [ :uri ] else settings = { :username => params [ :log_userid ] , :password => params [ :log_password ] } settings [ :uri ] = "#{params[:uri_prefix]}://#{params[:uri]}" settings [ :uri_prefix ] = params [ :uri_prefix ] end begin if pfx == "pxe" msg = _ ( 'PXE Credentials successfuly validated' ) PxeServer . verify_depot_settings ( settings ) else msg = _ ( 'Depot Settings successfuly validated' ) MiqSchedule . new . verify_file_depot ( settings ) end rescue StandardError => bang add_flash ( _ ( "Error during 'Validate': %{error_message}" ) % { :error_message => bang . message } , :error ) else add_flash ( msg ) end @changed = ( @edit [ :new ] != @edit [ :current ] ) if pfx == "pxe" render :update do | page | page . replace ( "flash_msg_div#{flash_div_num}" , :partial => "layouts/flash_msg" , :locals => { :div_num => flash_div_num } ) end end
moved this method here so it can be accessed from pxe_server controller as well
moved this method here so it can be accessed from pxe_server controller as well
# this is a terrible name, it doesn't validate log_depots # setting to nil, since we are using same view for both db_back and log_depot edit # if zone is selected in tree replace tab#3 # coming from diagnostics/database tab # add/edit pxe server # add/edit dbbackup schedule