Feature #353
closed
YAML output for hosts page
Added by Bash Shell over 14 years ago.
Updated about 14 years ago.
Description
The index function in the hosts controller could be changed to something like the following:
def index
@search = Host.search(params[:search])
@hosts = @search.paginate :page => params[:page], :include => [:hostgroup, :domain, :operatingsystem, :environment]
@via = "fact_values_"
@last_reports = Report.maximum(:id, :group => :host_id, :conditions => {:host_id => @hosts})
respond_to do |format|
format.html
format.yml { render :text => @search.map(&:name).to_yaml }
end
end
This would output a list of hosts in simple YAML format which can be directly fed to other scripts.
This is similar to what happens in the OutofSync and Error page.
Files
I think it makes more sense to handle this in one common controller (e.g. get out all of the hosts actions out of the dashboard controller, then we can unify them all to provide yaml / json output.
The proposed patch adds a responder for YAML output in HostsController#index
.
It also changes the JSON output to a simple array of the hosts instead of the nested hash with only one key/value-pair and makes it possible to use the search
parameter to narrow down the returned hosts.
- Status changed from New to Ready For Testing
- % Done changed from 0 to 100
- Category set to API
- Status changed from Ready For Testing to Closed
- Assignee set to Jochen Schalanda
- Target version changed from 0.2 to 0.1-6
Also available in: Atom
PDF