mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Merge pull request #19538 from rallytime/bp-19368
Backport #19368 to 2014.7
This commit is contained in:
commit
c6bd6971d2
@ -57,7 +57,7 @@ def tune(device, **kwargs):
|
||||
else:
|
||||
opts += '--{0} {1} '.format(switch, kwargs[key])
|
||||
cmd = 'blockdev {0}{1}'.format(opts, device)
|
||||
out = __salt__['cmd.run'](cmd).splitlines()
|
||||
out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
|
||||
return dump(device, args)
|
||||
|
||||
|
||||
@ -74,7 +74,7 @@ def wipe(device):
|
||||
|
||||
cmd = 'wipefs {0}'.format(device)
|
||||
try:
|
||||
out = __salt__['cmd.run_all'](cmd)
|
||||
out = __salt__['cmd.run_all'](cmd, python_shell=False)
|
||||
except subprocess.CalledProcessError as err:
|
||||
return False
|
||||
if out['retcode'] == 0:
|
||||
@ -93,7 +93,7 @@ def dump(device, args=None):
|
||||
cmd = 'blockdev --getro --getsz --getss --getpbsz --getiomin --getioopt --getalignoff --getmaxsect --getsize --getsize64 --getra --getfra {0}'.format(device)
|
||||
ret = {}
|
||||
opts = [c[2:] for c in cmd.split() if c.startswith('--')]
|
||||
out = __salt__['cmd.run_all'](cmd)
|
||||
out = __salt__['cmd.run_all'](cmd, python_shell=False)
|
||||
if out['retcode'] == 0:
|
||||
lines = [line for line in out['stdout'].splitlines() if line]
|
||||
count = 0
|
||||
|
@ -146,7 +146,10 @@ def install(dir,
|
||||
if optimize is True:
|
||||
cmd += ' --optimize-autoloader'
|
||||
|
||||
result = __salt__['cmd.run_all'](cmd, runas=runas, env={'COMPOSER_HOME': composer_home})
|
||||
result = __salt__['cmd.run_all'](cmd,
|
||||
runas=runas,
|
||||
env={'COMPOSER_HOME': composer_home},
|
||||
python_shell=False)
|
||||
|
||||
if result['retcode'] != 0:
|
||||
raise CommandExecutionError(result['stderr'])
|
||||
|
@ -59,7 +59,7 @@ def start(name):
|
||||
'''
|
||||
__salt__['file.remove']('{0}/down'.format(_service_path(name)))
|
||||
cmd = 'svc -u {0}'.format(_service_path(name))
|
||||
return not __salt__['cmd.retcode'](cmd)
|
||||
return not __salt__['cmd.retcode'](cmd, python_shell=False)
|
||||
|
||||
|
||||
#-- states.service compatible args
|
||||
@ -75,7 +75,7 @@ def stop(name):
|
||||
'''
|
||||
__salt__['file.touch']('{0}/down'.format(_service_path(name)))
|
||||
cmd = 'svc -d {0}'.format(_service_path(name))
|
||||
return not __salt__['cmd.retcode'](cmd)
|
||||
return not __salt__['cmd.retcode'](cmd, python_shell=False)
|
||||
|
||||
|
||||
def term(name):
|
||||
@ -89,7 +89,7 @@ def term(name):
|
||||
salt '*' daemontools.term <service name>
|
||||
'''
|
||||
cmd = 'svc -t {0}'.format(_service_path(name))
|
||||
return not __salt__['cmd.retcode'](cmd)
|
||||
return not __salt__['cmd.retcode'](cmd, python_shell=False)
|
||||
|
||||
|
||||
#-- states.service compatible
|
||||
@ -149,7 +149,7 @@ def status(name, sig=None):
|
||||
salt '*' daemontools.status <service name>
|
||||
'''
|
||||
cmd = 'svstat {0}'.format(_service_path(name))
|
||||
out = __salt__['cmd.run_stdout'](cmd)
|
||||
out = __salt__['cmd.run_stdout'](cmd, python_shell=False)
|
||||
try:
|
||||
pid = re.search(r'\(pid (\d+)\)', out).group(1)
|
||||
except AttributeError:
|
||||
|
@ -103,7 +103,7 @@ def _set_file(path):
|
||||
'''
|
||||
cmd = 'debconf-set-selections {0}'.format(path)
|
||||
|
||||
__salt__['cmd.run_stdout'](cmd)
|
||||
__salt__['cmd.run_stdout'](cmd, python_shell=False)
|
||||
|
||||
|
||||
def set_(package, question, type, value, *extra):
|
||||
|
@ -210,7 +210,7 @@ def blkid(device=None):
|
||||
args = " " + device
|
||||
|
||||
ret = {}
|
||||
for line in __salt__['cmd.run_stdout']('blkid' + args).split('\n'):
|
||||
for line in __salt__['cmd.run_stdout'](('blkid' + args).split('\n'), python_shell=False):
|
||||
comps = line.split()
|
||||
device = comps[0][:-1]
|
||||
info = {}
|
||||
|
@ -64,7 +64,7 @@ def command(settings_module,
|
||||
for key, value in kwargs.items():
|
||||
if not key.startswith('__'):
|
||||
cmd = '{0} --{1}={2}'.format(cmd, key, value)
|
||||
return __salt__['cmd.run'](cmd, env=env)
|
||||
return __salt__['cmd.run'](cmd, env=env, python_shell=False)
|
||||
|
||||
|
||||
def syncdb(settings_module,
|
||||
|
@ -67,7 +67,7 @@ def list_pkgs(*packages):
|
||||
'''
|
||||
pkgs = {}
|
||||
cmd = 'dpkg -l {0}'.format(' '.join(packages))
|
||||
out = __salt__['cmd.run_all'](cmd)
|
||||
out = __salt__['cmd.run_all'](cmd, python_shell=False)
|
||||
if out['retcode'] != 0:
|
||||
msg = 'Error: ' + out['stderr']
|
||||
log.error(msg)
|
||||
@ -99,7 +99,7 @@ def file_list(*packages):
|
||||
ret = set([])
|
||||
pkgs = {}
|
||||
cmd = 'dpkg -l {0}'.format(' '.join(packages))
|
||||
out = __salt__['cmd.run_all'](cmd)
|
||||
out = __salt__['cmd.run_all'](cmd, python_shell=False)
|
||||
if out['retcode'] != 0:
|
||||
msg = 'Error: ' + out['stderr']
|
||||
log.error(msg)
|
||||
@ -116,7 +116,7 @@ def file_list(*packages):
|
||||
for pkg in pkgs:
|
||||
files = []
|
||||
cmd = 'dpkg -L {0}'.format(pkg)
|
||||
for line in __salt__['cmd.run'](cmd).splitlines():
|
||||
for line in __salt__['cmd.run'](cmd, python_shell=False).splitlines():
|
||||
files.append(line)
|
||||
fileset = set(files)
|
||||
ret = ret.union(fileset)
|
||||
@ -141,7 +141,7 @@ def file_dict(*packages):
|
||||
ret = {}
|
||||
pkgs = {}
|
||||
cmd = 'dpkg -l {0}'.format(' '.join(packages))
|
||||
out = __salt__['cmd.run_all'](cmd)
|
||||
out = __salt__['cmd.run_all'](cmd, python_shell=False)
|
||||
if out['retcode'] != 0:
|
||||
msg = 'Error: ' + out['stderr']
|
||||
log.error(msg)
|
||||
@ -158,7 +158,7 @@ def file_dict(*packages):
|
||||
for pkg in pkgs:
|
||||
files = []
|
||||
cmd = 'dpkg -L {0}'.format(pkg)
|
||||
for line in __salt__['cmd.run'](cmd).splitlines():
|
||||
for line in __salt__['cmd.run'](cmd, python_shell=False).splitlines():
|
||||
files.append(line)
|
||||
ret[pkg] = files
|
||||
return {'errors': errors, 'packages': ret}
|
||||
|
@ -97,7 +97,7 @@ def mkfs(device, fs_type, **kwargs):
|
||||
else:
|
||||
opts += '-{0} {1} '.format(opt, kwargs[key])
|
||||
cmd = 'mke2fs -F -t {0} {1}{2}'.format(fs_type, opts, device)
|
||||
out = __salt__['cmd.run'](cmd).splitlines()
|
||||
out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
|
||||
ret = []
|
||||
for line in out:
|
||||
if not line:
|
||||
@ -182,7 +182,7 @@ def tune(device, **kwargs):
|
||||
else:
|
||||
opts += '-{0} {1} '.format(opt, kwargs[key])
|
||||
cmd = 'tune2fs {0}{1}'.format(opts, device)
|
||||
out = __salt__['cmd.run'](cmd).splitlines()
|
||||
out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
|
||||
return out
|
||||
|
||||
|
||||
@ -228,7 +228,7 @@ def dump(device, args=None):
|
||||
if args:
|
||||
cmd = cmd + ' -' + args
|
||||
ret = {'attributes': {}, 'blocks': {}}
|
||||
out = __salt__['cmd.run'](cmd).splitlines()
|
||||
out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
|
||||
mode = 'opts'
|
||||
group = None
|
||||
for line in out:
|
||||
|
@ -76,7 +76,7 @@ def get(name):
|
||||
salt '*' sysctl.get hw.physmem
|
||||
'''
|
||||
cmd = 'sysctl -n {0}'.format(name)
|
||||
out = __salt__['cmd.run'](cmd)
|
||||
out = __salt__['cmd.run'](cmd, python_shell=False)
|
||||
return out
|
||||
|
||||
|
||||
@ -92,7 +92,7 @@ def assign(name, value):
|
||||
'''
|
||||
ret = {}
|
||||
cmd = 'sysctl {0}="{1}"'.format(name, value)
|
||||
data = __salt__['cmd.run_all'](cmd)
|
||||
data = __salt__['cmd.run_all'](cmd, python_shell=False)
|
||||
|
||||
if data['retcode'] != 0:
|
||||
raise CommandExecutionError('sysctl failed: {0}'.format(
|
||||
|
@ -64,7 +64,7 @@ def _get_rcvar(name):
|
||||
|
||||
cmd = '{0} {1} rcvar'.format(_cmd(), name)
|
||||
|
||||
for line in __salt__['cmd.run_stdout'](cmd).splitlines():
|
||||
for line in __salt__['cmd.run_stdout'](cmd, python_path=False).splitlines():
|
||||
if '_enable="' not in line:
|
||||
continue
|
||||
rcvar, _ = line.split('=', 1)
|
||||
@ -228,7 +228,7 @@ def enabled(name):
|
||||
|
||||
cmd = '{0} {1} rcvar'.format(_cmd(), name)
|
||||
|
||||
for line in __salt__['cmd.run_stdout'](cmd).splitlines():
|
||||
for line in __salt__['cmd.run_stdout'](cmd, python_shell=False).splitlines():
|
||||
if '_enable="' not in line:
|
||||
continue
|
||||
_, state, _ = line.split('"', 2)
|
||||
@ -308,7 +308,7 @@ def start(name):
|
||||
salt '*' service.start <service name>
|
||||
'''
|
||||
cmd = '{0} {1} onestart'.format(_cmd(), name)
|
||||
return not __salt__['cmd.retcode'](cmd)
|
||||
return not __salt__['cmd.retcode'](cmd, python_shell=False)
|
||||
|
||||
|
||||
def stop(name):
|
||||
@ -322,7 +322,7 @@ def stop(name):
|
||||
salt '*' service.stop <service name>
|
||||
'''
|
||||
cmd = '{0} {1} onestop'.format(_cmd(), name)
|
||||
return not __salt__['cmd.retcode'](cmd)
|
||||
return not __salt__['cmd.retcode'](cmd, python_shell=False)
|
||||
|
||||
|
||||
def restart(name):
|
||||
@ -336,7 +336,7 @@ def restart(name):
|
||||
salt '*' service.restart <service name>
|
||||
'''
|
||||
cmd = '{0} {1} onerestart'.format(_cmd(), name)
|
||||
return not __salt__['cmd.retcode'](cmd)
|
||||
return not __salt__['cmd.retcode'](cmd, python_shell=False)
|
||||
|
||||
|
||||
def reload_(name):
|
||||
@ -350,7 +350,7 @@ def reload_(name):
|
||||
salt '*' service.reload <service name>
|
||||
'''
|
||||
cmd = '{0} {1} onereload'.format(_cmd(), name)
|
||||
return not __salt__['cmd.retcode'](cmd)
|
||||
return not __salt__['cmd.retcode'](cmd, python_shell=False)
|
||||
|
||||
|
||||
def status(name, sig=None):
|
||||
@ -369,4 +369,4 @@ def status(name, sig=None):
|
||||
if sig:
|
||||
return bool(__salt__['status.pid'](sig))
|
||||
cmd = '{0} {1} onestatus'.format(_cmd(), name)
|
||||
return not __salt__['cmd.retcode'](cmd)
|
||||
return not __salt__['cmd.retcode'](cmd, python_shell=False)
|
||||
|
@ -30,6 +30,7 @@ class DjangoModuleTest(integration.ModuleCase):
|
||||
django.command('settings.py', 'runserver')
|
||||
mock.assert_called_once_with(
|
||||
'django-admin.py runserver --settings=settings.py',
|
||||
python_shell=False,
|
||||
env=None
|
||||
)
|
||||
|
||||
@ -49,6 +50,7 @@ class DjangoModuleTest(integration.ModuleCase):
|
||||
mock.assert_called_once_with(
|
||||
'django-admin.py runserver --settings=settings.py '
|
||||
'--noinput --somethingelse',
|
||||
python_shell=False,
|
||||
env=None
|
||||
)
|
||||
|
||||
@ -66,6 +68,7 @@ class DjangoModuleTest(integration.ModuleCase):
|
||||
mock.assert_called_once_with(
|
||||
'django-admin.py runserver --settings=settings.py '
|
||||
'--database=something',
|
||||
python_shell=False,
|
||||
env=None
|
||||
)
|
||||
|
||||
@ -78,6 +81,7 @@ class DjangoModuleTest(integration.ModuleCase):
|
||||
)
|
||||
mock.assert_called_once_with(
|
||||
'django-admin.py runserver --settings=settings.py',
|
||||
python_shell=False,
|
||||
env=None
|
||||
)
|
||||
|
||||
@ -88,6 +92,7 @@ class DjangoModuleTest(integration.ModuleCase):
|
||||
django.syncdb('settings.py')
|
||||
mock.assert_called_once_with(
|
||||
'django-admin.py syncdb --settings=settings.py --noinput',
|
||||
python_shell=False,
|
||||
env=None
|
||||
)
|
||||
|
||||
@ -99,6 +104,7 @@ class DjangoModuleTest(integration.ModuleCase):
|
||||
mock.assert_called_once_with(
|
||||
'django-admin.py syncdb --settings=settings.py --migrate '
|
||||
'--noinput',
|
||||
python_shell=False,
|
||||
env=None
|
||||
)
|
||||
|
||||
@ -112,6 +118,7 @@ class DjangoModuleTest(integration.ModuleCase):
|
||||
mock.assert_called_once_with(
|
||||
'django-admin.py createsuperuser --settings=settings.py '
|
||||
'--noinput --username=testuser --email=user@example.com',
|
||||
python_shell=False,
|
||||
env=None
|
||||
)
|
||||
|
||||
@ -134,7 +141,9 @@ class DjangoModuleTest(integration.ModuleCase):
|
||||
mock.assert_called_once_with(
|
||||
'django-admin.py collectstatic --settings=settings.py '
|
||||
'--noinput --no-post-process --dry-run --clear --link '
|
||||
'--no-default-ignore --ignore=something', env=None
|
||||
'--no-default-ignore --ignore=something',
|
||||
python_shell=False,
|
||||
env=None
|
||||
)
|
||||
|
||||
|
||||
|
@ -24,7 +24,8 @@ class TestBlockdevModule(TestCase):
|
||||
mock.assert_called_once_with(
|
||||
'blockdev --getro --getsz --getss --getpbsz --getiomin '
|
||||
'--getioopt --getalignoff --getmaxsect --getsize '
|
||||
'--getsize64 --getra --getfra /dev/sda'
|
||||
'--getsize64 --getra --getfra /dev/sda',
|
||||
python_shell=False
|
||||
)
|
||||
|
||||
def test_wipe(self):
|
||||
@ -32,7 +33,8 @@ class TestBlockdevModule(TestCase):
|
||||
with patch.dict(blockdev.__salt__, {'cmd.run_all': mock}):
|
||||
blockdev.wipe('/dev/sda')
|
||||
mock.assert_called_once_with(
|
||||
'wipefs /dev/sda'
|
||||
'wipefs /dev/sda',
|
||||
python_shell=False
|
||||
)
|
||||
|
||||
def test_tune(self):
|
||||
@ -43,7 +45,8 @@ class TestBlockdevModule(TestCase):
|
||||
kwargs = {'read-ahead': 512, 'filesystem-read-ahead': 512}
|
||||
blockdev.tune('/dev/sda', **kwargs)
|
||||
mock.assert_called_once_with(
|
||||
'blockdev --setra 512 --setfra 512 /dev/sda'
|
||||
'blockdev --setra 512 --setfra 512 /dev/sda',
|
||||
python_shell=False
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user