Project

General

Profile

Feature #865

create method for updating multiple hosts via name instead of id

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

Status:
Closed
Priority:
Normal
Assignee:
Category:
API
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
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

Associated revisions

Revision 2b0af5e7 (diff)
Added by Ohad Levy over 9 years ago

Fixes #865 - adds support for api to select multiple hosts via name and id

Signed-off-by: Corey Osman <>
Signed-off-by: Ohad Levy <>

History

#1 Updated by Corey Osman over 9 years ago

  • Assignee set to Corey Osman

#2 Updated by Ohad Levy over 9 years ago

  • Status changed from New to Ready For Testing
  • % Done changed from 0 to 100

#3 Updated by Ohad Levy over 9 years ago

  • Category set to API
  • Status changed from Ready For Testing to Closed
  • Target version set to 0.3

Also available in: Atom PDF