mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 09:23:56 +00:00
Merge pull request #45574 from rallytime/unicode-changes-2
Add unicode_literals to more modules, states, and tests
This commit is contained in:
commit
80c9787417
@ -12,7 +12,7 @@ Module for the management of MacOS systems that use launchd/launchctl
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
import os
|
||||
import plistlib
|
||||
@ -20,6 +20,7 @@ import fnmatch
|
||||
import re
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils.data
|
||||
import salt.utils.files
|
||||
import salt.utils.path
|
||||
import salt.utils.platform
|
||||
@ -92,7 +93,9 @@ def _available_services():
|
||||
# This assumes most of the plist files
|
||||
# will be already in XML format
|
||||
with salt.utils.files.fopen(file_path):
|
||||
plist = plistlib.readPlist(true_path)
|
||||
plist = plistlib.readPlist(
|
||||
salt.utils.data.decode(true_path)
|
||||
)
|
||||
|
||||
except Exception:
|
||||
# If plistlib is unable to read the file we'll need to use
|
||||
|
@ -2,7 +2,7 @@
|
||||
'''
|
||||
Support for Layman
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import salt.utils.path
|
||||
import salt.exceptions
|
||||
|
@ -11,7 +11,7 @@ This is an alternative to the ``ldap`` interface provided by the
|
||||
:depends: - ``ldap`` Python module
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
available_backends = set()
|
||||
try:
|
||||
@ -402,8 +402,7 @@ def add(connect_spec, dn, attributes):
|
||||
# are not modified)
|
||||
attributes = dict(((attr, list(vals))
|
||||
for attr, vals in six.iteritems(attributes)))
|
||||
log.info('adding entry: dn: {0} attributes: {1}'.format(
|
||||
repr(dn), repr(attributes)))
|
||||
log.info('adding entry: dn: %s attributes: %s', repr(dn), repr(attributes))
|
||||
|
||||
if 'unicodePwd' in attributes:
|
||||
attributes['unicodePwd'] = [_format_unicode_password(x) for x in attributes['unicodePwd']]
|
||||
@ -441,7 +440,7 @@ def delete(connect_spec, dn):
|
||||
}" dn='cn=admin,dc=example,dc=com'
|
||||
'''
|
||||
l = connect(connect_spec)
|
||||
log.info('deleting entry: dn: {0}'.format(repr(dn)))
|
||||
log.info('deleting entry: dn: %s', repr(dn))
|
||||
try:
|
||||
l.c.delete_s(dn)
|
||||
except ldap.LDAPError as e:
|
||||
|
@ -39,13 +39,14 @@ Salt interface to LDAP commands
|
||||
to the same LDAP server. It's easy enough to override this behavior, but
|
||||
badness may ensue - you have been warned.
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import python libs
|
||||
import time
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
import time
|
||||
|
||||
# Import salt libs
|
||||
# Import Salt libs
|
||||
from salt.ext import six
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
# Import third party libs
|
||||
@ -143,22 +144,20 @@ def search(filter, # pylint: disable=C0103
|
||||
_ldap = _connect(**kwargs)
|
||||
start = time.time()
|
||||
log.debug(
|
||||
'Running LDAP search with filter:{0}, dn:{1}, scope:{2}, '
|
||||
'attrs:{3}'.format(
|
||||
filter, dn, scope, attrs
|
||||
)
|
||||
'Running LDAP search with filter:%s, dn:%s, scope:%s, '
|
||||
'attrs:%s', filter, dn, scope, attrs
|
||||
)
|
||||
results = _ldap.search_s(dn, int(scope), filter, attrs)
|
||||
elapsed = (time.time() - start)
|
||||
if elapsed < 0.200:
|
||||
elapsed_h = str(round(elapsed * 1000, 1)) + 'ms'
|
||||
elapsed_h = six.text_type(round(elapsed * 1000, 1)) + 'ms'
|
||||
else:
|
||||
elapsed_h = str(round(elapsed, 2)) + 's'
|
||||
elapsed_h = six.text_type(round(elapsed, 2)) + 's'
|
||||
|
||||
ret = {
|
||||
'results': results,
|
||||
'count': len(results),
|
||||
'time': {'human': elapsed_h, 'raw': str(round(elapsed, 5))},
|
||||
'time': {'human': elapsed_h, 'raw': six.text_type(round(elapsed, 5))},
|
||||
}
|
||||
return ret
|
||||
|
||||
|
@ -5,7 +5,7 @@ Support for Linux File Access Control Lists
|
||||
The Linux ACL module requires the `getfacl` and `setfacl` binaries.
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils.path
|
||||
|
@ -3,12 +3,13 @@
|
||||
The networking module for Non-RH/Deb Linux distros
|
||||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils.files
|
||||
import salt.utils.path
|
||||
import salt.utils.platform
|
||||
import salt.utils.stringutils
|
||||
|
||||
from salt.ext.six.moves import zip
|
||||
|
||||
@ -140,7 +141,7 @@ def _parse_routes():
|
||||
Parse the contents of ``/proc/net/route``
|
||||
'''
|
||||
with salt.utils.files.fopen('/proc/net/route', 'r') as fp_:
|
||||
out = fp_.read()
|
||||
out = salt.utils.stringutils.to_unicode(fp_.read())
|
||||
|
||||
ret = {}
|
||||
for line in out.splitlines():
|
||||
|
@ -2,7 +2,7 @@
|
||||
'''
|
||||
Support for Linux LVM2
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import os.path
|
||||
@ -488,7 +488,7 @@ def lvresize(size, lvpath):
|
||||
salt '*' lvm.lvresize +12M /dev/mapper/vg1-test
|
||||
'''
|
||||
ret = {}
|
||||
cmd = ['lvresize', '-L', str(size), lvpath]
|
||||
cmd = ['lvresize', '-L', six.text_type(size), lvpath]
|
||||
cmd_ret = __salt__['cmd.run_all'](cmd, python_shell=False)
|
||||
if cmd_ret['retcode'] != 0:
|
||||
return {}
|
||||
|
@ -2,20 +2,22 @@
|
||||
'''
|
||||
Module for viewing and modifying sysctl parameters
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
import os
|
||||
import re
|
||||
import string
|
||||
|
||||
# Import salt libs
|
||||
from salt.ext import six
|
||||
import salt.utils.files
|
||||
from salt.ext.six import string_types
|
||||
from salt.exceptions import CommandExecutionError
|
||||
import salt.utils.data
|
||||
import salt.utils.files
|
||||
import salt.utils.systemd
|
||||
import string
|
||||
import salt.utils.stringutils
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -72,6 +74,7 @@ def show(config_file=False):
|
||||
try:
|
||||
with salt.utils.files.fopen(config_file) as fp_:
|
||||
for line in fp_:
|
||||
line = salt.utils.stringutils.to_str(line)
|
||||
if not line.startswith('#') and '=' in line:
|
||||
# search if we have some '=' instead of ' = ' separators
|
||||
SPLIT = ' = '
|
||||
@ -120,9 +123,18 @@ def assign(name, value):
|
||||
|
||||
salt '*' sysctl.assign net.ipv4.ip_forward 1
|
||||
'''
|
||||
value = str(value)
|
||||
trantab = ''.maketrans('./', '/.') if six.PY3 else string.maketrans('./', '/.')
|
||||
sysctl_file = '/proc/sys/{0}'.format(name.translate(trantab))
|
||||
value = six.text_type(value)
|
||||
|
||||
if six.PY3:
|
||||
tran_tab = name.translate(''.maketrans('./', '/.'))
|
||||
else:
|
||||
if isinstance(name, unicode): # pylint: disable=incompatible-py3-code
|
||||
trans_args = ({ord(x): None for x in ''.join(['./', '/.'])},)
|
||||
else:
|
||||
trans_args = string.maketrans('./', '/.')
|
||||
tran_tab = name.translate(*trans_args)
|
||||
|
||||
sysctl_file = '/proc/sys/{0}'.format(tran_tab)
|
||||
if not os.path.exists(sysctl_file):
|
||||
raise CommandExecutionError('sysctl {0} does not exist'.format(name))
|
||||
|
||||
@ -137,7 +149,7 @@ def assign(name, value):
|
||||
# net.ipv4.tcp_rmem = 4096 87380 16777216
|
||||
regex = re.compile(r'^{0}\s+=\s+{1}$'.format(re.escape(name), re.escape(value)))
|
||||
|
||||
if not regex.match(out) or 'Invalid argument' in str(err):
|
||||
if not regex.match(out) or 'Invalid argument' in six.text_type(err):
|
||||
if data['retcode'] != 0 and err:
|
||||
error = err
|
||||
else:
|
||||
@ -182,7 +194,7 @@ def persist(name, value, config=None):
|
||||
# Use readlines because this should be a small file
|
||||
# and it seems unnecessary to indent the below for
|
||||
# loop since it is a fairly large block of code.
|
||||
config_data = _fh.readlines()
|
||||
config_data = salt.utils.data.decode(_fh.readlines())
|
||||
except (IOError, OSError):
|
||||
msg = 'Could not read from file: {0}'
|
||||
raise CommandExecutionError(msg.format(config))
|
||||
@ -214,9 +226,9 @@ def persist(name, value, config=None):
|
||||
continue
|
||||
if name == comps[0]:
|
||||
# This is the line to edit
|
||||
if str(comps[1]) == str(value):
|
||||
if six.text_type(comps[1]) == six.text_type(value):
|
||||
# It is correct in the config, check if it is correct in /proc
|
||||
if str(get(name)) != str(value):
|
||||
if six.text_type(get(name)) != six.text_type(value):
|
||||
assign(name, value)
|
||||
return 'Updated'
|
||||
else:
|
||||
@ -230,8 +242,8 @@ def persist(name, value, config=None):
|
||||
if not edited:
|
||||
nlines.append('{0} = {1}\n'.format(name, value))
|
||||
try:
|
||||
with salt.utils.files.fopen(config, 'w+') as _fh:
|
||||
_fh.writelines(nlines)
|
||||
with salt.utils.files.fopen(config, 'wb') as _fh:
|
||||
_fh.writelines(salt.utils.data.encode(nlines))
|
||||
except (IOError, OSError):
|
||||
msg = 'Could not write to file: {0}'
|
||||
raise CommandExecutionError(msg.format(config))
|
||||
|
@ -2,7 +2,7 @@
|
||||
'''
|
||||
Module for managing locales on POSIX-like systems.
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
@ -55,10 +55,9 @@ def _parse_dbus_locale():
|
||||
if match:
|
||||
ret[match.group(1)] = match.group(2).replace('"', '')
|
||||
else:
|
||||
log.error('Odd locale parameter "{0}" detected in dbus locale '
|
||||
log.error('Odd locale parameter "%s" detected in dbus locale '
|
||||
'output. This should not happen. You should '
|
||||
'probably investigate what caused this.'.format(
|
||||
env_var))
|
||||
'probably investigate what caused this.', env_var)
|
||||
|
||||
return ret
|
||||
|
||||
@ -95,7 +94,7 @@ def _localectl_set(locale=''):
|
||||
sure not to trample on other params that have been set.
|
||||
'''
|
||||
locale_params = _parse_dbus_locale() if HAS_DBUS else _parse_localectl()
|
||||
locale_params['LANG'] = str(locale)
|
||||
locale_params['LANG'] = six.text_type(locale)
|
||||
args = ' '.join(['{0}="{1}"'.format(k, v)
|
||||
for k, v in six.iteritems(locale_params)])
|
||||
cmd = 'localectl set-locale {0}'.format(args)
|
||||
@ -232,7 +231,7 @@ def avail(locale):
|
||||
try:
|
||||
normalized_locale = salt.utils.locales.normalize_locale(locale)
|
||||
except IndexError:
|
||||
log.error('Unable to validate locale "{0}"'.format(locale))
|
||||
log.error('Unable to validate locale "%s"', locale)
|
||||
return False
|
||||
avail_locales = __salt__['locale.list_avail']()
|
||||
locale_exists = next((True for x in avail_locales
|
||||
@ -298,7 +297,7 @@ def gen_locale(locale, **kwargs):
|
||||
|
||||
if not valid:
|
||||
log.error(
|
||||
'The provided locale "{0}" is not found in {1}'.format(locale, search))
|
||||
'The provided locale "%s" is not found in %s', locale, search)
|
||||
return False
|
||||
|
||||
if os.path.exists('/etc/locale.gen'):
|
||||
|
@ -2,7 +2,7 @@
|
||||
'''
|
||||
Module for using the locate utilities
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
|
@ -2,7 +2,7 @@
|
||||
'''
|
||||
Module for managing Solaris logadm based log rotations.
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
@ -13,9 +13,11 @@ except ImportError:
|
||||
from pipes import quote as _quote_args
|
||||
|
||||
# Import salt libs
|
||||
from salt.ext import six
|
||||
import salt.utils.args
|
||||
import salt.utils.decorators as decorators
|
||||
import salt.utils.files
|
||||
import salt.utils.stringutils
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
default_conf = '/etc/logadm.conf'
|
||||
@ -72,7 +74,7 @@ def _parse_conf(conf_file=default_conf):
|
||||
ret = {}
|
||||
with salt.utils.files.fopen(conf_file, 'r') as ifile:
|
||||
for line in ifile:
|
||||
line = line.strip()
|
||||
line = salt.utils.stringutils.to_unicode(line).strip()
|
||||
if not line:
|
||||
continue
|
||||
if line.startswith('#'):
|
||||
@ -283,7 +285,7 @@ def rotate(name, pattern=None, conf_file=default_conf, **kwargs):
|
||||
kwargs['log_file'] = name
|
||||
|
||||
## build command
|
||||
log.debug("logadm.rotate - kwargs: {}".format(kwargs))
|
||||
log.debug("logadm.rotate - kwargs: %s", kwargs)
|
||||
command = "logadm -f {}".format(conf_file)
|
||||
for arg, val in kwargs.items():
|
||||
if arg in option_toggles.values() and val:
|
||||
@ -295,10 +297,10 @@ def rotate(name, pattern=None, conf_file=default_conf, **kwargs):
|
||||
command = "{} {} {}".format(
|
||||
command,
|
||||
_arg2opt(arg),
|
||||
_quote_args(str(val))
|
||||
_quote_args(six.text_type(val))
|
||||
)
|
||||
elif arg != 'log_file':
|
||||
log.warning("Unknown argument {}, don't know how to map this!".format(arg))
|
||||
log.warning("Unknown argument %s, don't know how to map this!", arg)
|
||||
if 'log_file' in kwargs:
|
||||
# NOTE: except from ```man logadm```
|
||||
# If no log file name is provided on a logadm command line, the entry
|
||||
@ -313,7 +315,7 @@ def rotate(name, pattern=None, conf_file=default_conf, **kwargs):
|
||||
else:
|
||||
command = "{} {}".format(command, _quote_args(kwargs['log_file']))
|
||||
|
||||
log.debug("logadm.rotate - command: {}".format(command))
|
||||
log.debug("logadm.rotate - command: %s", command)
|
||||
result = __salt__['cmd.run_all'](command, python_shell=False)
|
||||
if result['retcode'] != 0:
|
||||
return dict(Error='Failed in adding log', Output=result['stderr'])
|
||||
|
@ -20,7 +20,7 @@ CLI Example:
|
||||
|
||||
salt '*' log.error 'Please dont do that, this module is not for CLI use!'
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
@ -35,36 +35,48 @@ def __virtual__():
|
||||
|
||||
|
||||
def debug(message):
|
||||
'''Log message at level DEBUG.'''
|
||||
'''
|
||||
Log message at level DEBUG.
|
||||
'''
|
||||
log.debug(message)
|
||||
return True
|
||||
|
||||
|
||||
def info(message):
|
||||
'''Log message at level INFO.'''
|
||||
'''
|
||||
Log message at level INFO.
|
||||
'''
|
||||
log.info(message)
|
||||
return True
|
||||
|
||||
|
||||
def warning(message):
|
||||
'''Log message at level WARNING.'''
|
||||
'''
|
||||
Log message at level WARNING.
|
||||
'''
|
||||
log.warning(message)
|
||||
return True
|
||||
|
||||
|
||||
def error(message):
|
||||
'''Log message at level ERROR.'''
|
||||
'''
|
||||
Log message at level ERROR.
|
||||
'''
|
||||
log.error(message)
|
||||
return True
|
||||
|
||||
|
||||
def critical(message):
|
||||
'''Log message at level CRITICAL.'''
|
||||
'''
|
||||
Log message at level CRITICAL.
|
||||
'''
|
||||
log.critical(message)
|
||||
return True
|
||||
|
||||
|
||||
def exception(message):
|
||||
'''Log message at level EXCEPTION.'''
|
||||
'''
|
||||
Log message at level EXCEPTION.
|
||||
'''
|
||||
log.exception(message)
|
||||
return True
|
||||
|
@ -2,15 +2,17 @@
|
||||
'''
|
||||
Module for managing logrotate.
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
import logging
|
||||
|
||||
# Import salt libs
|
||||
from salt.ext import six
|
||||
import salt.utils.files
|
||||
import salt.utils.platform
|
||||
import salt.utils.stringutils
|
||||
from salt.exceptions import SaltInvocationError
|
||||
|
||||
_LOG = logging.getLogger(__name__)
|
||||
@ -46,7 +48,7 @@ def _convert_if_int(value):
|
||||
:rtype: bool|int|str
|
||||
'''
|
||||
try:
|
||||
value = int(str(value))
|
||||
value = int(six.text_type(value))
|
||||
except ValueError:
|
||||
pass
|
||||
return value
|
||||
@ -69,7 +71,7 @@ def _parse_conf(conf_file=_DEFAULT_CONF):
|
||||
|
||||
with salt.utils.files.fopen(conf_file, 'r') as ifile:
|
||||
for line in ifile:
|
||||
line = line.strip()
|
||||
line = salt.utils.stringutils.to_unicode(line).strip()
|
||||
if not line:
|
||||
continue
|
||||
if line.startswith('#'):
|
||||
@ -211,7 +213,7 @@ def set_(key, value, setting=None, conf_file=_DEFAULT_CONF):
|
||||
if key in conf['include files'][include]:
|
||||
conf_file = os.path.join(conf['include'], include)
|
||||
|
||||
new_line = str()
|
||||
new_line = six.text_type()
|
||||
kwargs = {
|
||||
'flags': 8,
|
||||
'backup': False,
|
||||
|
@ -2,7 +2,7 @@
|
||||
'''
|
||||
Support for LVS (Linux Virtual Server)
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
|
||||
|
@ -9,7 +9,7 @@ lxc >= 1.0 (even beta alpha) is required
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import, print_function
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import datetime
|
||||
import copy
|
||||
import string
|
||||
@ -27,6 +27,7 @@ import random
|
||||
# Import salt libs
|
||||
import salt.utils.args
|
||||
import salt.utils.cloud
|
||||
import salt.utils.data
|
||||
import salt.utils.dictupdate
|
||||
import salt.utils.files
|
||||
import salt.utils.functools
|
||||
@ -34,6 +35,7 @@ import salt.utils.hashutils
|
||||
import salt.utils.network
|
||||
import salt.utils.odict
|
||||
import salt.utils.path
|
||||
import salt.utils.stringutils
|
||||
from salt.exceptions import CommandExecutionError, SaltInvocationError
|
||||
import salt.config
|
||||
from salt.utils.versions import LooseVersion as _LooseVersion
|
||||
@ -135,7 +137,7 @@ def _clear_context():
|
||||
Clear any lxc variables set in __context__
|
||||
'''
|
||||
for var in [x for x in __context__ if x.startswith('lxc.')]:
|
||||
log.trace('Clearing __context__[\'{0}\']'.format(var))
|
||||
log.trace('Clearing __context__[\'%s\']', var)
|
||||
__context__.pop(var, None)
|
||||
|
||||
|
||||
@ -693,7 +695,7 @@ def _rand_cpu_str(cpu):
|
||||
while len(to_set) < cpu:
|
||||
choice = random.randint(0, avail - 1)
|
||||
if choice not in to_set:
|
||||
to_set.add(str(choice))
|
||||
to_set.add(six.text_type(choice))
|
||||
return ','.join(sorted(to_set))
|
||||
|
||||
|
||||
@ -999,7 +1001,7 @@ class _LXCConfig(object):
|
||||
self.path = os.path.join(path, self.name, 'config')
|
||||
if os.path.isfile(self.path):
|
||||
with salt.utils.files.fopen(self.path) as fhr:
|
||||
for line in fhr.readlines():
|
||||
for line in salt.utils.data.decode(fhr.readlines()):
|
||||
match = self.pattern.findall((line.strip()))
|
||||
if match:
|
||||
self.data.append((match[0][0], match[0][-1]))
|
||||
@ -1039,7 +1041,7 @@ class _LXCConfig(object):
|
||||
# 2 step rendering to be sure not to open/wipe the config
|
||||
# before as_string succeeds.
|
||||
with salt.utils.files.fopen(self.path, 'w') as fic:
|
||||
fic.write(content)
|
||||
fic.write(salt.utils.stringutils.to_str(content))
|
||||
fic.flush()
|
||||
|
||||
def tempfile(self):
|
||||
@ -1748,9 +1750,9 @@ def _after_ignition_network_profile(cmd,
|
||||
|
||||
if network_changes:
|
||||
log.info(
|
||||
'Network changes from applying network profile \'{0}\' '
|
||||
'to newly-created container \'{1}\':\n{2}'
|
||||
.format(network_profile, name, network_changes)
|
||||
'Network changes from applying network profile \'%s\' '
|
||||
'to newly-created container \'%s\':\n%s',
|
||||
network_profile, name, network_changes
|
||||
)
|
||||
c_state = state(name, path=path)
|
||||
return {'result': True,
|
||||
@ -2755,7 +2757,7 @@ def info(name, path=None):
|
||||
try:
|
||||
conf_file = os.path.join(cpath, name, 'config')
|
||||
except AttributeError:
|
||||
conf_file = os.path.join(cpath, str(name), 'config')
|
||||
conf_file = os.path.join(cpath, six.text_type(name), 'config')
|
||||
|
||||
if not os.path.isfile(conf_file):
|
||||
raise CommandExecutionError(
|
||||
@ -2766,6 +2768,7 @@ def info(name, path=None):
|
||||
config = []
|
||||
with salt.utils.files.fopen(conf_file) as fp_:
|
||||
for line in fp_:
|
||||
line = salt.utils.stringutils.to_unicode(line)
|
||||
comps = [x.strip() for x in
|
||||
line.split('#', 1)[0].strip().split('=', 1)]
|
||||
if len(comps) == 2:
|
||||
@ -2838,8 +2841,7 @@ def info(name, path=None):
|
||||
else:
|
||||
# Neither was successful, give up
|
||||
log.warning(
|
||||
'Unable to run ip or ifconfig in container \'{0}\''
|
||||
.format(name)
|
||||
'Unable to run ip or ifconfig in container \'%s\'', name
|
||||
)
|
||||
ip_data = {}
|
||||
|
||||
@ -2985,7 +2987,7 @@ def update_lxc_conf(name, lxc_conf, lxc_conf_unset, path=None):
|
||||
row[conf].strip()))
|
||||
ret['comment'] = 'lxc.conf is up to date'
|
||||
lines = []
|
||||
orig_config = fic.read()
|
||||
orig_config = salt.utils.stringutils.to_unicode(fic.read())
|
||||
for line in orig_config.splitlines():
|
||||
if line.startswith('#') or not line.strip():
|
||||
lines.append([line, ''])
|
||||
@ -3035,9 +3037,9 @@ def update_lxc_conf(name, lxc_conf, lxc_conf_unset, path=None):
|
||||
# DO NOT USE salt.utils.files.fopen here, i got (kiorky)
|
||||
# problems with lxc configs which were wiped !
|
||||
with salt.utils.files.fopen('{0}.{1}'.format(lxc_conf_p, chrono), 'w') as wfic:
|
||||
wfic.write(conf)
|
||||
wfic.write(salt.utils.stringutils.to_str(conf))
|
||||
with salt.utils.files.fopen(lxc_conf_p, 'w') as wfic:
|
||||
wfic.write(conf)
|
||||
wfic.write(salt.utils.stringutils.to_str(conf))
|
||||
ret['comment'] = 'Updated'
|
||||
ret['result'] = True
|
||||
|
||||
@ -3347,8 +3349,8 @@ def wait_started(name, path=None, timeout=300):
|
||||
started = test_started(name, path=path)
|
||||
if started is None:
|
||||
logger(
|
||||
'Assuming {0} is started, although we failed to detect that'
|
||||
' is fully started correctly'.format(name))
|
||||
'Assuming %s is started, although we failed to detect that'
|
||||
' is fully started correctly', name)
|
||||
ret = True
|
||||
else:
|
||||
ret = started
|
||||
@ -3452,8 +3454,7 @@ def bootstrap(name,
|
||||
wait_started(name, path=path)
|
||||
if bootstrap_delay is not None:
|
||||
try:
|
||||
log.info('LXC {0}: bootstrap_delay: {1}'.format(
|
||||
name, bootstrap_delay))
|
||||
log.info('LXC %s: bootstrap_delay: %s', name, bootstrap_delay)
|
||||
time.sleep(bootstrap_delay)
|
||||
except TypeError:
|
||||
# Bad input, but assume since a value was passed that
|
||||
@ -3504,8 +3505,7 @@ def bootstrap(name,
|
||||
|
||||
cmd = 'install -m 0700 -d {0}'.format(configdir)
|
||||
if run(name, cmd, python_shell=False):
|
||||
log.error('tmpdir {0} creation failed ({1}'
|
||||
.format(configdir, cmd))
|
||||
log.error('tmpdir %s creation failed %s', configdir, cmd)
|
||||
return False
|
||||
|
||||
bs_ = __salt__['config.gather_bootstrap_script'](
|
||||
@ -3532,8 +3532,7 @@ def bootstrap(name,
|
||||
script))
|
||||
# log ASAP the forged bootstrap command which can be wrapped
|
||||
# out of the output in case of unexpected problem
|
||||
log.info('Running {0} in LXC container \'{1}\''
|
||||
.format(cmd, name))
|
||||
log.info('Running %s in LXC container \'%s\'', cmd, name)
|
||||
ret = retcode(name, cmd, output_loglevel='info',
|
||||
path=path, use_vt=True) == 0
|
||||
|
||||
@ -3602,7 +3601,7 @@ def attachable(name, path=None):
|
||||
_ensure_exists(name, path=path)
|
||||
# Can't use run() here because it uses attachable() and would
|
||||
# endlessly recurse, resulting in a traceback
|
||||
log.debug('Checking if LXC container {0} is attachable'.format(name))
|
||||
log.debug('Checking if LXC container %s is attachable', name)
|
||||
cmd = 'lxc-attach'
|
||||
if path:
|
||||
cmd += ' -P {0}'.format(pipes.quote(path))
|
||||
@ -4229,7 +4228,7 @@ def read_conf(conf_file, out_format='simple'):
|
||||
ret_commented = []
|
||||
ret_simple = {}
|
||||
with salt.utils.files.fopen(conf_file, 'r') as fp_:
|
||||
for line in fp_.readlines():
|
||||
for line in salt.utils.data.decode(fp_.readlines()):
|
||||
if '=' not in line:
|
||||
ret_commented.append(line)
|
||||
continue
|
||||
@ -4313,7 +4312,7 @@ def write_conf(conf_file, conf):
|
||||
content += out_line
|
||||
content += '\n'
|
||||
with salt.utils.files.fopen(conf_file, 'w') as fp_:
|
||||
fp_.write(content)
|
||||
fp_.write(salt.utils.stringutils.to_str(content))
|
||||
return {}
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ The qemu img command is wrapped for specific functions
|
||||
|
||||
:depends: qemu-img
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
|
@ -7,7 +7,7 @@ are used here to build up kvm images.
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import glob
|
||||
import tempfile
|
||||
@ -45,8 +45,7 @@ def connect(image):
|
||||
salt '*' qemu_nbd.connect /tmp/image.raw
|
||||
'''
|
||||
if not os.path.isfile(image):
|
||||
log.warning('Could not connect image: '
|
||||
'{0} does not exist'.format(image))
|
||||
log.warning('Could not connect image: %s does not exist', image)
|
||||
return ''
|
||||
|
||||
if salt.utils.path.which('sfdisk'):
|
||||
@ -65,8 +64,7 @@ def connect(image):
|
||||
if not __salt__['cmd.retcode']('{0} {1}'.format(fdisk, nbd)):
|
||||
break
|
||||
return nbd
|
||||
log.warning('Could not connect image: '
|
||||
'{0}'.format(image))
|
||||
log.warning('Could not connect image: %s', image)
|
||||
return ''
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
'''
|
||||
Module for managing quotas on POSIX-like systems.
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
|
@ -5,9 +5,11 @@ Manage and query udev info
|
||||
.. versionadded:: 2015.8.0
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils.path
|
||||
import salt.modules.cmdmod
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
@ -7,7 +7,7 @@ uWSGI stats server https://uwsgi-docs.readthedocs.io/en/latest/StatsServer.html
|
||||
:platform: all
|
||||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils.json
|
||||
|
@ -9,13 +9,14 @@ Support for Varnish
|
||||
These functions are designed to work with all implementations of Varnish
|
||||
from 3.x onwards
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
import re
|
||||
|
||||
# Import salt libs
|
||||
from salt.ext import six
|
||||
import salt.utils.path
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -49,7 +50,7 @@ def _run_varnishadm(cmd, params=(), **kwargs):
|
||||
'''
|
||||
cmd = ['varnishadm', cmd]
|
||||
cmd.extend([param for param in params if param is not None])
|
||||
log.debug('Executing: {0}'.format(' '.join(cmd)))
|
||||
log.debug('Executing: %s', ' '.join(cmd))
|
||||
return __salt__['cmd.run_all'](cmd, python_shell=False, **kwargs)
|
||||
|
||||
|
||||
@ -122,7 +123,7 @@ def param_set(param, value):
|
||||
|
||||
salt '*' varnish.param_set param value
|
||||
'''
|
||||
return _run_varnishadm('param.set', [param, str(value)])['retcode'] == 0
|
||||
return _run_varnishadm('param.set', [param, six.text_type(value)])['retcode'] == 0
|
||||
|
||||
|
||||
def param_show(param=None):
|
||||
|
@ -2,7 +2,7 @@
|
||||
'''
|
||||
VirtualBox Guest Additions installer
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import contextlib
|
||||
@ -13,6 +13,9 @@ import os
|
||||
import re
|
||||
import tempfile
|
||||
|
||||
# Import Salt libs
|
||||
from salt.ext import six
|
||||
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
__virtualname__ = 'vbox_guest'
|
||||
@ -84,7 +87,7 @@ def _return_mount_error(f):
|
||||
try:
|
||||
return f(*args, **kwargs)
|
||||
except OSError as e:
|
||||
return str(e)
|
||||
return six.text_type(e)
|
||||
return wrapper
|
||||
|
||||
|
||||
@ -126,7 +129,7 @@ def _additions_install_linux(mount_point, **kwargs):
|
||||
elif guest_os == 'fedora':
|
||||
_additions_install_fedora(**kwargs)
|
||||
else:
|
||||
log.warning("{0} is not fully supported yet.".format(guest_os))
|
||||
log.warning("%s is not fully supported yet.", guest_os)
|
||||
installer_path = _additions_install_program_path(mount_point)
|
||||
installer_ret = __salt__['cmd.run_all'](installer_path)
|
||||
if installer_ret['retcode'] in (0, 1):
|
||||
|
@ -16,7 +16,7 @@ The default for this setting is ``False``.
|
||||
:depends: virtualbox
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import re
|
||||
import os.path
|
||||
import logging
|
||||
|
@ -2,7 +2,7 @@
|
||||
'''
|
||||
Module used to access the vcenter proxy connection methods
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
|
@ -13,7 +13,7 @@ Requires an ``api_key`` in ``/etc/salt/minion``:
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import, print_function
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import datetime
|
||||
import logging
|
||||
import time
|
||||
@ -61,7 +61,7 @@ def _query(action=None,
|
||||
if routing_key:
|
||||
path += routing_key
|
||||
|
||||
log.debug('VictorOps URL: {0}'.format(path))
|
||||
log.debug('VictorOps URL: %s', path)
|
||||
|
||||
if not isinstance(args, dict):
|
||||
args = {}
|
||||
@ -201,7 +201,7 @@ def create_event(message_type=None, routing_key='everybody', **kwargs):
|
||||
data[kwarg] = kwargs[kwarg]
|
||||
else:
|
||||
# Should this faile on the wrong type.
|
||||
log.error('Wrong type, skipping {0}'.format(kwarg))
|
||||
log.error('Wrong type, skipping %s', kwarg)
|
||||
|
||||
status, result = _query(action='alert',
|
||||
routing_key=routing_key,
|
||||
|
@ -6,7 +6,7 @@ This module is used to manage Wordpress installations
|
||||
'''
|
||||
|
||||
# Import Python Modules
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import collections
|
||||
|
||||
# Import Salt Modules
|
||||
|
@ -16,7 +16,7 @@ Useful documentation:
|
||||
. https://github.com/xapi-project/xen-api/tree/master/scripts/examples/python
|
||||
. http://xenbits.xen.org/gitweb/?p=xen.git;a=tree;f=tools/python/xen/xm;hb=HEAD
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import sys
|
||||
@ -35,6 +35,7 @@ except ImportError:
|
||||
# Import salt libs
|
||||
import salt.utils.files
|
||||
import salt.utils.path
|
||||
import salt.utils.stringutils
|
||||
import salt.modules.cmdmod
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
@ -775,7 +776,7 @@ def is_hyper():
|
||||
return False
|
||||
try:
|
||||
with salt.utils.files.fopen('/proc/modules') as fp_:
|
||||
if 'xen_' not in fp_.read():
|
||||
if 'xen_' not in salt.utils.stringutils.to_unicode(fp_.read()):
|
||||
return False
|
||||
except (OSError, IOError):
|
||||
return False
|
||||
|
@ -26,7 +26,7 @@ Module for managing XFS file systems.
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
@ -36,6 +36,7 @@ import logging
|
||||
import salt.utils.files
|
||||
import salt.utils.path
|
||||
import salt.utils.platform
|
||||
import salt.utils.data
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
# Import 3rd-party libs
|
||||
@ -59,10 +60,10 @@ def _verify_run(out, cmd=None):
|
||||
'''
|
||||
if out.get("retcode", 0) and out['stderr']:
|
||||
if cmd:
|
||||
log.debug('Command: "{0}"'.format(cmd))
|
||||
log.debug('Command: "%s"', cmd)
|
||||
|
||||
log.debug('Return code: {0}'.format(out.get('retcode')))
|
||||
log.debug('Error output:\n{0}'.format(out.get('stderr', "N/A")))
|
||||
log.debug('Return code: %s', out.get('retcode'))
|
||||
log.debug('Error output:\n%s', out.get('stderr', "N/A"))
|
||||
|
||||
raise CommandExecutionError(out['stderr'])
|
||||
|
||||
@ -511,7 +512,7 @@ def _get_mounts():
|
||||
'''
|
||||
mounts = {}
|
||||
with salt.utils.files.fopen("/proc/mounts") as fhr:
|
||||
for line in fhr.readlines():
|
||||
for line in salt.utils.data.decode(fhr.readlines()):
|
||||
device, mntpnt, fstype, options, fs_freq, fs_passno = line.strip().split(" ")
|
||||
if fstype != 'xfs':
|
||||
continue
|
||||
|
@ -36,7 +36,7 @@ Module for Sending Messages via XMPP (a.k.a. Jabber)
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
import logging
|
||||
|
||||
|
@ -10,6 +10,8 @@ A state module to manage Gentoo package overlays via layman
|
||||
sunrise:
|
||||
layman.present
|
||||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def __virtual__():
|
||||
|
@ -9,11 +9,13 @@ The ``states.ldap`` state module allows you to manage LDAP entries and
|
||||
their attributes.
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import copy
|
||||
import inspect
|
||||
import logging
|
||||
|
||||
# Import Salt libs
|
||||
from salt.ext import six
|
||||
from salt.utils.odict import OrderedDict
|
||||
from salt.utils.oset import OrderedSet
|
||||
@ -344,7 +346,7 @@ def managed(name, entries, connect_spec=None):
|
||||
if len(errs):
|
||||
ret['result'] = False
|
||||
ret['comment'] = 'failed to ' \
|
||||
+ ', '.join((op + ' entry ' + dn + '(' + str(err) + ')'
|
||||
+ ', '.join((op + ' entry ' + dn + '(' + six.text_type(err) + ')'
|
||||
for op, dn, err in errs))
|
||||
|
||||
# set ret['changes']. filter out any unchanged attributes, and
|
||||
@ -521,6 +523,6 @@ def _toset(thing):
|
||||
# convert numbers to strings so that equality checks work
|
||||
# (LDAP stores numbers as strings)
|
||||
try:
|
||||
return OrderedSet((str(x) for x in thing))
|
||||
return OrderedSet((six.text_type(x) for x in thing))
|
||||
except TypeError:
|
||||
return OrderedSet((str(thing),))
|
||||
return OrderedSet((six.text_type(thing),))
|
||||
|
@ -28,19 +28,13 @@ Ensure a Linux ACL does not exist
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
|
||||
# Import salt libs
|
||||
import salt.utils.path
|
||||
|
||||
# Impot salt exceptions
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
# Import 3rd-party libs
|
||||
from salt.ext import six
|
||||
from salt.exceptions import CommandExecutionError
|
||||
import salt.utils.path
|
||||
|
||||
__virtualname__ = 'acl'
|
||||
|
||||
@ -111,13 +105,13 @@ def present(name, acl_type, acl_name='', perms='', recurse=False):
|
||||
'perms': perms},
|
||||
'old': {'acl_name': acl_name,
|
||||
'acl_type': acl_type,
|
||||
'perms': str(user[_search_name]['octal'])}}
|
||||
'perms': six.text_type(user[_search_name]['octal'])}}
|
||||
|
||||
if __opts__['test']:
|
||||
ret.update({'comment': 'Updated permissions will be applied for '
|
||||
'{0}: {1} -> {2}'.format(
|
||||
acl_name,
|
||||
str(user[_search_name]['octal']),
|
||||
six.text_type(user[_search_name]['octal']),
|
||||
perms),
|
||||
'result': None, 'pchanges': changes})
|
||||
return ret
|
||||
|
@ -18,7 +18,8 @@ Manage the available locales and the system default:
|
||||
- locale: us_locale
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import salt libs
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
@ -15,9 +15,9 @@ Management of logs using Solaris logadm.
|
||||
TODO
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
|
||||
# Import salt libs
|
||||
@ -60,28 +60,28 @@ def rotate(name, **kwargs):
|
||||
'result': None,
|
||||
'comment': ''}
|
||||
|
||||
## cleanup kwargs
|
||||
# cleanup kwargs
|
||||
kwargs = salt.utils.args.clean_kwargs(**kwargs)
|
||||
|
||||
## inject name as entryname
|
||||
# inject name as entryname
|
||||
if 'entryname' not in kwargs:
|
||||
kwargs['entryname'] = name
|
||||
|
||||
## figure out log_file and entryname
|
||||
# figure out log_file and entryname
|
||||
if 'log_file' not in kwargs or not kwargs['log_file']:
|
||||
if 'entryname' in kwargs and kwargs['entryname']:
|
||||
if kwargs['entryname'].startswith('/'):
|
||||
kwargs['log_file'] = kwargs['entryname']
|
||||
|
||||
## check for log_file
|
||||
# check for log_file
|
||||
if 'log_file' not in kwargs or not kwargs['log_file']:
|
||||
ret['result'] = False
|
||||
ret['comment'] = 'Missing log_file attribute!'
|
||||
else:
|
||||
## lookup old configuration
|
||||
# lookup old configuration
|
||||
old_config = __salt__['logadm.list_conf']()
|
||||
|
||||
## remove existing entry
|
||||
# remove existing entry
|
||||
if kwargs['log_file'] in old_config:
|
||||
res = __salt__['logadm.remove'](kwargs['entryname'] if 'entryname' in kwargs else kwargs['log_file'])
|
||||
ret['result'] = 'Error' not in res
|
||||
@ -89,7 +89,7 @@ def rotate(name, **kwargs):
|
||||
ret['comment'] = res['Error']
|
||||
ret['changes'] = {}
|
||||
|
||||
## add new entry
|
||||
# add new entry
|
||||
res = __salt__['logadm.rotate'](name, **kwargs)
|
||||
ret['result'] = 'Error' not in res
|
||||
if ret['result']:
|
||||
@ -103,8 +103,8 @@ def rotate(name, **kwargs):
|
||||
log.debug(ret['changes'])
|
||||
else:
|
||||
ret['comment'] = res['Error']
|
||||
## NOTE: we need to remove the log file first
|
||||
## potentially the log configuraiton can get lost :s
|
||||
# NOTE: we need to remove the log file first
|
||||
# potentially the log configuraiton can get lost :s
|
||||
if kwargs['log_file'] in old_config:
|
||||
ret['changes'] = {kwargs['log_file']: None}
|
||||
else:
|
||||
@ -131,10 +131,10 @@ def remove(name, log_file=None):
|
||||
'result': None,
|
||||
'comment': ''}
|
||||
|
||||
## retrieve all log configuration
|
||||
# retrieve all log configuration
|
||||
config = __salt__['logadm.list_conf']()
|
||||
|
||||
## figure out log_file and name
|
||||
# figure out log_file and name
|
||||
if not log_file:
|
||||
if name.startswith('/'):
|
||||
log_file = name
|
||||
@ -151,7 +151,7 @@ def remove(name, log_file=None):
|
||||
name = config[log]['entryname']
|
||||
break
|
||||
|
||||
## remove log if needed
|
||||
# remove log if needed
|
||||
if log_file in config:
|
||||
res = __salt__['logadm.remove'](name if name else log_file)
|
||||
ret['result'] = 'Error' not in res
|
||||
|
@ -6,9 +6,11 @@ Module for managing logrotate.
|
||||
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt libs
|
||||
from salt.ext import six
|
||||
|
||||
_DEFAULT_CONF = '/etc/logrotate.conf'
|
||||
|
||||
@ -40,7 +42,7 @@ def _convert_if_int(value):
|
||||
:rtype: bool|int|str
|
||||
'''
|
||||
try:
|
||||
value = int(str(value))
|
||||
value = int(six.text_type(value))
|
||||
except ValueError:
|
||||
pass
|
||||
return value
|
||||
@ -77,7 +79,7 @@ def set_(name, key, value, setting=None, conf_file=_DEFAULT_CONF):
|
||||
'''
|
||||
ret = {'name': name,
|
||||
'changes': dict(),
|
||||
'comment': str(),
|
||||
'comment': six.text_type(),
|
||||
'result': None}
|
||||
|
||||
try:
|
||||
|
@ -29,7 +29,7 @@ Allows for looping over execution modules.
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
import time
|
||||
|
||||
|
@ -21,7 +21,7 @@ A state module to manage LVMs
|
||||
- stripes: 5
|
||||
- stripesize: 8K
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
|
@ -4,6 +4,9 @@ Management of LVS (Linux Virtual Server) Real Server
|
||||
====================================================
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -4,6 +4,9 @@ Management of LVS (Linux Virtual Server) Service
|
||||
================================================
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -4,7 +4,7 @@ Manage Linux Containers
|
||||
=======================
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
# Import salt libs
|
||||
|
@ -12,6 +12,8 @@ The quota can be managed for the system:
|
||||
mode: off
|
||||
quotatype: user
|
||||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def __virtual__():
|
||||
|
@ -2,7 +2,7 @@
|
||||
'''
|
||||
VirtualBox Guest Additions installer state
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
|
@ -17,6 +17,9 @@ VictorOps service during state runs.
|
||||
- state_message: 'Webserver diskspace is low.'
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -5,6 +5,9 @@ This state module is used to manage Wordpress installations
|
||||
:depends: wp binary from http://wp-cli.org/
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def __virtual__():
|
||||
return 'wordpress.show_plugin' in __salt__
|
||||
|
@ -17,6 +17,9 @@ protocol
|
||||
- recipient: admins@xmpp.example.com/salt
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase
|
||||
|
@ -5,7 +5,7 @@ Test the lxc module
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.case import ModuleCase
|
||||
|
@ -4,7 +4,7 @@
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
|
@ -4,7 +4,7 @@
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import time
|
||||
|
||||
# Import Salt Testing Libs
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Import Pytohn libs
|
||||
from __future__ import absolute_import
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
|
@ -4,7 +4,7 @@
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os.path
|
||||
|
||||
# Import Salt Testing Libs
|
||||
|
@ -4,7 +4,7 @@
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Libs
|
||||
import salt.modules.linux_sysctl as linux_sysctl
|
||||
|
@ -4,7 +4,7 @@
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
|
@ -4,7 +4,7 @@
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
|
@ -4,7 +4,7 @@
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
|
@ -4,7 +4,7 @@
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.exceptions import SaltInvocationError
|
||||
|
@ -4,7 +4,7 @@
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt Testing Libs
|
||||
from tests.support.mixins import LoaderModuleMockMixin
|
||||
|
Loading…
Reference in New Issue
Block a user