Feature #259
closed
Ability to search Hosts by Parameters
Added by Bash Shell over 14 years ago.
Updated over 13 years ago.
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.
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?
@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).
- Category set to Web Interface
- Target version set to 0.1-6
- 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.
- 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.
Paul, can you please rebase again ?
- 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
- 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.
paul, any chance you can rebase this one? if not, please unassign the target version
- Status changed from Ready For Testing to Pending
- Target version deleted (
0.2)
Rebasing this one is a nightmare. It will rewrite it sometime.
- Status changed from Pending to Ready For Testing
- % Done changed from 0 to 100
- Assignee changed from Paul Kelly to Amos Benari
- Target version set to 0.3
- Status changed from Ready For Testing to Closed
Also available in: Atom
PDF