mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 08:58:59 +00:00
Merge pull request #40701 from rallytime/merge-nitrogen
[nitrogen] Merge forward from 2016.11 to nitrogen
This commit is contained in:
commit
06a4cf84fd
@ -383,6 +383,7 @@ Section -Post
|
||||
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 Start SERVICE_AUTO_START"
|
||||
nsExec::Exec "nssm.exe set salt-minion AppNoConsole 1"
|
||||
|
||||
RMDir /R "$INSTDIR\var\cache\salt" ; removing cache from old version
|
||||
|
||||
|
@ -81,6 +81,12 @@ markers for specific list items:
|
||||
- 0
|
||||
- 1
|
||||
- 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
|
||||
@ -94,6 +100,8 @@ import salt.utils
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
__virtualname__ = 'status'
|
||||
|
||||
|
||||
def __validate__(config):
|
||||
'''
|
||||
@ -105,11 +113,7 @@ def __validate__(config):
|
||||
|
||||
|
||||
def __virtual__():
|
||||
# TODO Find a way to check the existence of the module itself, not just a single func
|
||||
if 'status.w' not in __salt__:
|
||||
return (False, 'The \'status\' execution module is not available on this system')
|
||||
else:
|
||||
return True
|
||||
return __virtualname__
|
||||
|
||||
|
||||
def beacon(config):
|
||||
|
@ -72,6 +72,7 @@ import logging
|
||||
|
||||
# Import 3rd-party libs
|
||||
# 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.request import (
|
||||
urlopen as _urlopen,
|
||||
@ -176,7 +177,7 @@ def _auth(uri):
|
||||
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
|
||||
standard for encoding the version into the `war file name
|
||||
@ -526,7 +527,7 @@ def deploy_war(war,
|
||||
saltenv='base',
|
||||
timeout=180,
|
||||
temp_war_location=None,
|
||||
version=''):
|
||||
version=True):
|
||||
'''
|
||||
Deploy a WAR file
|
||||
|
||||
@ -607,11 +608,11 @@ def deploy_war(war,
|
||||
}
|
||||
|
||||
# If parallel versions are desired or not disabled
|
||||
if version is True:
|
||||
if version:
|
||||
# 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
|
||||
opts['version'] = version
|
||||
|
||||
|
@ -192,10 +192,14 @@ def returner(ret):
|
||||
logoption = logoption | getattr(syslog, opt)
|
||||
|
||||
# Open syslog correctly based on options and tag
|
||||
if 'tag' in _options:
|
||||
syslog.openlog(ident=_options['tag'], logoption=logoption)
|
||||
else:
|
||||
syslog.openlog(logoption=logoption)
|
||||
try:
|
||||
if 'tag' in _options:
|
||||
syslog.openlog(ident=_options['tag'], 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
|
||||
syslog.syslog(facility | level, '{0}'.format(json.dumps(ret)))
|
||||
|
@ -57,9 +57,6 @@ Notes
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
# import salt libs
|
||||
from salt.modules.tomcat import _extract_war_version
|
||||
|
||||
|
||||
# Private
|
||||
def __virtual__():
|
||||
@ -77,7 +74,7 @@ def war_deployed(name,
|
||||
url='http://localhost:8080/manager',
|
||||
timeout=180,
|
||||
temp_war_location=None,
|
||||
version=''):
|
||||
version=True):
|
||||
'''
|
||||
Enforce that the WAR will be deployed and started in the context path,
|
||||
while making use of WAR versions in the filename.
|
||||
@ -108,9 +105,9 @@ def war_deployed(name,
|
||||
|
||||
.. 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:
|
||||
|
||||
@ -118,7 +115,7 @@ def war_deployed(name,
|
||||
|
||||
jenkins:
|
||||
tomcat.war_deployed:
|
||||
- name: /ran
|
||||
- name: /salt-powered-jenkins
|
||||
- war: salt://jenkins-1.2.4.war
|
||||
- require:
|
||||
- service: application-service
|
||||
@ -126,7 +123,7 @@ def war_deployed(name,
|
||||
.. note::
|
||||
|
||||
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``.
|
||||
|
||||
'''
|
||||
@ -137,12 +134,10 @@ def war_deployed(name,
|
||||
'comment': ''}
|
||||
|
||||
# if version is defined or False, we don't want to overwrite
|
||||
if version == '':
|
||||
version = _extract_war_version(war) or ""
|
||||
if version is True:
|
||||
version = __salt__['tomcat.extract_war_version'](war) or ''
|
||||
elif not version:
|
||||
version = ''
|
||||
else:
|
||||
version = str(version)
|
||||
|
||||
webapps = __salt__['tomcat.ls'](url, timeout)
|
||||
deploy = False
|
||||
@ -150,7 +145,7 @@ def war_deployed(name,
|
||||
status = True
|
||||
|
||||
# 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
|
||||
try:
|
||||
|
@ -146,8 +146,9 @@ class DiskTestCase(TestCase, LoaderModuleMockMixin):
|
||||
device = '/dev/sdX1'
|
||||
fs_type = 'ext4'
|
||||
mock = MagicMock(return_value='FSTYPE\n{0}'.format(fs_type))
|
||||
with patch.dict(disk.__salt__, {'cmd.run': mock}):
|
||||
self.assertEqual(disk.fstype(device), fs_type)
|
||||
with patch.dict(disk.__grains__, {'kernel': 'Linux'}):
|
||||
with patch.dict(disk.__salt__, {'cmd.run': mock}):
|
||||
self.assertEqual(disk.fstype(device), fs_type)
|
||||
|
||||
@skipIf(not salt.utils.which('resize2fs'), 'resize2fs not found')
|
||||
def test_resize2fs(self):
|
||||
|
@ -8,6 +8,7 @@ from __future__ import absolute_import
|
||||
|
||||
# Import Salt Libs
|
||||
import salt.states.tomcat as tomcat
|
||||
from salt.modules import tomcat as tomcatmod
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
@ -49,6 +50,7 @@ class TomcatTestCase(TestCase, LoaderModuleMockMixin):
|
||||
{'salt': {'version': '1'}},
|
||||
{'salt': {'version': '1'}}])
|
||||
with patch.dict(tomcat.__salt__, {"tomcat.ls": mock_ls,
|
||||
'tomcat.extract_war_version': tomcatmod.extract_war_version,
|
||||
'tomcat.start': mock_start,
|
||||
'tomcat.undeploy': mock_undeploy,
|
||||
'tomcat.deploy_war': mock_deploy}):
|
||||
@ -112,6 +114,7 @@ class TomcatTestCase(TestCase, LoaderModuleMockMixin):
|
||||
with patch.dict(tomcat.__opts__, {"test": True}):
|
||||
with patch.dict(tomcat.__salt__,
|
||||
{"tomcat.ls": mock_ls_version,
|
||||
"tomcat.extract_war_version": tomcatmod.extract_war_version,
|
||||
"tomcat.deploy_war": mock_deploy,
|
||||
"tomcat.undeploy": mock_undeploy}):
|
||||
# We deploy from version to no version
|
||||
@ -125,6 +128,7 @@ class TomcatTestCase(TestCase, LoaderModuleMockMixin):
|
||||
|
||||
with patch.dict(tomcat.__salt__,
|
||||
{"tomcat.ls": mock_ls_no_version,
|
||||
"tomcat.extract_war_version": tomcatmod.extract_war_version,
|
||||
"tomcat.deploy_war": mock_deploy,
|
||||
"tomcat.undeploy": mock_undeploy}):
|
||||
# Deploy from none to specified version
|
||||
@ -164,7 +168,8 @@ class TomcatTestCase(TestCase, LoaderModuleMockMixin):
|
||||
'result': True,
|
||||
'comment': 'tomcat manager is ready'}
|
||||
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)
|
||||
|
||||
def test_mod_watch(self):
|
||||
@ -176,7 +181,8 @@ class TomcatTestCase(TestCase, LoaderModuleMockMixin):
|
||||
'result': False,
|
||||
'comment': '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}})
|
||||
self.assertDictEqual(tomcat.mod_watch('salt'), ret)
|
||||
|
||||
@ -195,6 +201,7 @@ class TomcatTestCase(TestCase, LoaderModuleMockMixin):
|
||||
{'salt': {'version': 1}}])
|
||||
mock2 = MagicMock(side_effect=['FAIL', 'saltstack'])
|
||||
with patch.dict(tomcat.__salt__, {"tomcat.status": mock,
|
||||
"tomcat.extract_war_version": tomcatmod.extract_war_version,
|
||||
"tomcat.ls": mock1,
|
||||
"tomcat.undeploy": mock2}):
|
||||
ret.update({'comment': 'Tomcat Manager does not respond'})
|
||||
|
Loading…
Reference in New Issue
Block a user