Merge branch '2018.3' into netbsdswap

This commit is contained in:
Nicole Thomas 2018-04-25 09:55:25 -04:00 committed by GitHub
commit 0bcb1a079a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 70 additions and 32 deletions

View file

@ -46,7 +46,9 @@ This should complete the proxy setup for ``p8000``
beacons:
salt_proxy:
- p8000: {}
- proxies:
p8000: {}
p8001: {}
Once this beacon is configured it will automatically start the ``salt-proxy``

View file

@ -495,7 +495,7 @@ pkg
Significate changes have been made to the :mod:`win_pkg <salt.modules.win_pkg>` execution module. Users should test this release against their existing package sls definition files. These changes are also in 2016.11.9 & 2017.7.3.
- ``pkg.list_available`` no longer defaults to refreshing the winrepo meta database.
- ``pkg.install`` without a ``version`` parameter no longer upgrades software if the software is already installed. Use ``pkg.install version=latest`` or in a state use ``pkg.latest`` to get the old behavior.
- ``pkg.install`` without a ``version`` parameter no longer upgrades software if the software is already installed. Use ``pkg.install version=latest`` or in a state use ``pkg.latest`` to get the old behavior.
- ``pkg.list_pkgs`` now returns multiple versions if software installed more than once.
- ``pkg.list_pkgs`` now returns 'Not Found' when the version is not found instead of '(value not set)' which matches the contents of the sls definitions.
- ``pkg.remove()`` will wait upto 3 seconds (normally about a second) to detect changes in the registry after removing software, improving reporting of version changes.
@ -1220,10 +1220,11 @@ check the configuration for the correct format and only load if the validation p
beacons:
proxy_example:
endpoint: beacon
```
New behavior:
```
.. code-block:: yaml
beacons:
proxy_example:
- endpoint: beacon

View file

@ -63,8 +63,8 @@ def beacon(config):
beacons:
diskusage:
- interval: 120
- 'c:\': 90%
- 'd:\': 50%
- 'c:\\': 90%
- 'd:\\': 50%
Regular expressions can be used as mount points.
@ -73,7 +73,7 @@ def beacon(config):
beacons:
diskusage:
- '^\/(?!home).*$': 90%
- '^[a-zA-Z]:\$': 50%
- '^[a-zA-Z]:\\$': 50%
The first one will match all mounted disks beginning with "/", except /home
The second one will match disks from A:\ to Z:\ on a Windows system

View file

@ -54,6 +54,7 @@ def validate(config):
if not isinstance(_config['proxies'], dict):
return False, ('Proxies for salt_proxy '
'beacon must be a dictionary.')
return True, 'Valid beacon configuration'
def beacon(config):

View file

