Skip to content

Commit

Permalink
Merge pull request #55532 from s0undt3ch/features/pytest-staged-24
Browse files Browse the repository at this point in the history
[PyTest #24] Beacons module related fixes
  • Loading branch information
dwoz authored Dec 12, 2019
2 parents 963a6ec + 75fb35b commit 4618a4c
Showing 1 changed file with 42 additions and 13 deletions.
55 changes: 42 additions & 13 deletions salt/modules/beacons.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,9 +196,14 @@ def add(name, beacon_data, **kwargs):
if name in beacons and beacons[name] == beacon_data:
ret['result'] = True
ret['comment'] = 'Added beacon: {0}.'.format(name)
else:
elif event_ret:
ret['result'] = False
ret['comment'] = event_ret['comment']
else:
ret['result'] = False
ret['comment'] = 'Did not receive the beacon add complete event before the timeout of {}s'.format(
kwargs.get('timeout', default_event_wait)
)
return ret
except KeyError:
# Effectively a no-op, since we can't really return without an event system
Expand Down Expand Up @@ -295,9 +300,14 @@ def modify(name, beacon_data, **kwargs):
if name in beacons and beacons[name] == beacon_data:
ret['result'] = True
ret['comment'] = 'Modified beacon: {0}.'.format(name)
else:
elif event_ret:
ret['result'] = False
ret['comment'] = event_ret['comment']
else:
ret['result'] = False
ret['comment'] = 'Did not receive the beacon modify complete event before the timeout of {}s'.format(
kwargs.get('timeout', default_event_wait)
)
return ret
except KeyError:
# Effectively a no-op, since we can't really return without an event system
Expand Down Expand Up @@ -342,9 +352,14 @@ def delete(name, **kwargs):
ret['result'] = True
ret['comment'] = 'Deleted beacon: {0}.'.format(name)
return ret
else:
elif event_ret:
ret['result'] = False
ret['comment'] = event_ret['comment']
else:
ret['result'] = False
ret['comment'] = 'Did not receive the beacon delete complete event before the timeout of {}s'.format(
kwargs.get('timeout', default_event_wait)
)
except KeyError:
# Effectively a no-op, since we can't really return without an event system
ret['comment'] = 'Event module not available. Beacon add failed.'
Expand Down Expand Up @@ -422,9 +437,14 @@ def enable(**kwargs):
if 'enabled' in beacons and beacons['enabled']:
ret['result'] = True
ret['comment'] = 'Enabled beacons on minion.'
else:
elif event_ret:
ret['result'] = False
ret['comment'] = 'Failed to enable beacons on minion.'
else:
ret['result'] = False
ret['comment'] = 'Did not receive the beacon enabled complete event before the timeout of {}s'.format(
kwargs.get('timeout', default_event_wait)
)
return ret
except KeyError:
# Effectively a no-op, since we can't really return without an event system
Expand Down Expand Up @@ -464,9 +484,14 @@ def disable(**kwargs):
if 'enabled' in beacons and not beacons['enabled']:
ret['result'] = True
ret['comment'] = 'Disabled beacons on minion.'
else:
elif event_ret:
ret['result'] = False
ret['comment'] = 'Failed to disable beacons on minion.'
else:
ret['result'] = False
ret['comment'] = 'Did not receive the beacon disabled complete event before the timeout of {}s'.format(
kwargs.get('timeout', default_event_wait)
)
return ret
except KeyError:
# Effectively a no-op, since we can't really return without an event system
Expand Down Expand Up @@ -532,12 +557,14 @@ def enable_beacon(name, **kwargs):
else:
ret['result'] = False
ret['comment'] = 'Failed to enable beacon {0} on minion.'.format(name)
elif event_ret:
ret['result'] = False
ret['comment'] = event_ret['comment']
else:
ret['result'] = False
if event_ret is not None:
ret['comment'] = event_ret['comment']
else:
ret['comment'] = 'Beacon enabled event never received'
ret['comment'] = 'Did not receive the beacon enabled complete event before the timeout of {}s'.format(
kwargs.get('timeout', default_event_wait)
)
return ret
except KeyError:
# Effectively a no-op, since we can't really return without an event system
Expand Down Expand Up @@ -593,12 +620,14 @@ def disable_beacon(name, **kwargs):
else:
ret['result'] = False
ret['comment'] = 'Failed to disable beacon on minion.'
elif event_ret:
ret['result'] = False
ret['comment'] = event_ret['comment']
else:
ret['result'] = False
if event_ret is not None:
ret['comment'] = event_ret['comment']
else:
ret['comment'] = 'Beacon disabled event never received'
ret['comment'] = 'Did not receive the beacon disabled complete event before the timeout of {}s'.format(
kwargs.get('timeout', default_event_wait)
)
return ret
except KeyError:
# Effectively a no-op, since we can't really return without an event system
Expand Down

0 comments on commit 4618a4c

Please sign in to comment.