Handle when beacon not configured and we try to enable/disable them (#32692)

* Handle the situation when the beacon is not configured and we try to disable it

* a couple more missing returns in the enable & disable
This commit is contained in:
garethgreenaway 2016-04-20 15:58:51 -04:00 committed by Nicole Thomas
parent f52af5a596
commit 3aa0605033

View File

@ -394,13 +394,16 @@ def enable_beacon(name, **kwargs):
if not name:
ret['comment'] = 'Beacon name is required.'
ret['result'] = False
return ret
if 'test' in kwargs and kwargs['test']:
ret['comment'] = 'Beacon {0} would be enabled.'.format(name)
else:
if name not in list_(return_yaml=True):
_beacons = list_(return_yaml=False)
if name not in _beacons:
ret['comment'] = 'Beacon {0} is not currently configured.'.format(name)
ret['result'] = False
return ret
try:
eventer = salt.utils.event.get_event('minion', opts=__opts__)
@ -442,13 +445,16 @@ def disable_beacon(name, **kwargs):
if not name:
ret['comment'] = 'Beacon name is required.'
ret['result'] = False
return ret
if 'test' in kwargs and kwargs['test']:
ret['comment'] = 'Beacons would be enabled.'
else:
if name not in list_(return_yaml=True):
_beacons = list_(return_yaml=False)
if name not in _beacons:
ret['comment'] = 'Beacon {0} is not currently configured.'.format(name)
ret['result'] = False
return ret
try:
eventer = salt.utils.event.get_event('minion', opts=__opts__)