mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Fix network.managed test=True on Windows
Fixes some logic in detecting enabled interfaces
This commit is contained in:
parent
395b7f8fdc
commit
f1c68a09b5
1 changed files with 8 additions and 8 deletions
|
@ -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))
|
||||
|
|
Loading…
Add table
Reference in a new issue