New nailgun hook to sync cobbler
We need this hook to update cobbler config and reload dnsmasq from nailgun. Co-Authored-By: Aleksandr Didenko <adidenko@mirantis.com> Partial-bug: #1495593 Change-Id: Ie2f2d0b81d4134fbf2913558da1d4bea37e3ecbb
This commit is contained in:
parent
7cea69bd02
commit
8c5c4dd8dd
|
@ -34,6 +34,7 @@ module Astute
|
|||
when 'upload_file' then upload_file_hook(hook)
|
||||
when 'puppet' then puppet_hook(hook)
|
||||
when 'reboot' then reboot_hook(hook)
|
||||
when 'cobbler_sync' then cobbler_sync_hook(hook)
|
||||
else raise "Unknown hook type #{hook['type']}"
|
||||
end
|
||||
|
||||
|
@ -200,6 +201,18 @@ module Astute
|
|||
ret
|
||||
end # shell_hook
|
||||
|
||||
def cobbler_sync_hook(hook)
|
||||
validate_presence(hook['parameters'], 'provisioning_info')
|
||||
|
||||
ret = {'error' => nil}
|
||||
cobbler = CobblerManager.new(
|
||||
hook['parameters']['provisioning_info']['engine'],
|
||||
@ctx.reporter
|
||||
)
|
||||
cobbler.sync
|
||||
|
||||
ret
|
||||
end # cobbler_sync_hook
|
||||
|
||||
def sync_hook(hook)
|
||||
validate_presence(hook, 'uids')
|
||||
|
|
|
@ -121,24 +121,44 @@ describe Astute::NailgunHooks do
|
|||
end
|
||||
|
||||
let(:upload_files_hook) do
|
||||
{
|
||||
"priority" => 100,
|
||||
"type" => "upload_files",
|
||||
"fail_on_error" => false,
|
||||
"diagnostic_name" => "copy-example-1.0",
|
||||
"uids" => ['1'],
|
||||
"parameters" => {
|
||||
"nodes" =>[
|
||||
"uid" => '1',
|
||||
"files" => [{
|
||||
"dst" => "/etc/fuel/nova.key",
|
||||
"data" => "",
|
||||
"permissions" => "0600",
|
||||
"dir_permissions" => "0700"}],
|
||||
]
|
||||
{
|
||||
"priority" => 100,
|
||||
"type" => "upload_files",
|
||||
"fail_on_error" => false,
|
||||
"diagnostic_name" => "copy-example-1.0",
|
||||
"uids" => ['1'],
|
||||
"parameters" => {
|
||||
"nodes" =>[
|
||||
"uid" => '1',
|
||||
"files" => [{
|
||||
"dst" => "/etc/fuel/nova.key",
|
||||
"data" => "",
|
||||
"permissions" => "0600",
|
||||
"dir_permissions" => "0700"}],
|
||||
]
|
||||
}
|
||||
}
|
||||
end
|
||||
|
||||
let (:cobbler_sync_hook) do
|
||||
{
|
||||
"priority" => 800,
|
||||
"type" => "cobbler_sync",
|
||||
"fail_on_error" => false,
|
||||
"diagnostic_name" => "copy-example-1.0",
|
||||
"uids" => ['master'],
|
||||
"parameters" => {
|
||||
"provisioning_info" => {
|
||||
"engine" => {
|
||||
"url" => "http://10.20.0.2:80/cobbler_api",
|
||||
"username" => "cobbler",
|
||||
"password" => "cobblerpassword",
|
||||
"master_ip" => "10.20.0.2"
|
||||
}
|
||||
}
|
||||
}
|
||||
end
|
||||
}
|
||||
end
|
||||
|
||||
let(:hooks_data) do
|
||||
[
|
||||
|
@ -1323,4 +1343,22 @@ describe Astute::NailgunHooks do
|
|||
|
||||
end #reboot_hook
|
||||
|
||||
context '#cobbler_sync_hook' do
|
||||
|
||||
it 'should validate presence of provisioning_info' do
|
||||
cobbler_sync_hook['parameters']['provisioning_info'] = {}
|
||||
hooks = Astute::NailgunHooks.new([cobbler_sync_hook], ctx)
|
||||
|
||||
expect {hooks.process}.to raise_error(StandardError, /Missing a required parameter/)
|
||||
end
|
||||
|
||||
it 'should call Astute::CobblerManager sync method ' do
|
||||
hooks = Astute::NailgunHooks.new([cobbler_sync_hook], ctx)
|
||||
Astute::CobblerManager.any_instance.expects(:sync).once
|
||||
|
||||
hooks.process
|
||||
end
|
||||
|
||||
end #cobbler_sync_hook
|
||||
|
||||
end # 'describe'
|
||||
|
|
Loading…
Reference in New Issue