Swapping out if state looking for test in opts for a __opts__.get

This commit is contained in:
Gareth J. Greenaway 2019-03-19 09:49:23 -07:00
parent e1cf599eb3
commit 7f83b4baee
No known key found for this signature in database
GPG key ID: 10B62F8A7CAD7A41

View file

@ -67,7 +67,7 @@ def present(name,
if beacon_data == current_beacons[name]:
ret['comment'].append('Job {0} in correct state'.format(name))
else:
if 'test' in __opts__ and __opts__['test']:
if __opts__.get('test'):
kwargs['test'] = True
result = __salt__['beacons.modify'](name, beacon_data)
ret['comment'].append(result['comment'])
@ -86,7 +86,7 @@ def present(name,
ret['comment'].append(result['comment'])
else:
if 'test' in __opts__ and __opts__['test']:
if __opts__.get('test'):
kwargs['test'] = True
result = __salt__['beacons.add'](name, beacon_data, **kwargs)
ret['comment'].append(result['comment'])
@ -100,7 +100,7 @@ def present(name,
ret['comment'].append('Adding {0} to beacons'.format(name))
if save:
if 'test' in __opts__ and __opts__['test']:
if __opts__.get('test'):
ret['comment'].append('Beacon {0} would be saved'.format(name))
else:
result = __salt__['beacons.save']()
@ -133,7 +133,7 @@ def absent(name,
current_beacons = __salt__['beacons.list'](return_yaml=False)
if name in current_beacons:
if 'test' in __opts__ and __opts__['test']:
if __opts__.get('test'):
kwargs['test'] = True
result = __salt__['beacons.delete'](name, **kwargs)
ret['comment'].append(result['comment'])
@ -149,7 +149,7 @@ def absent(name,
ret['comment'].append('{0} not configured in beacons'.format(name))
if save:
if 'test' in __opts__ and __opts__['test']:
if __opts__.get('test'):
ret['comment'].append('Beacon {0} would be saved'.format(name))
else:
result = __salt__['beacons.save']()
@ -178,7 +178,7 @@ def enabled(name, **kwargs):
current_beacons = __salt__['beacons.list'](return_yaml=False)
if name in current_beacons:
if 'test' in __opts__ and __opts__['test']:
if __opts__.get('test'):
kwargs['test'] = True
result = __salt__['beacons.enable_beacon'](name, **kwargs)
ret['comment'].append(result['comment'])
@ -216,7 +216,7 @@ def disabled(name, **kwargs):
current_beacons = __salt__['beacons.list'](return_yaml=False)
if name in current_beacons:
if 'test' in __opts__ and __opts__['test']:
if __opts__.get('test'):
kwargs['test'] = True
result = __salt__['beacons.disable_beacon'](name, **kwargs)
ret['comment'].append(result['comment'])