Merge remote-tracking branch 'upstream/2015.5' into merge-forward-2015.8

Conflicts:
    salt/fileclient.py
    salt/states/blockdev.py
This commit is contained in:
Colton Myers 2015-11-12 11:06:00 -07:00
commit 5aeab71f76
3 changed files with 45 additions and 22 deletions

View file

@ -481,7 +481,7 @@ def get_saved_rules(conf_file=None, family='ipv4'):
IPv6:
salt '*' iptables.get_saved_rules family=ipv6
'''
return _parse_conf(conf_file, family)
return _parse_conf(conf_file=conf_file, family=family)
def get_rules(family='ipv4'):

View file

@ -680,7 +680,7 @@ def lowdata_fmt():
# if the data was sent as urlencoded, we need to make it a list.
# this is a very forgiving implementation as different clients set different
# headers for form encoded data (including charset or something similar)
if not isinstance(data, list):
if data and not isinstance(data, list):
# Make the 'arg' param a list if not already
if 'arg' in data and not isinstance(data['arg'], list):
data['arg'] = [data['arg']]
@ -1180,6 +1180,7 @@ class Keys(LowDataAdapter):
module <salt.wheel.key>` functions.
'''
@cherrypy.config(**{'tools.salt_token.on': True})
def GET(self, mid=None):
'''
Show the list of minion keys or detail on a specific key
@ -1247,8 +1248,6 @@ class Keys(LowDataAdapter):
minions:
jerry: 51:93:b3:d0:9f:3a:6d:e5:28:67:c2:4b:27:d6:cd:2b
'''
self._cp_config['tools.salt_token.on'] = True
if mid:
lowstate = [{
'client': 'wheel',
@ -1266,6 +1265,7 @@ class Keys(LowDataAdapter):
return {'return': next(result, {}).get('data', {}).get('return', {})}
@cherrypy.config(**{'tools.hypermedia_out.on': False, 'tools.sessions.on': False})
def POST(self, mid, keysize=None, force=None, **kwargs):
r'''
Easily generate keys for a minion and auto-accept the new key
@ -1326,9 +1326,6 @@ class Keys(LowDataAdapter):
jerry.pub0000644000000000000000000000070300000000000010730 0ustar 00000000000000
'''
self._cp_config['tools.hypermedia_out.on'] = False
self._cp_config['tools.sessions.on'] = False
lowstate = [{
'client': 'wheel',
'fun': 'key.gen_accept',
@ -2212,7 +2209,9 @@ class Webhook(object):
'''
tag = '/'.join(itertools.chain(self.tag_base, args))
data = cherrypy.serving.request.unserialized_data
raw_body = cherrypy.serving.request.raw_body
if not data:
data = {}
raw_body = getattr(cherrypy.serving.request, 'raw_body', '')
headers = dict(cherrypy.request.headers)
ret = self.event.fire_event({

View file

@ -25,12 +25,17 @@ from __future__ import absolute_import
# Import python libs
import os
import os.path
import time
import logging
# Import salt libs
import salt.utils
__virtualname__ = 'blockdev'
# Init logger
log = logging.getLogger(__name__)
def __virtual__():
'''
@ -130,12 +135,7 @@ def formatted(name, fs_type='ext4', **kwargs):
ret['comment'] = '{0} does not exist'.format(name)
return ret
blk = __salt__['cmd.run']('lsblk -o fstype {0}'.format(name)).splitlines()
if len(blk) == 1:
current_fs = ''
else:
current_fs = blk[1]
current_fs = _checkblk(name)
if current_fs == fs_type:
ret['result'] = True
@ -152,12 +152,36 @@ def formatted(name, fs_type='ext4', **kwargs):
__salt__['blockdev.format'](name, fs_type, **kwargs)
current_fs = __salt__['blockdev.fstype'](name)
if current_fs == fs_type:
ret['comment'] = ('{0} has been formatted '
'with {1}').format(name, fs_type)
ret['changes'] = {'new': fs_type, 'old': current_fs}
ret['result'] = True
else:
ret['comment'] = 'Failed to format {0}'.format(name)
ret['result'] = False
# Repeat lsblk check up to 10 times with 3s sleeping between each
# to avoid lsblk failing although mkfs has succeeded
# see https://github.com/saltstack/salt/issues/25775
for i in range(10):
log.info('Check blk fstype attempt %s of 10', str(i+1))
current_fs = _checkblk(name)
if current_fs == fs_type:
ret['comment'] = ('{0} has been formatted '
'with {1}').format(name, fs_type)
ret['changes'] = {'new': fs_type, 'old': current_fs}
ret['result'] = True
return ret
if current_fs == '':
log.info('Waiting 3s before next check')
time.sleep(3)
else:
break
ret['comment'] = 'Failed to format {0}'.format(name)
ret['result'] = False
return ret
def _checkblk(name):
'''
Check if the blk exists and return its fstype if ok
'''
blk = __salt__['cmd.run']('lsblk -o fstype {0}'.format(name)).splitlines()
return '' if len(blk) == 1 else blk[1]