mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Updating the beacon state module to ensure that the format of the beacon data that is being sent along to the beacon execution module is in the right format.
This commit is contained in:
parent
12de4b99d4
commit
f3dee43bf0
@ -134,7 +134,7 @@ def add(name, beacon_data, **kwargs):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' beacons.add ps "[{'salt-master': 'stopped', 'apache2': 'stopped'}]"
|
||||
salt '*' beacons.add ps "[{'salt-master': 'stopped'}, {'apache2': 'stopped'}]"
|
||||
|
||||
'''
|
||||
ret = {'comment': 'Failed to add beacon {0}.'.format(name),
|
||||
@ -207,7 +207,7 @@ def modify(name, beacon_data, **kwargs):
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' beacons.modify ps "[{'salt-master': 'stopped', 'apache2': 'stopped'}]"
|
||||
salt '*' beacons.modify ps "[{'salt-master': 'stopped'}, {'apache2': 'stopped'}]"
|
||||
'''
|
||||
|
||||
ret = {'comment': '',
|
||||
|
@ -34,6 +34,12 @@ Management of the Salt beacons
|
||||
'''
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt libs
|
||||
from salt.ext import six
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def present(name,
|
||||
save=False,
|
||||
@ -54,7 +60,7 @@ def present(name,
|
||||
'comment': []}
|
||||
|
||||
current_beacons = __salt__['beacons.list'](return_yaml=False)
|
||||
beacon_data = [kwargs]
|
||||
beacon_data = [{k: v} for k, v in six.iteritems(kwargs)]
|
||||
|
||||
if name in current_beacons:
|
||||
|
||||
|
49
tests/integration/states/test_beacon.py
Normal file
49
tests/integration/states/test_beacon.py
Normal file
@ -0,0 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
'''
|
||||
Integration tests for the beacon states
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.case import ModuleCase
|
||||
from tests.support.helpers import destructiveTest
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@destructiveTest
|
||||
class BeaconStateTestCase(ModuleCase):
|
||||
'''
|
||||
Test zookeeper states
|
||||
'''
|
||||
def setUp(self):
|
||||
'''
|
||||
'''
|
||||
pass
|
||||
|
||||
def tearDown(self):
|
||||
pass
|
||||
|
||||
def test_present_absent(self):
|
||||
kwargs = {'/': '38%', 'interval': 5}
|
||||
ret = self.run_state(
|
||||
'beacon.present',
|
||||
name='diskusage',
|
||||
**kwargs
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
ret = self.run_function('beacons.list', return_yaml=False)
|
||||
self.assertEqual(ret, {'diskusage': [{'interval': 5}, {'/': u'38%'}]})
|
||||
|
||||
ret = self.run_state(
|
||||
'beacon.absent',
|
||||
name='diskusage',
|
||||
)
|
||||
self.assertSaltTrueReturn(ret)
|
||||
|
||||
ret = self.run_function('beacons.list', return_yaml=False)
|
||||
self.assertEqual(ret, {'beacons': {}})
|
Loading…
Reference in New Issue
Block a user