Merge branch '2016.11' into '2017.7'

Conflicts:
  - salt/modules/rabbitmq.py
  - salt/netapi/rest_cherrypy/app.py
  - salt/netapi/rest_tornado/saltnado.py
This commit is contained in:
rallytime 2017-08-07 09:57:03 -04:00
commit 0f75482c37
6 changed files with 36 additions and 34 deletions

View file

@ -199,7 +199,7 @@ def execute(context=None, lens=None, commands=(), load_path=None):
method = METHOD_MAP[cmd]
nargs = arg_map[method]
parts = salt.utils.shlex_split(arg)
parts = salt.utils.shlex_split(arg, posix=False)
if len(parts) not in nargs:
err = '{0} takes {1} args: {2}'.format(method, nargs, parts)

View file

@ -609,11 +609,11 @@ def set_user_tags(name, tags, runas=None):
if runas is None and not salt.utils.is_windows():
runas = salt.utils.get_user()
if tags and isinstance(tags, (list, tuple)):
tags = ' '.join(tags)
if not isinstance(tags, (list, tuple)):
tags = [tags]
res = __salt__['cmd.run_all'](
[RABBITMQCTL, 'set_user_tags', name, tags],
[RABBITMQCTL, 'set_user_tags', name] + list(tags),
runas=runas,
python_shell=False)
msg = "Tag(s) set"

View file

@ -483,13 +483,22 @@ import signal
import tarfile
from multiprocessing import Process, Pipe
logger = logging.getLogger(__name__)
# Import third-party libs
# pylint: disable=import-error
import cherrypy # pylint: disable=3rd-party-module-not-gated
# pylint: disable=import-error, 3rd-party-module-not-gated
import cherrypy
try:
from cherrypy.lib import cpstats
except ImportError:
cpstats = None
logger.warn('Import of cherrypy.cpstats failed. '
'Possible upstream bug: '
'https://github.com/cherrypy/cherrypy/issues/1444')
import yaml
import salt.ext.six as six
# pylint: enable=import-error
# pylint: enable=import-error, 3rd-party-module-not-gated
# Import Salt libs
import salt
@ -500,8 +509,6 @@ import salt.utils.event
# Import salt-api libs
import salt.netapi
logger = logging.getLogger(__name__)
# Imports related to websocket
try:
from .tools import websockets
@ -2616,13 +2623,6 @@ class Stats(object):
:status 406: |406|
'''
if hasattr(logging, 'statistics'):
# Late import
try:
from cherrypy.lib import cpstats
except ImportError:
logger.error('Import of cherrypy.cpstats failed. Possible '
'upstream bug here: https://github.com/cherrypy/cherrypy/issues/1444')
return {}
return cpstats.extrapolate_statistics(logging.statistics)
return {}
@ -2742,13 +2742,14 @@ class API(object):
'tools.trailing_slash.on': True,
'tools.gzip.on': True,
'tools.cpstats.on': self.apiopts.get('collect_stats', False),
'tools.html_override.on': True,
'tools.cors_tool.on': True,
},
}
if cpstats and self.apiopts.get('collect_stats', False):
conf['/']['tools.cpstats.on'] = True
if 'favicon' in self.apiopts:
conf['/favicon.ico'] = {
'tools.staticfile.on': True,

View file

@ -523,8 +523,7 @@ class BaseSaltAPIHandler(tornado.web.RequestHandler, SaltClientsMixIn): # pylin
try:
# Use cgi.parse_header to correctly separate parameters from value
header = cgi.parse_header(self.request.headers['Content-Type'])
value, parameters = header
value, parameters = cgi.parse_header(self.request.headers['Content-Type'])
return ct_in_map[value](tornado.escape.native_str(data))
except KeyError:
self.send_error(406)
@ -538,7 +537,7 @@ class BaseSaltAPIHandler(tornado.web.RequestHandler, SaltClientsMixIn): # pylin
if not self.request.body:
return
data = self.deserialize(self.request.body)
self.raw_data = copy(data)
self.request_payload = copy(data)
if data and 'arg' in data and not isinstance(data['arg'], list):
data['arg'] = [data['arg']]
@ -696,15 +695,13 @@ class SaltAuthHandler(BaseSaltAPIHandler): # pylint: disable=W0223
}}
'''
try:
request_payload = self.deserialize(self.request.body)
if not isinstance(request_payload, dict):
if not isinstance(self.request_payload, dict):
self.send_error(400)
return
creds = {'username': request_payload['username'],
'password': request_payload['password'],
'eauth': request_payload['eauth'],
creds = {'username': self.request_payload['username'],
'password': self.request_payload['password'],
'eauth': self.request_payload['eauth'],
}
# if any of the args are missing, its a bad request
except KeyError:
@ -1641,7 +1638,7 @@ class WebhookSaltAPIHandler(SaltAPIHandler): # pylint: disable=W0223
value = value[0]
arguments[argname] = value
ret = self.event.fire_event({
'post': self.raw_data,
'post': self.request_payload,
'get': arguments,
# In Tornado >= v4.0.3, the headers come
# back as an HTTPHeaders instance, which

View file

@ -141,10 +141,14 @@ def present(name, template_body=None, template_url=None, parameters=None, notifi
stack_policy_body = _get_template(stack_policy_body, name)
stack_policy_during_update_body = _get_template(stack_policy_during_update_body, name)
for i in [template_body, stack_policy_body, stack_policy_during_update_body]:
if isinstance(i, dict):
return i
_valid = _validate(template_body, template_url, region, key, keyid, profile)
log.debug('Validate is : {0}.'.format(_valid))
if _valid is not True:
code, message = _get_error(_valid)
code, message = _valid
ret['result'] = False
ret['comment'] = 'Template could not be validated.\n{0} \n{1}'.format(code, message)
return ret
@ -250,7 +254,7 @@ def _get_template(template, name):
def _validate(template_body=None, template_url=None, region=None, key=None, keyid=None, profile=None):
# Validates template. returns true if template syntax is correct.
validate = __salt__['boto_cfn.validate_template'](template_body, template_url, region, key, keyid, profile)
log.debug('Validate is result is {0}.'.format(str(validate)))
log.debug('Validate result is {0}.'.format(str(validate)))
if isinstance(validate, str):
code, message = _get_error(validate)
log.debug('Validate error is {0} and message is {1}.'.format(code, message))

View file

@ -46,9 +46,9 @@ class SaltYamlSafeLoader(yaml.SafeLoader, object):
self.add_constructor(
u'tag:yaml.org,2002:omap',
type(self).construct_yaml_map)
self.add_constructor(
u'tag:yaml.org,2002:python/unicode',
type(self).construct_unicode)
self.add_constructor(
u'tag:yaml.org,2002:python/unicode',
type(self).construct_unicode)
self.dictclass = dictclass
def construct_yaml_map(self, node):