Fix network.managed test=True on Windows

Fixes some logic in detecting enabled interfaces
This commit is contained in:
twangboy 2018-03-29 15:31:33 -06:00
parent 395b7f8fdc
commit f1c68a09b5
No known key found for this signature in database
GPG key ID: 93FF3BDEB278C9EB

View file

@ -265,8 +265,13 @@ def managed(name,
ret['comment'] = ' '.join(errors)
return ret
try:
currently_enabled = __salt__['ip.is_enabled'](name)
except CommandExecutionError:
currently_enabled = False
if not enabled:
if __salt__['ip.is_enabled'](name):
if currently_enabled:
if __opts__['test']:
ret['result'] = None
ret['comment'] = ('Interface \'{0}\' will be disabled'
@ -277,21 +282,16 @@ def managed(name,
ret['comment'] = ('Failed to disable interface \'{0}\''
.format(name))
else:
ret['comment'] += ' (already disabled)'
ret['comment'] += '(already disabled)'
return ret
else:
try:
currently_enabled = __salt__['ip.is_disabled'](name)
except CommandExecutionError:
currently_enabled = False
if not currently_enabled:
if __opts__['test']:
ret['result'] = None
ret['comment'] = ('Interface \'{0}\' will be enabled'
.format(name))
else:
result = __salt__['ip.enable'](name)
if not result:
if not __salt__['ip.enable'](name):
ret['result'] = False
ret['comment'] = ('Failed to enable interface \'{0}\' to '
'make changes'.format(name))