Add default gateway pinger to the netconfig task
Change-Id: Ic2e7616526bb578c65e942b3ceddc91482d83de6 Related-Bug: 1497391
This commit is contained in:
parent
c1900b49e6
commit
dc39130006
@ -0,0 +1,41 @@
|
||||
require 'timeout'
|
||||
|
||||
Puppet::Type.type(:ping_host).provide(:ping_host) do
|
||||
desc 'Ping a host until in becomes online'
|
||||
|
||||
commands :ping => 'ping'
|
||||
|
||||
# check if the host is online
|
||||
# @return [:up,:down]
|
||||
def status
|
||||
begin
|
||||
Timeout::timeout(5) do
|
||||
ping '-q', '-c', '1', '-W', '3', @resource[:name]
|
||||
end
|
||||
rescue Timeout::Error, Puppet::ExecutionFailure
|
||||
return :down
|
||||
end
|
||||
:up
|
||||
end
|
||||
|
||||
# get the host status value
|
||||
# @return [:up, :down]
|
||||
def ensure
|
||||
debug "Call 'ensure' on host '#{@resource[:name]}'"
|
||||
out = status
|
||||
debug "Return: #{out}"
|
||||
out
|
||||
end
|
||||
|
||||
# wait for host status to change into specified value
|
||||
# @param value [:up, :down]
|
||||
def ensure=(value)
|
||||
debug "Waiting for host '#{@resource[:name]}' to change status to '#{value}'"
|
||||
@resource[:count].times do
|
||||
return if status == value
|
||||
sleep @resource[:step]
|
||||
end
|
||||
fail "Timeout waiting for host '#{@resource[:name]}' status to become '#{value}' after #{@resource[:count] * @resource[:step]} seconds!"
|
||||
end
|
||||
|
||||
end
|
33
deployment/puppet/osnailyfacter/lib/puppet/type/ping_host.rb
Normal file
33
deployment/puppet/osnailyfacter/lib/puppet/type/ping_host.rb
Normal file
@ -0,0 +1,33 @@
|
||||
Puppet::Type.newtype(:ping_host) do
|
||||
desc 'Ping a host until in becomes online'
|
||||
|
||||
newparam(:name) do
|
||||
desc 'Hostname or the IP addrress of the host'
|
||||
isnamevar
|
||||
end
|
||||
|
||||
newproperty(:ensure) do
|
||||
desc 'Expected host status'
|
||||
newvalues :up, :down
|
||||
defaultto :up
|
||||
end
|
||||
|
||||
newparam(:count) do
|
||||
desc 'How many times try to perform check?'
|
||||
newvalues(/\d+/)
|
||||
defaultto 10
|
||||
munge do |n|
|
||||
n.to_i
|
||||
end
|
||||
end
|
||||
|
||||
newparam(:step) do
|
||||
desc 'How many seconds to wait between retries?'
|
||||
newvalues(/\d+/)
|
||||
defaultto 6
|
||||
munge do |n|
|
||||
n.to_i
|
||||
end
|
||||
end
|
||||
|
||||
end
|
@ -79,5 +79,16 @@ if !defined(Service['irqbalance']) {
|
||||
exec { 'wait-for-interfaces':
|
||||
path => '/usr/bin:/bin',
|
||||
command => 'sleep 32',
|
||||
require => Class['l23network'],
|
||||
}
|
||||
|
||||
# check that network was configured successfully
|
||||
# and the default gateway is online
|
||||
$default_gateway = hiera('default_gateway')
|
||||
|
||||
ping_host { $default_gateway :
|
||||
ensure => 'up',
|
||||
}
|
||||
|
||||
Class['l23network'] ->
|
||||
Exec['wait-for-interfaces'] ->
|
||||
Ping_host[$default_gateway]
|
||||
|
Loading…
Reference in New Issue
Block a user