Revision c6e02bd3
Added by Joseph Magen over 10 years ago
app/models/host/managed.rb | ||
---|---|---|
:if => Proc.new { |host| host.managed and host.disk.empty? and not defined?(Rake) and capabilities.include?(:build) }
|
||
validates :serial, :format => {:with => /[01],\d{3,}n\d/, :message => N_("should follow this format: 0,9600n8")},
|
||
:allow_blank => true, :allow_nil => true
|
||
after_validation :set_compute_attributes
|
||
end
|
||
|
||
|
||
before_validation :set_hostgroup_defaults, :set_ip_address, :normalize_addresses, :normalize_hostname, :force_lookup_value_matcher
|
||
after_validation :ensure_associations, :set_default_user
|
||
before_validation :set_certname, :if => Proc.new {|h| h.managed? and Setting[:use_uuid_for_certificates] } if SETTINGS[:unattended]
|
||
... | ... | |
|
||
def set_hostgroup_defaults
|
||
return unless hostgroup
|
||
assign_hostgroup_attributes(%w{environment domain puppet_proxy puppet_ca_proxy})
|
||
assign_hostgroup_attributes(%w{environment domain puppet_proxy puppet_ca_proxy compute_profile})
|
||
if SETTINGS[:unattended] and (new_record? or managed?)
|
||
assign_hostgroup_attributes(%w{operatingsystem architecture})
|
||
assign_hostgroup_attributes(%w{medium ptable subnet}) if capabilities.include?(:build)
|
||
end
|
||
end
|
||
|
||
def set_compute_attributes
|
||
return unless compute_attributes.empty?
|
||
return unless compute_profile_id && compute_resource_id
|
||
self.compute_attributes = compute_resource.compute_profile_attributes_for(compute_profile_id)
|
||
end
|
||
|
||
def set_ip_address
|
||
self.ip ||= subnet.unused_ip if subnet and SETTINGS[:unattended] and (new_record? or managed?)
|
||
end
|
||
... | ... | |
bmc_proxy.boot({:function => 'bootdevice', :device => booting_device})
|
||
end
|
||
|
||
# take from hostgroup if compute_profile_id is nil
|
||
def compute_profile_id
|
||
read_attribute(:compute_profile_id) || hostgroup.try(:compute_profile_id)
|
||
end
|
||
|
||
private
|
||
|
||
def lookup_value_match
|
Also available in: Unified diff
fixes #3178 - add feature for compute profiles for hostgroups and hosts