Project

General

Profile

« Previous | Next » 

Revision 77f70152

Added by Stephen Benjamin about 10 years ago

fixes #1809 - foreman realm integration

View differences:

app/models/host/managed.rb
allow :name, :diskLayout, :puppetmaster, :puppet_ca_server, :operatingsystem, :os, :environment, :ptable, :hostgroup, :location,
:organization, :url_for_boot, :params, :info, :hostgroup, :compute_resource, :domain, :ip, :mac, :shortname, :architecture,
:model, :certname, :capabilities, :provider, :subnet, :token, :location, :organization, :provision_method,
:image_build?, :pxe_build?
:image_build?, :pxe_build?, :otp
end
attr_reader :cached_host_params
......
include Orchestration::TFTP
include Orchestration::Puppetca
include Orchestration::SSHProvision
include Orchestration::Realm
include HostTemplateHelpers
validates :ip, :uniqueness => true, :if => Proc.new {|host| host.require_ip_validation?}
......
# delete all expired tokens
self.build = false
self.otp = nil
self.installed_at = Time.now.utc if installed
self.save
rescue => e
......
end
# Cleans Certificate and enable Autosign
# Called after a host is given their provisioning template
# Called before a host is given their provisioning template
# Returns : Boolean status of the operation
def handle_ca
# If there's no puppetca, tell the caller that everything is ok
......
setAutosign
end
# Request a new OTP for a host
def handle_realm
return true unless realm?
# If no OTP is set, then this is probably a rebuild
if self.otp.blank?
logger.info "Setting realm for host #{name}"
set_realm :rebuild => true
self.save!
else
true
end
end
# returns the host correct disk layout, custom or common
def diskLayout
@host = self
......
return unless hostgroup
assign_hostgroup_attributes(%w{environment_id domain_id puppet_proxy_id puppet_ca_proxy_id compute_profile_id})
if SETTINGS[:unattended] and (new_record? or managed?)
assign_hostgroup_attributes(%w{operatingsystem_id architecture_id})
assign_hostgroup_attributes(%w{operatingsystem_id architecture_id realm_id})
assign_hostgroup_attributes(%w{medium_id ptable_id subnet_id}) if pxe_build?
end
end
......
ids << d.dns_id
end
[realm, hostgroup.try(:realm)].compact.each do |r|
ids << r.realm_proxy_id
end
[puppet_proxy_id, puppet_ca_proxy_id, hostgroup.try(:puppet_proxy_id), hostgroup.try(:puppet_ca_proxy_id)].compact.each do |p|
ids << p
end

Also available in: Unified diff