Refactor new win_ntp module

Use built in service management functions to handle starting/restarting
services.
This commit is contained in:
Erik Johnson 2013-10-09 14:43:44 -05:00
parent 0ce1473298
commit 2ee1dab825

View File

@ -31,12 +31,16 @@ def set_servers(*servers):
salt '*' ntp.set_servers 'pool.ntp.org' 'us.pool.ntp.org'
'''
cmd = ('W32tm /config /syncfromflags:manual /manualpeerlist:"{0}" &&'
'W32tm /config /reliable:yes &&'
'W32tm /config /update &&'
'Net stop w32time && Net start w32time'
).format(' '.join(servers))
ret = __salt__['cmd.run'](cmd)
service_name = 'w32time'
if not __salt__['service.status'](service_name):
if not __salt__['service.start'](service_name):
return False
ret = __salt__['cmd.run'](
'W32tm /config /syncfromflags:manual /manualpeerlist:"{0}" &&'
'W32tm /config /reliable:yes && W32tm /config /update'
.format(' '.join(servers))
)
__salt__['service.restart'](service_name)
return 'command completed successfully' in ret