Project

General

Profile

Feature #353

YAML output for hosts page

Added by Bash Shell over 8 years ago. Updated about 8 years ago.

Status:
Closed
Priority:
Normal
Category:
API
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

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.


Related issues

Related to Foreman - Refactor #288: move dashboard controller actions (besides index) to hosts controllerClosed2010-05-29

Associated revisions

Revision a90a43fa (diff)
Added by Jochen Schalanda about 8 years ago

Fixes #353 - Added responder for YAML output in HostsController#index

History

#1 Updated by Ohad Levy over 8 years ago

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.

#2 Updated by Jochen Schalanda about 8 years ago

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.

#3 Updated by Jochen Schalanda about 8 years ago

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

#4 Updated by Ohad Levy about 8 years ago

  • 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