Merge pull request #40701 from rallytime/merge-nitrogen

[nitrogen] Merge forward from 2016.11 to nitrogen
This commit is contained in:
Nicole Thomas 2017-04-17 09:19:10 -06:00 committed by GitHub
commit 06a4cf84fd
7 changed files with 44 additions and 31 deletions

View File

@ -383,6 +383,7 @@ Section -Post
nsExec::Exec "nssm.exe set salt-minion AppEnvironmentExtra PYTHONHOME=" nsExec::Exec "nssm.exe set salt-minion AppEnvironmentExtra PYTHONHOME="
nsExec::Exec "nssm.exe set salt-minion Description Salt Minion from saltstack.com" nsExec::Exec "nssm.exe set salt-minion Description Salt Minion from saltstack.com"
nsExec::Exec "nssm.exe set salt-minion Start SERVICE_AUTO_START" nsExec::Exec "nssm.exe set salt-minion Start SERVICE_AUTO_START"
nsExec::Exec "nssm.exe set salt-minion AppNoConsole 1"
RMDir /R "$INSTDIR\var\cache\salt" ; removing cache from old version RMDir /R "$INSTDIR\var\cache\salt" ; removing cache from old version

View File

@ -81,6 +81,12 @@ markers for specific list items:
- 0 - 0
- 1 - 1
- 2 - 2
.. warning::
Not all status functions are supported for every operating system. Be certain
to check the minion log for errors after configuring this beacon.
''' '''
# Import python libs # Import python libs
@ -94,6 +100,8 @@ import salt.utils
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
__virtualname__ = 'status'
def __validate__(config): def __validate__(config):
''' '''
@ -105,11 +113,7 @@ def __validate__(config):
def __virtual__(): def __virtual__():
# TODO Find a way to check the existence of the module itself, not just a single func return __virtualname__
if 'status.w' not in __salt__:
return (False, 'The \'status\' execution module is not available on this system')
else:
return True
def beacon(config): def beacon(config):

View File

@ -72,6 +72,7 @@ import logging
# Import 3rd-party libs # Import 3rd-party libs
# pylint: disable=no-name-in-module,import-error # pylint: disable=no-name-in-module,import-error
from salt.ext.six import string_types as _string_types
from salt.ext.six.moves.urllib.parse import urlencode as _urlencode from salt.ext.six.moves.urllib.parse import urlencode as _urlencode
from salt.ext.six.moves.urllib.request import ( from salt.ext.six.moves.urllib.request import (
urlopen as _urlopen, urlopen as _urlopen,
@ -176,7 +177,7 @@ def _auth(uri):
return _build_opener(basic, digest) return _build_opener(basic, digest)
def _extract_war_version(war): def extract_war_version(war):
''' '''
Extract the version from the war file name. There does not seem to be a Extract the version from the war file name. There does not seem to be a
standard for encoding the version into the `war file name standard for encoding the version into the `war file name
@ -526,7 +527,7 @@ def deploy_war(war,
saltenv='base', saltenv='base',
timeout=180, timeout=180,
temp_war_location=None, temp_war_location=None,
version=''): version=True):
''' '''
Deploy a WAR file Deploy a WAR file
@ -607,11 +608,11 @@ def deploy_war(war,
} }
# If parallel versions are desired or not disabled # If parallel versions are desired or not disabled
if version is True: if version:
# Set it to defined version or attempt extract # Set it to defined version or attempt extract
version = version or _extract_war_version(war) version = extract_war_version(war) if version is True else version
if version != ('' or None): if isinstance(version, _string_types):
# Only pass version to Tomcat if not undefined # Only pass version to Tomcat if not undefined
opts['version'] = version opts['version'] = version

View File

@ -192,10 +192,14 @@ def returner(ret):
logoption = logoption | getattr(syslog, opt) logoption = logoption | getattr(syslog, opt)
# Open syslog correctly based on options and tag # Open syslog correctly based on options and tag
if 'tag' in _options: try:
syslog.openlog(ident=_options['tag'], logoption=logoption) if 'tag' in _options:
else: syslog.openlog(ident=_options['tag'], logoption=logoption)
syslog.openlog(logoption=logoption) else:
syslog.openlog(logoption=logoption)
except TypeError:
# Python 2.6 syslog.openlog does not accept keyword args
syslog.openlog(_options.get('tag', 'salt-minion'), logoption)
# Send log of given level and facility # Send log of given level and facility
syslog.syslog(facility | level, '{0}'.format(json.dumps(ret))) syslog.syslog(facility | level, '{0}'.format(json.dumps(ret)))

