Project

General

Profile

« Previous | Next » 

Revision b09b4515

Added by Ohad Levy about 14 years ago

  • ID b09b451583194c3bae7cafc2b5331f1319c4681a
Fixes #193 - move hosts controller away from AS
  • Remove active scaffold from hosts controller.
  • changed default host graphs from one day for up to one week
  • added dynamic dropdown boxes for host creation / edit page (e.g. for puppet classes, operating systems etc).
  • converted puppet class selection to a template, using it in hostgroups and hosts edit page.
  • Renamed puppetgroups to hostgroups for consistency
  • Added search option to list, this include search by facts as well

View differences:

app/models/host.rb
belongs_to :hostgroup
has_many :reports, :dependent => :destroy
has_many :host_parameters, :dependent => :destroy
accepts_nested_attributes_for :host_parameters, :reject_if => lambda { |a| a[:value].blank? }, :allow_destroy => true
named_scope :recent, lambda { |*args| {:conditions => ["last_report > ?", (args.first || (SETTINGS[:run_interval] + 5.minutes).ago)]} }
named_scope :out_of_sync, lambda { |*args| {:conditions => ["last_report < ?", (args.first || (SETTINGS[:run_interval] + 5.minutes).ago)]} }
......
# returns the list of puppetclasses a host is in.
def puppetclasses_names
if hostgroup.nil?
return puppetclasses.collect {|c| c.name}
else
return (hostgroup.puppetclasses.collect {|c| c.name} + puppetclasses.collect {|c| c.name}).uniq
end
return all_puppetclasses.collect {|c| c.name}
end
def all_puppetclasses
return hostgroup.nil? ? puppetclasses : (hostgroup.puppetclasses + puppetclasses).uniq
end
# provide information about each node, mainly used for puppet external nodes
# TODO: remove hard coded default parameters into some selectable values in the database.
......
param = {}
# maybe these should be moved to the common parameters, leaving them in for now
param["puppetmaster"] = puppetmaster
param["domainname"] = domain.fullname unless domain.fullname.empty?
param["domainname"] = domain.fullname unless domain.nil? or domain.fullname.nil?
param.update self.params
return Hash['classes' => self.puppetclasses_names, 'parameters' => param, 'environment' => environment.to_s]
end
......
# read common parameters
CommonParameter.find_each {|p| parameters.update Hash[p.name => p.value] }
# read domain parameters
domain.domain_parameters.each {|p| parameters.update Hash[p.name => p.value] }
domain.domain_parameters.each {|p| parameters.update Hash[p.name => p.value] } unless domain.nil?
# read group parameters only if a host belongs to a group
hostgroup.group_parameters.each {|p| parameters.update Hash[p.name => p.value] } unless hostgroup.nil?
# and now read host parameters, override if required

Also available in: Unified diff