Project

General

Profile

Actions

Feature #865

closed

create method for updating multiple hosts via name instead of id

Added by Corey Osman over 13 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

I need a method to update multiple hosts via a name. I altered some code but I don't understand how the find function works with the params.

Need some clarification on whats going on with the following line of code.

   @hosts = Host.find(params[:host_names], :order => "hostgroup_id ASC")

Here is what I put together as a future patch for this feature.


def find_multiple
    if not params[:host_ids].blank?
      @hosts = Host.find(params[:host_ids], :order => "hostgroup_id ASC")
    elsif not params[:host_names].blank?
      @hosts = Host.find(params[:host_names], :order => "hostgroup_id ASC")
    else
      error 'No Hosts selected'
      redirect_to(hosts_path) and return false
    end
  rescue => e
    error "Something went wrong while selecting hosts - #{e}" 
    redirect_to hosts_path
  end

Actions

Also available in: Atom PDF