View File

@ -57,9 +57,6 @@ Notes
from __future__ import absolute_import from __future__ import absolute_import
# import salt libs
from salt.modules.tomcat import _extract_war_version
# Private # Private
def __virtual__(): def __virtual__():
@ -77,7 +74,7 @@ def war_deployed(name,
url='http://localhost:8080/manager', url='http://localhost:8080/manager',
timeout=180, timeout=180,
temp_war_location=None, temp_war_location=None,
version=''): version=True):
''' '''
Enforce that the WAR will be deployed and started in the context path, Enforce that the WAR will be deployed and started in the context path,
while making use of WAR versions in the filename. while making use of WAR versions in the filename.
@ -108,9 +105,9 @@ def war_deployed(name,
.. versionadded:: 2015.8.6 .. versionadded:: 2015.8.6
Use ``False`` to prevent guessing the version and keeping it blank. Use ``False`` or blank value to prevent guessing the version and keeping it blank.
.. versionadded:: 2016.PLEASE_LET_ME_KNOW .. versionadded:: 2016.11.0
Example: Example:
@ -118,7 +115,7 @@ def war_deployed(name,
jenkins: jenkins:
tomcat.war_deployed: tomcat.war_deployed:
- name: /ran - name: /salt-powered-jenkins
- war: salt://jenkins-1.2.4.war - war: salt://jenkins-1.2.4.war
- require: - require:
- service: application-service - service: application-service
@ -126,7 +123,7 @@ def war_deployed(name,
.. note:: .. note::
Be aware that in the above example the WAR ``jenkins-1.2.4.war`` will Be aware that in the above example the WAR ``jenkins-1.2.4.war`` will
be deployed to the context path ``jenkins##1.2.4``. To avoid this be deployed to the context path ``salt-powered-jenkins##1.2.4``. To avoid this
either specify a version yourself, or set version to ``False``. either specify a version yourself, or set version to ``False``.
''' '''
@ -137,12 +134,10 @@ def war_deployed(name,
'comment': ''} 'comment': ''}
# if version is defined or False, we don't want to overwrite # if version is defined or False, we don't want to overwrite
if version == '': if version is True:
version = _extract_war_version(war) or "" version = __salt__['tomcat.extract_war_version'](war) or ''
elif not version: elif not version:
version = '' version = ''
else:
version = str(version)
webapps = __salt__['tomcat.ls'](url, timeout) webapps = __salt__['tomcat.ls'](url, timeout)
deploy = False deploy = False
@ -150,7 +145,7 @@ def war_deployed(name,
status = True status = True
# Gathered/specified new WAR version string # Gathered/specified new WAR version string
specified_ver = 'version ' + version if version else 'no version' specified_ver = 'version {0}'.format(version) if version else 'no version'
# Determine what to do # Determine what to do
try: try:

View File

@ -146,8 +146,9 @@ class DiskTestCase(TestCase, LoaderModuleMockMixin):
device = '/dev/sdX1' device = '/dev/sdX1'
fs_type = 'ext4' fs_type = 'ext4'
mock = MagicMock(return_value='FSTYPE\n{0}'.format(fs_type)) mock = MagicMock(return_value='FSTYPE\n{0}'.format(fs_type))
with patch.dict(disk.__salt__, {'cmd.run': mock}): with patch.dict(disk.__grains__, {'kernel': 'Linux'}):
self.assertEqual(disk.fstype(device), fs_type) with patch.dict(disk.__salt__, {'cmd.run': mock}):
self.assertEqual(disk.fstype(device), fs_type)
@skipIf(not salt.utils.which('resize2fs'), 'resize2fs not found') @skipIf(not salt.utils.which('resize2fs'), 'resize2fs not found')
def test_resize2fs(self): def test_resize2fs(self):

View File

@ -8,6 +8,7 @@ from __future__ import absolute_import
# Import Salt Libs # Import Salt Libs
import salt.states.tomcat as tomcat import salt.states.tomcat as tomcat
from salt.modules import tomcat as tomcatmod
# Import Salt Testing Libs # Import Salt Testing Libs
from tests.support.mixins import LoaderModuleMockMixin from tests.support.mixins import LoaderModuleMockMixin
@ -49,6 +50,7 @@ class TomcatTestCase(TestCase, LoaderModuleMockMixin):
{'salt': {'version': '1'}}, {'salt': {'version': '1'}},
{'salt': {'version': '1'}}]) {'salt': {'version': '1'}}])
with patch.dict(tomcat.__salt__, {"tomcat.ls": mock_ls, with patch.dict(tomcat.__salt__, {"tomcat.ls": mock_ls,
'tomcat.extract_war_version': tomcatmod.extract_war_version,
'tomcat.start': mock_start, 'tomcat.start': mock_start,
'tomcat.undeploy': mock_undeploy, 'tomcat.undeploy': mock_undeploy,
'tomcat.deploy_war': mock_deploy}): 'tomcat.deploy_war': mock_deploy}):
@ -112,6 +114,7 @@ class TomcatTestCase(TestCase, LoaderModuleMockMixin):
with patch.dict(tomcat.__opts__, {"test": True}): with patch.dict(tomcat.__opts__, {"test": True}):
with patch.dict(tomcat.__salt__, with patch.dict(tomcat.__salt__,
{"tomcat.ls": mock_ls_version, {"tomcat.ls": mock_ls_version,
"tomcat.extract_war_version": tomcatmod.extract_war_version,
"tomcat.deploy_war": mock_deploy, "tomcat.deploy_war": mock_deploy,
"tomcat.undeploy": mock_undeploy}): "tomcat.undeploy": mock_undeploy}):
# We deploy from version to no version # We deploy from version to no version
@ -125,6 +128,7 @@ class TomcatTestCase(TestCase, LoaderModuleMockMixin):
with patch.dict(tomcat.__salt__, with patch.dict(tomcat.__salt__,
{"tomcat.ls": mock_ls_no_version, {"tomcat.ls": mock_ls_no_version,
"tomcat.extract_war_version": tomcatmod.extract_war_version,
"tomcat.deploy_war": mock_deploy, "tomcat.deploy_war": mock_deploy,
"tomcat.undeploy": mock_undeploy}): "tomcat.undeploy": mock_undeploy}):
# Deploy from none to specified version # Deploy from none to specified version
@ -164,7 +168,8 @@ class TomcatTestCase(TestCase, LoaderModuleMockMixin):
'result': True, 'result': True,
'comment': 'tomcat manager is ready'} 'comment': 'tomcat manager is ready'}
mock = MagicMock(return_value=True) mock = MagicMock(return_value=True)
with patch.dict(tomcat.__salt__, {"tomcat.status": mock}): with patch.dict(tomcat.__salt__, {"tomcat.status": mock,
"tomcat.extract_war_version": tomcatmod.extract_war_version}):
self.assertDictEqual(tomcat.wait('salt'), ret) self.assertDictEqual(tomcat.wait('salt'), ret)
def test_mod_watch(self): def test_mod_watch(self):
@ -176,7 +181,8 @@ class TomcatTestCase(TestCase, LoaderModuleMockMixin):
'result': False, 'result': False,
'comment': 'True'} 'comment': 'True'}
mock = MagicMock(return_value='True') mock = MagicMock(return_value='True')
with patch.dict(tomcat.__salt__, {"tomcat.reload": mock}): with patch.dict(tomcat.__salt__, {"tomcat.reload": mock,
"tomcat.extract_war_version": tomcatmod.extract_war_version}):
ret.update({'changes': {'salt': False}}) ret.update({'changes': {'salt': False}})
self.assertDictEqual(tomcat.mod_watch('salt'), ret) self.assertDictEqual(tomcat.mod_watch('salt'), ret)
@ -195,6 +201,7 @@ class TomcatTestCase(TestCase, LoaderModuleMockMixin):
{'salt': {'version': 1}}]) {'salt': {'version': 1}}])
mock2 = MagicMock(side_effect=['FAIL', 'saltstack']) mock2 = MagicMock(side_effect=['FAIL', 'saltstack'])
with patch.dict(tomcat.__salt__, {"tomcat.status": mock, with patch.dict(tomcat.__salt__, {"tomcat.status": mock,
"tomcat.extract_war_version": tomcatmod.extract_war_version,
"tomcat.ls": mock1, "tomcat.ls": mock1,
"tomcat.undeploy": mock2}): "tomcat.undeploy": mock2}):
ret.update({'comment': 'Tomcat Manager does not respond'}) ret.update({'comment': 'Tomcat Manager does not respond'})