@ -197,7 +197,7 @@ def _get_virtual():
__context__['pkg._get_virtual'][realpkg] = []
__context__['pkg._get_virtual'][realpkg].append(pkg.name)
elif _has_dctrl_tools():
cmd = ['grep-available', '-F', 'Provides', '-s',
cmd = ['grep-status', '-F', 'Provides', '-s',
'Package,Provides', '-e', '^.+$']
out = __salt__['cmd.run_stdout'](cmd,
output_loglevel='trace',
@ -1393,8 +1393,8 @@ def list_pkgs(versions_as_list=False,
name,
version_num)
# Check for virtual packages. We need dctrl-tools for this.
if not removed and not HAS_APT:
# Check for virtual packages
if not removed:
try:
virtpkgs_all = _get_virtual()
except CommandExecutionError as cee:

View file

@ -8,9 +8,11 @@ from __future__ import absolute_import, print_function, unicode_literals
# Import Salt Testing libs
from tests.support.case import ModuleCase
from tests.support.mixins import LoaderModuleMockMixin
from tests.support.unit import skipIf
# Import Salt libs
import salt.loader
import salt.utils.platform
if salt.utils.platform.is_windows():
try:
@ -27,19 +29,6 @@ class TestGrainsCore(ModuleCase):
'''
Test the core grains grains
'''
@skipIf(not salt.utils.platform.is_windows(), 'Only run on Windows')
def test_win_cpu_model(self):
'''
test grains['cpu_model']
'''
cpu_model_text = salt.modules.reg.read_value(
'HKEY_LOCAL_MACHINE',
'HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0',
'ProcessorNameString').get('vdata')
self.assertEqual(
self.run_function('grains.items')['cpu_model'],
cpu_model_text
)
@skipIf(not _freebsd_or_openbsd(), 'Only run on FreeBSD or OpenBSD')
def test_freebsd_openbsd_mem_total(self):
@ -62,3 +51,33 @@ class TestGrainsCore(ModuleCase):
self.run_function('grains.items')['swap_total'],
int(swapmem) / 1048576
)
class TestGrainsReg(ModuleCase, LoaderModuleMockMixin):
'''
Test the core windows grains
'''
def setup_loader_modules(self):
self.opts = opts = salt.config.DEFAULT_MINION_OPTS
utils = salt.loader.utils(opts, whitelist=['reg'])
return {
salt.modules.reg: {
'__opts__': opts,
'__utils__': utils,
}
}
@skipIf(not salt.utils.platform.is_windows(), 'Only run on Windows')
def test_win_cpu_model(self):
'''
test grains['cpu_model']
'''
cpu_model_text = salt.modules.reg.read_value(
'HKEY_LOCAL_MACHINE',
'HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0',
'ProcessorNameString').get('vdata')
self.assertEqual(
self.run_function('grains.items')['cpu_model'],
cpu_model_text
)

View file

@ -444,12 +444,14 @@ class CPModuleTest(ModuleCase):
self.assertIn('ARTHUR:', data)
self.assertNotIn('bacon', data)
def test_cache_master(self):
@with_tempfile()
def test_cache_master(self, tgt):
'''
cp.cache_master
'''
ret = self.run_function(
'cp.cache_master',
[tgt],
)
for path in ret:
self.assertTrue(os.path.exists(path))

View file

@ -53,6 +53,7 @@ class SaltProxyBeaconTestCase(TestCase, LoaderModuleMockMixin):
config = [{'proxies': {'p8000': ''}}]
ret = salt_proxy.validate(config)
self.assertEqual(ret, (True, 'Valid beacon configuration'))
ret = salt_proxy.beacon(config)
self.assertEqual(ret, [{'p8000': 'Proxy p8000 is already running'}])
@ -75,6 +76,7 @@ class SaltProxyBeaconTestCase(TestCase, LoaderModuleMockMixin):
config = [{'proxies': {'p8000': ''}}]
ret = salt_proxy.validate(config)
self.assertEqual(ret, (True, 'Valid beacon configuration'))
ret = salt_proxy.beacon(config)
self.assertEqual(ret, [{'p8000': 'Proxy p8000 was started'}])

View file

@ -59,6 +59,7 @@ class SensehatBeaconTestCase(TestCase, LoaderModuleMockMixin):
config = [{'sensors': {'humidity': '70%'}}]
ret = sensehat.validate(config)
self.assertEqual(ret, (True, 'Valid beacon configuration'))
ret = sensehat.beacon(config)
self.assertEqual(ret, [{'tag': 'sensehat/humidity',
@ -69,6 +70,7 @@ class SensehatBeaconTestCase(TestCase, LoaderModuleMockMixin):
config = [{'sensors': {'temperature': 20}}]
ret = sensehat.validate(config)
self.assertEqual(ret, (True, 'Valid beacon configuration'))
ret = sensehat.beacon(config)
self.assertEqual(ret, [{'tag': 'sensehat/temperature',
@ -79,6 +81,7 @@ class SensehatBeaconTestCase(TestCase, LoaderModuleMockMixin):
config = [{'sensors': {'temperature': [20, 29]}}]
ret = sensehat.validate(config)
self.assertEqual(ret, (True, 'Valid beacon configuration'))
ret = sensehat.beacon(config)
self.assertEqual(ret, [{'tag': 'sensehat/temperature',
@ -89,6 +92,7 @@ class SensehatBeaconTestCase(TestCase, LoaderModuleMockMixin):
config = [{'sensors': {'pressure': '1400'}}]
ret = sensehat.validate(config)
self.assertEqual(ret, (True, 'Valid beacon configuration'))
ret = sensehat.beacon(config)
self.assertEqual(ret, [{'tag': 'sensehat/pressure',
@ -99,6 +103,7 @@ class SensehatBeaconTestCase(TestCase, LoaderModuleMockMixin):
config = [{'sensors': {'pressure': '1600'}}]
ret = sensehat.validate(config)
self.assertEqual(ret, (True, 'Valid beacon configuration'))
ret = sensehat.beacon(config)
self.assertEqual(ret, [])

View file

@ -44,7 +44,11 @@ class StatusBeaconTestCase(TestCase, LoaderModuleMockMixin):
}
def test_empty_config(self, *args, **kwargs):
config = {}
config = []
ret = status.validate(config)
self.assertEqual(ret, (True, 'Valid beacon configuration'))
ret = status.beacon(config)
if sys.platform.startswith('win'):
@ -56,17 +60,16 @@ class StatusBeaconTestCase(TestCase, LoaderModuleMockMixin):
def test_deprecated_dict_config(self):
config = {'time': ['all']}
ret = status.beacon(config)
if sys.platform.startswith('win'):
expected = []
else:
expected = ['time']
self.assertEqual(list(ret[0]['data']), expected)
ret = status.validate(config)
self.assertEqual(ret, (False, 'Configuration for status beacon must be a list.'))
def test_list_config(self):
config = [{'time': ['all']}]
ret = status.validate(config)
self.assertEqual(ret, (True, 'Valid beacon configuration'))
ret = status.beacon(config)
if sys.platform.startswith('win'):

View file

@ -81,6 +81,7 @@ class TelegramBotMsgBeaconTestCase(TestCase, LoaderModuleMockMixin):
inst.get_updates.return_value = []
ret = telegram_bot_msg.beacon(config)
self.assertEqual(ret, (True, 'Valid beacon configuration'))
telegram_api.Bot.assert_called_once_with(token)
self.assertEqual(ret, [])
@ -107,6 +108,7 @@ class TelegramBotMsgBeaconTestCase(TestCase, LoaderModuleMockMixin):
inst.get_updates.return_value = [update]
ret = telegram_bot_msg.beacon(config)
self.assertEqual(ret, (True, 'Valid beacon configuration'))
telegram_api.Bot.assert_called_once_with(token)
self.assertEqual(ret, [])
@ -131,6 +133,7 @@ class TelegramBotMsgBeaconTestCase(TestCase, LoaderModuleMockMixin):
inst.get_updates.return_value = [update]
ret = telegram_bot_msg.beacon(config)
self.assertEqual(ret, (True, 'Valid beacon configuration'))
telegram_api.Bot.assert_called_once_with(token)
self.assertTrue(ret)