Merge pull request #40690 from thor/2016.11-tomcat

Fixes #40658: even clearer and working(!) Tomcat version handling
This commit is contained in:
Mike Place 2017-04-14 04:44:01 -06:00 committed by GitHub
commit 983d35ad38
2 changed files with 11 additions and 12 deletions

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,
@ -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

@ -74,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.
@ -105,7 +105,7 @@ 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.11.0 .. versionadded:: 2016.11.0
@ -115,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
@ -123,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``.
''' '''
@ -134,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 = __salt__['tomcat.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
@ -147,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: