Project

General

Profile

« Previous | Next » 

Revision 83683ed0

Added by Tomer Brisker over 9 years ago

Fixes #844 #5725 - correct hosts count in puppetclass

View differences:

app/models/host/managed.rb
class Host::Managed < Host::Base
include ReportCommon
include Hostext::Search
PROVISION_METHODS = %w[build image]
has_many :host_classes, :dependent => :destroy, :foreign_key => :host_id
has_many :puppetclasses, :through => :host_classes
has_many :host_classes, :foreign_key => :host_id
has_many :puppetclasses, :through => :host_classes, :dependent => :destroy
belongs_to :hostgroup
has_many :reports, :dependent => :destroy, :foreign_key => :host_id
has_many :host_parameters, :dependent => :destroy, :foreign_key => :reference_id, :inverse_of => :host
......
# Custom hooks will be executed after_commit
after_commit :build_hooks
before_save :clear_data_on_build
after_save :update_hostgroups_puppetclasses, :if => :hostgroup_id_changed?
def build_hooks
return unless respond_to?(:old) && old && (build? != old.build?)
......
LookupValue.where(:match => "fqdn=#{fqdn_was}").update_all(:match => lookup_value_match)
end
def update_hostgroups_puppetclasses
Hostgroup.find(hostgroup_id_was).update_puppetclasses_total_hosts if hostgroup_id_was.present?
Hostgroup.find(hostgroup_id).update_puppetclasses_total_hosts if hostgroup_id.present?
end
end

Also available in: Unified diff