Revision f09d61de
Added by Dominic Cleal almost 11 years ago
- ID f09d61de451450a566c7ee16bdf35281e98708c4
app/models/host/managed.rb | ||
---|---|---|
# Called after a host is given their provisioning template
|
||
# Returns : Boolean status of the operation
|
||
def handle_ca
|
||
return true if Rails.env == "test"
|
||
return true unless Setting[:manage_puppetca]
|
||
if puppetca?
|
||
respond_to?(:initialize_puppetca,true) && initialize_puppetca && delCertificate && setAutosign
|
||
end
|
||
return true unless puppetca?
|
||
respond_to?(:initialize_puppetca,true) && initialize_puppetca && delCertificate && setAutosign
|
||
end
|
||
|
||
# returns the host correct disk layout, custom or common
|
test/fixtures/hosts.yml | ||
---|---|---|
subnet: one
|
||
domain: mydomain
|
||
puppet_proxy: puppetmaster
|
||
puppet_ca_proxy: puppetmaster
|
||
managed: true
|
||
compute_resource: one
|
||
|
test/functional/unattended_controller_test.rb | ||
---|---|---|
require 'test_helper'
|
||
|
||
class UnattendedControllerTest < ActionController::TestCase
|
||
setup do
|
||
Host::Managed.any_instance.stubs(:handle_ca).returns(true)
|
||
end
|
||
|
||
test "should get a kickstart" do
|
||
@request.env["HTTP_X_RHN_PROVISIONING_MAC_0"] = "eth0 #{hosts(:redhat).mac}"
|
||
get :kickstart
|
test/unit/host_test.rb | ||
---|---|---|
assert_equal ConfigTemplate.find_by_name("MyFinish"), host.configTemplate({:kind => "finish"})
|
||
end
|
||
|
||
test "when provisioning a new host we should not call puppetca if its disabled" do
|
||
# TODO improve this test :-)
|
||
Setting[:manage_puppetca] = false
|
||
assert hosts(:one).handle_ca
|
||
end
|
||
|
||
test "custom_disk_partition_with_erb" do
|
||
h = hosts(:one)
|
||
h.disk = "<%= 1 + 1 %>"
|
||
assert h.save
|
||
assert h.disk.present?
|
||
assert_equal "2", h.diskLayout
|
||
end
|
||
test "handle_ca must not perform actions when the manage_puppetca setting is false" do
|
||
h = hosts(:one)
|
||
Setting[:manage_puppetca] = false
|
||
h.expects(:initialize_puppetca).never()
|
||
h.expects(:setAutosign).never()
|
||
assert h.handle_ca
|
||
end
|
||
|
||
test "handle_ca must not perform actions when no Puppet CA proxy is associated" do
|
||
h = hosts(:one)
|
||
Setting[:manage_puppetca] = true
|
||
refute h.puppetca?
|
||
h.expects(:initialize_puppetca).never()
|
||
assert h.handle_ca
|
||
end
|
||
|
||
test "handle_ca must call initialize, delete cert and add autosign methods" do
|
||
h = hosts(:dhcp)
|
||
Setting[:manage_puppetca] = true
|
||
assert h.puppetca?
|
||
h.expects(:initialize_puppetca).returns(true)
|
||
h.expects(:delCertificate).returns(true)
|
||
h.expects(:setAutosign).returns(true)
|
||
assert h.handle_ca
|
||
end
|
||
|
||
test "custom_disk_partition_with_erb" do
|
||
h = hosts(:one)
|
||
h.disk = "<%= 1 + 1 %>"
|
||
assert h.save
|
||
assert h.disk.present?
|
||
assert_equal "2", h.diskLayout
|
||
end
|
||
|
||
test "models are updated when host.model has no value" do
|
||
h = hosts(:one)
|
Also available in: Unified diff
fixes #2693 - don't cause handle_ca error when no Puppet CA associated with host