Project

General

Profile

Feature #259

Ability to search Hosts by Parameters

Added by Bash Shell over 10 years ago. Updated over 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Web Interface
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Fixed in Releases:
Found in Releases:

Description

It would be useful to add a Search by Parameter field to the search bar

Adding these two lines in _searchbar.erb seems to do it:

diff --git a/app/views/common/_searchbar.erb b/app/views/common/_searchbar.erb
index 91abe8b..c9adc52 100644
--- a/app/views/common/_searchbar.erb
+++ b/app/views/common/_searchbar.erb
@@ -20,6 +20,8 @@
           </span>
           <%= f.label :hostgroup, "Role" %>
           <%= f.collection_select :hostgroup_id_eq, Hostgroup.all, :id, :name, :include_blank => true %>
+          <%= f.label :parameter, "Parameter" %>
+          <%= f.text_field :host_parameters_name_like, :size => 10 %>
           <%= render :partial => 'common/fact_selected' %>
           <%= f.submit "Go" %> Save as tab: <%= text_field_tag :tab_name, "" %>
         <% end %>

This is useful as assigning parameters to individual hosts creates "drift" and there should be a way to search for such Parameters.


Related issues

Related to Foreman - Refactor #250: Remove activescaffold from the domain parameters pageClosed2010-05-13
Follows Foreman - Feature #248: Generalise the searchbar and tabs to support multiple controllersClosed2010-05-13
Follows Foreman - Feature #719: Add new search functionailyClosed2011-03-09

Associated revisions

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

fixes #259 - Ability to search Hosts by Parameters

History

#1 Updated by Bash Shell over 10 years ago

Or this:

diff --git a/app/views/common/_searchbar.erb b/app/views/common/_searchbar.erb
index 91abe8b..2534123 100644
--- a/app/views/common/_searchbar.erb
+++ b/app/views/common/_searchbar.erb
@@ -20,6 +20,8 @@
           </span>
           <%= f.label :hostgroup, "Role" %>
           <%= f.collection_select :hostgroup_id_eq, Hostgroup.all, :id, :name, :include_blank => true %>
+          <%= f.label :parameter, "Parameter" %>
+          <%= f.collection_select :host_parameters_name_like, Parameter.find(:all, :select => "DISTINCT name", :order => "name", :conditions => ['type="HostParameter"']), :name, :name, :include_blank => true %>
           <%= render :partial => 'common/fact_selected' %>
           <%= f.submit "Go" %> Save as tab: <%= text_field_tag :tab_name, "" %>
         <% end %>

This works too, but how can I improve?

#2 Updated by Ohad Levy over 10 years ago

@Paul, do you want to generalize your domain parameters to any type of parameters?
as we are limited with screen size (but have many options for searching) maybe we need to break down more search options, like two select drop boxes (like with facts).

#3 Updated by Ohad Levy over 10 years ago

  • Category set to Web Interface
  • Target version set to 0.1-6

#4 Updated by Paul Kelly about 10 years ago

  • Status changed from New to Pending
  • Assignee set to Paul Kelly
  • Branch set to feature/259-search-hosts-by-parameters

Wow have I had some problems with this one! I have generalized the GUI components that show habtm relationships, such as facts, so that they can be added simply to search lines but there is a real problem with the host_parameters single-line selector.
There appears to be a bug in searchlogic, even in v2.4.26, where
Host.search("host_parameters_name_eq"=>"hostmode", "host_parameters_value_eq"=>"development").all.count
produces an SQL error. Just try it in the console. Ohad, maybe you can see something wrong with the declaration of the associations? I have posted a error report on the searchlogic site and am awaiting a reply.

#5 Updated by Paul Kelly about 10 years ago

  • Status changed from Pending to Ready For Testing

The solution provided uses a workaround that ensures that a parameter based search is not combined with other searches from the search line as this leads to SQL errors. This may or may not be acceptable Ohad, you will have to decide.

#6 Updated by Ohad Levy about 10 years ago

Paul, can you please rebase again ?

#7 Updated by Paul Kelly about 10 years ago

  • Branch changed from feature/259-search-hosts-by-parameters to feature/259-search-hosts-by-parameters-2

rebased and tested
Note the branch name change

#8 Updated by Ohad Levy about 10 years ago

  • Target version changed from 0.1-6 to 0.2

while the patch does a pertty good job, I wont feel we should merge it just yet, pushing to the next version.

#9 Updated by Ohad Levy almost 10 years ago

paul, any chance you can rebase this one? if not, please unassign the target version

#10 Updated by Paul Kelly almost 10 years ago

  • Status changed from Ready For Testing to Pending
  • Target version deleted (0.2)

Rebasing this one is a nightmare. It will rewrite it sometime.

#11 Updated by Ohad Levy over 9 years ago

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

#12 Updated by Ohad Levy over 9 years ago

  • Assignee changed from Paul Kelly to Amos Benari
  • Target version set to 0.3

#13 Updated by Ohad Levy over 9 years ago

  • Status changed from Ready For Testing to Closed

Also available in: Atom PDF