mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Merge pull request #30750 from jfindlay/war_version
extract whole war version
This commit is contained in:
commit
2415b3e62e
@ -63,11 +63,11 @@ Also configure a user in the conf/tomcat-users.xml file:
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
import re
|
||||
import glob
|
||||
import hashlib
|
||||
import tempfile
|
||||
import os
|
||||
import re
|
||||
import logging
|
||||
|
||||
# Import 3rd-party libs
|
||||
@ -175,12 +175,23 @@ def _auth(uri):
|
||||
return _build_opener(basic, digest)
|
||||
|
||||
|
||||
def _extract_version(war):
|
||||
def _extract_war_version(war):
|
||||
'''
|
||||
extract the version from the war name
|
||||
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
|
||||
<https://tomcat.apache.org/tomcat-6.0-doc/deployer-howto.html>`_.
|
||||
|
||||
Examples:
|
||||
|
||||
.. code-block::
|
||||
|
||||
/path/salt-2015.8.6.war -> 2015.8.6
|
||||
/path/V6R2013xD5.war -> V6R2013xD5
|
||||
'''
|
||||
version = re.findall("-([\\d.-]+)$", os.path.basename(war).replace('.war', ''))
|
||||
return version[0] if len(version) == 1 else None
|
||||
basename = os.path.basename(war)
|
||||
war_package = os.path.splitext(basename)[0] # remove '.war'
|
||||
version = re.findall("-([\\d.-]+)$", war_package) # try semver
|
||||
return version[0] if version and len(version) == 1 else war_package # default to whole name
|
||||
|
||||
|
||||
def _wget(cmd, opts=None, url='http://localhost:8080/manager', timeout=180):
|
||||
@ -514,7 +525,8 @@ def deploy_war(war,
|
||||
saltenv='base',
|
||||
timeout=180,
|
||||
env=None,
|
||||
temp_war_location=None):
|
||||
temp_war_location=None,
|
||||
version=''):
|
||||
'''
|
||||
Deploy a WAR file
|
||||
|
||||
@ -535,6 +547,17 @@ def deploy_war(war,
|
||||
temp_war_location : None
|
||||
use another location to temporarily copy to war file
|
||||
by default the system's temp directory is used
|
||||
version : ''
|
||||
Specify the war version. If this argument is provided, it overrides
|
||||
the version encoded in the war file name, if one is present.
|
||||
|
||||
Examples:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
salt '*' tomcat.deploy_war salt://salt-2015.8.6.war version=2015.08.r6
|
||||
|
||||
.. versionadded:: 2015.8.6
|
||||
|
||||
CLI Examples:
|
||||
|
||||
@ -586,13 +609,11 @@ def deploy_war(war,
|
||||
else:
|
||||
tfile = war
|
||||
|
||||
version_string = _extract_version(war)
|
||||
|
||||
# Prepare options
|
||||
opts = {
|
||||
'war': 'file:{0}'.format(tfile),
|
||||
'path': context,
|
||||
'version': version_string,
|
||||
'version': version or _extract_war_version(war),
|
||||
}
|
||||
if force == 'yes':
|
||||
opts['update'] = 'true'
|
||||
|
@ -43,7 +43,7 @@ Notes:
|
||||
from __future__ import absolute_import
|
||||
|
||||
# import salt libs
|
||||
from salt.modules.tomcat import _extract_version
|
||||
from salt.modules.tomcat import _extract_war_version
|
||||
|
||||
|
||||
# Private
|
||||
@ -61,7 +61,8 @@ def war_deployed(name,
|
||||
force=False,
|
||||
url='http://localhost:8080/manager',
|
||||
timeout=180,
|
||||
temp_war_location=None):
|
||||
temp_war_location=None,
|
||||
version=''):
|
||||
'''
|
||||
Enforce that the WAR will be deployed and started in the context path
|
||||
it will make use of WAR versions
|
||||
@ -83,6 +84,11 @@ def war_deployed(name,
|
||||
temp_war_location : None
|
||||
use another location to temporarily copy to war file
|
||||
by default the system's temp directory is used
|
||||
version : ''
|
||||
Specify the war version. If this argument is provided, it overrides
|
||||
the version encoded in the war file name, if one is present.
|
||||
|
||||
.. versionadded:: 2015.8.6
|
||||
|
||||
Example:
|
||||
|
||||
@ -100,9 +106,9 @@ def war_deployed(name,
|
||||
'result': True,
|
||||
'changes': {},
|
||||
'comment': ''}
|
||||
basename = war.split('/')[-1]
|
||||
|
||||
version = _extract_version(basename)
|
||||
if not version:
|
||||
version = _extract_war_version(war)
|
||||
|
||||
webapps = __salt__['tomcat.ls'](url, timeout)
|
||||
deploy = False
|
||||
|
Loading…
Reference in New Issue
Block a user