Project

General

Profile

Actions

Feature #353

closed

YAML output for hosts page

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

Status:
Closed
Priority:
Normal
Category:
API
Target version:
Difficulty:
Triaged:
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.


Files


Related issues 1 (0 open1 closed)

Related to Foreman - Refactor #288: move dashboard controller actions (besides index) to hosts controllerClosedOhad Levy05/29/2010Actions
Actions #1

Updated by Ohad Levy over 14 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.

Actions #2

Updated by Jochen Schalanda about 14 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.

Actions #3

Updated by Jochen Schalanda about 14 years ago

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

Updated by Ohad Levy about 14 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
Actions

Also available in: Atom PDF