11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/beaker/utils/ntp_control.rb', line 11
def timesync
@logger.notify "Update system time sync"
@logger.notify "run ntpdate against NTP pool systems"
@hosts.each do |host|
success=FALSE
if host['platform'].include? 'solaris-10'
host.exec(Command.new("sleep 10 && ntpdate -w #{NTPSERVER}"))
elsif host['platform'].include? 'windows'
host.exec(Command.new("w32tm /register"), :acceptable_exit_codes => [0,5])
host.exec(Command.new("net start w32time"), :acceptable_exit_codes => [0,2])
host.exec(Command.new("w32tm /config /manualpeerlist:#{NTPSERVER} /syncfromflags:manual /update"))
host.exec(Command.new("w32tm /resync"))
else
count=0
until success do
count+=1
raise "ntp time sync failed after #{count} tries" and break if count > 3
if host.exec(Command.new("ntpdate -t 20 #{NTPSERVER}")).exit_code == 0
success=TRUE
end
end
@logger.notify "NTP date succeeded after #{count} tries"
end
end
rescue => e
report_and_raise(@logger, e, "timesync (--ntp)")
end
|