mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 17:09:03 +00:00
Add unicode_literals to modules, states, tests (I)
This commit is contained in:
parent
ab63da4f35
commit
9effd08bb3
@ -8,7 +8,7 @@ Module to provide icinga2 compatibility to salt.
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
import subprocess
|
||||
|
||||
|
@ -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 logging
|
||||
import time
|
||||
|
||||
|
@ -4,14 +4,17 @@ Manage HP ILO
|
||||
|
||||
:depends: hponcfg (SmartStart Scripting Toolkit Linux Edition)
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
|
||||
from salt._compat import ElementTree as ET
|
||||
import salt.utils.path
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
import os
|
||||
import tempfile
|
||||
|
||||
import logging
|
||||
# Import Salt libs
|
||||
from salt._compat import ElementTree as ET
|
||||
from salt.ext import six
|
||||
import salt.utils.path
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -37,7 +40,7 @@ def __execute_cmd(name, xml):
|
||||
if not os.path.isdir(tmp_dir):
|
||||
os.mkdir(tmp_dir)
|
||||
with tempfile.NamedTemporaryFile(dir=tmp_dir,
|
||||
prefix=name+str(os.getpid()),
|
||||
prefix=name + six.text_type(os.getpid()),
|
||||
suffix='.xml',
|
||||
delete=False) as fh:
|
||||
tmpfilename = fh.name
|
||||
@ -59,7 +62,7 @@ def __execute_cmd(name, xml):
|
||||
# Make sure dict keys don't collide
|
||||
if ret[name.replace('_', ' ')].get(i.tag, False):
|
||||
ret[name.replace('_', ' ')].update(
|
||||
{i.tag + '_' + str(id_num): i.attrib}
|
||||
{i.tag + '_' + six.text_type(id_num): i.attrib}
|
||||
)
|
||||
id_num += 1
|
||||
else:
|
||||
|
@ -2,16 +2,18 @@
|
||||
'''
|
||||
Work with incron
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
import os
|
||||
|
||||
# Import salt libs
|
||||
from salt.ext import six
|
||||
from salt.ext.six.moves import range
|
||||
import salt.utils.files
|
||||
import salt.utils.functools
|
||||
from salt.ext.six.moves import range
|
||||
import salt.utils.stringutils
|
||||
|
||||
# Set up logging
|
||||
log = logging.getLogger(__name__)
|
||||
@ -103,7 +105,7 @@ def _write_incron_lines(user, lines):
|
||||
else:
|
||||
path = salt.utils.files.mkstemp()
|
||||
with salt.utils.files.fopen(path, 'w+') as fp_:
|
||||
fp_.writelines(lines)
|
||||
fp_.writelines(salt.utils.stringutils.to_str(lines))
|
||||
if __grains__['os_family'] == 'Solaris' and user != "root":
|
||||
__salt__['cmd.run']('chown {0} {1}'.format(user, path), python_shell=False)
|
||||
ret = __salt__['cmd.run_all'](_get_incron_cmdstr(path), runas=user, python_shell=False)
|
||||
@ -117,12 +119,11 @@ def _write_file(folder, filename, data):
|
||||
'''
|
||||
path = os.path.join(folder, filename)
|
||||
if not os.path.exists(folder):
|
||||
msg = '{0} cannot be written. {1} does not exist'
|
||||
msg = msg.format(filename, folder)
|
||||
msg = '%s cannot be written. %s does not exist', filename, folder
|
||||
log.error(msg)
|
||||
raise AttributeError(msg)
|
||||
raise AttributeError(six.text_type(msg))
|
||||
with salt.utils.files.fopen(path, 'w') as fp_:
|
||||
fp_.write(data)
|
||||
fp_.write(salt.utils.stringutils.to_str(data))
|
||||
|
||||
return 0
|
||||
|
||||
@ -134,7 +135,7 @@ def _read_file(folder, filename):
|
||||
path = os.path.join(folder, filename)
|
||||
try:
|
||||
with salt.utils.files.fopen(path, 'rb') as contents:
|
||||
return contents.readlines()
|
||||
return salt.utils.stringutils.to_unicode(contents.readlines())
|
||||
except (OSError, IOError):
|
||||
return ''
|
||||
|
||||
@ -225,7 +226,7 @@ def set_job(user, path, mask, cmd):
|
||||
salt '*' incron.set_job root '/root' 'IN_MODIFY' 'echo "$$ $@ $# $% $&"'
|
||||
'''
|
||||
# Scrub the types
|
||||
mask = str(mask).upper()
|
||||
mask = six.text_type(mask).upper()
|
||||
|
||||
# Check for valid mask types
|
||||
for item in mask.split(','):
|
||||
@ -288,7 +289,7 @@ def rm_job(user,
|
||||
'''
|
||||
|
||||
# Scrub the types
|
||||
mask = str(mask).upper()
|
||||
mask = six.text_type(mask).upper()
|
||||
|
||||
# Check for valid mask types
|
||||
for item in mask.split(','):
|
||||
|
@ -27,7 +27,7 @@ version 0.9+)
|
||||
would override ``user`` and ``password`` while still using the defaults for
|
||||
``host`` and ``port``.
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
try:
|
||||
import influxdb
|
||||
@ -125,7 +125,7 @@ def create_db(name, **client_args):
|
||||
salt '*' influxdb.create_db <name>
|
||||
'''
|
||||
if db_exists(name, **client_args):
|
||||
log.info('DB \'{0}\' already exists'.format(name))
|
||||
log.info('DB \'%s\' already exists', name)
|
||||
return False
|
||||
|
||||
client = _client(**client_args)
|
||||
@ -148,7 +148,7 @@ def drop_db(name, **client_args):
|
||||
salt '*' influxdb.drop_db <name>
|
||||
'''
|
||||
if not db_exists(name, **client_args):
|
||||
log.info('DB \'{0}\' does not exist'.format(name))
|
||||
log.info('DB \'%s\' does not exist', name)
|
||||
return False
|
||||
|
||||
client = _client(**client_args)
|
||||
@ -235,7 +235,7 @@ def create_user(name, password, admin=False, **client_args):
|
||||
salt '*' influxdb.create_user <name> <password> admin=True
|
||||
'''
|
||||
if user_exists(name, **client_args):
|
||||
log.info("User '{0}' already exists".format(name))
|
||||
log.info("User '%s' already exists", name)
|
||||
return False
|
||||
|
||||
client = _client(**client_args)
|
||||
@ -261,7 +261,7 @@ def set_user_password(name, password, **client_args):
|
||||
salt '*' influxdb.set_user_password <name> <password>
|
||||
'''
|
||||
if not user_exists(name, **client_args):
|
||||
log.info('User \'{0}\' does not exist'.format(name))
|
||||
log.info('User \'%s\' does not exist', name)
|
||||
return False
|
||||
|
||||
client = _client(**client_args)
|
||||
@ -322,7 +322,7 @@ def remove_user(name, **client_args):
|
||||
salt '*' influxdb.remove_user <name>
|
||||
'''
|
||||
if not user_exists(name, **client_args):
|
||||
log.info('User \'{0}\' does not exist'.format(name))
|
||||
log.info('User \'%s\' does not exist', name)
|
||||
return False
|
||||
|
||||
client = _client(**client_args)
|
||||
|
@ -23,7 +23,7 @@ version 0.5-0.8)
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
try:
|
||||
import influxdb.influxdb08
|
||||
@ -149,7 +149,7 @@ def db_create(name, user=None, password=None, host=None, port=None):
|
||||
salt '*' influxdb08.db_create <name> <user> <password> <host> <port>
|
||||
'''
|
||||
if db_exists(name, user, password, host, port):
|
||||
log.info('DB \'{0}\' already exists'.format(name))
|
||||
log.info('DB \'%s\' already exists', name)
|
||||
return False
|
||||
client = _client(user=user, password=password, host=host, port=port)
|
||||
client.create_database(name)
|
||||
@ -183,7 +183,7 @@ def db_remove(name, user=None, password=None, host=None, port=None):
|
||||
salt '*' influxdb08.db_remove <name> <user> <password> <host> <port>
|
||||
'''
|
||||
if not db_exists(name, user, password, host, port):
|
||||
log.info('DB \'{0}\' does not exist'.format(name))
|
||||
log.info('DB \'%s\' does not exist', name)
|
||||
return False
|
||||
client = _client(user=user, password=password, host=host, port=port)
|
||||
return client.delete_database(name)
|
||||
@ -321,10 +321,9 @@ def user_create(name,
|
||||
'''
|
||||
if user_exists(name, database, user, password, host, port):
|
||||
if database:
|
||||
log.info('User \'{0}\' already exists for DB \'{1}\''.format(
|
||||
name, database))
|
||||
log.info('User \'%s\' already exists for DB \'%s\'', name, database)
|
||||
else:
|
||||
log.info('Cluster admin \'{0}\' already exists'.format(name))
|
||||
log.info('Cluster admin \'%s\' already exists', name)
|
||||
return False
|
||||
|
||||
client = _client(user=user, password=password, host=host, port=port)
|
||||
@ -380,14 +379,9 @@ def user_chpass(name,
|
||||
'''
|
||||
if not user_exists(name, database, user, password, host, port):
|
||||
if database:
|
||||
log.info(
|
||||
'User \'{0}\' does not exist for DB \'{1}\''.format(
|
||||
name,
|
||||
database
|
||||
)
|
||||
)
|
||||
log.info('User \'%s\' does not exist for DB \'%s\'', name, database)
|
||||
else:
|
||||
log.info('Cluster admin \'{0}\' does not exist'.format(name))
|
||||
log.info('Cluster admin \'%s\' does not exist', name)
|
||||
return False
|
||||
|
||||
client = _client(user=user, password=password, host=host, port=port)
|
||||
@ -442,13 +436,9 @@ def user_remove(name,
|
||||
'''
|
||||
if not user_exists(name, database, user, password, host, port):
|
||||
if database:
|
||||
log.info(
|
||||
'User \'{0}\' does not exist for DB \'{1}\''.format(
|
||||
name, database
|
||||
)
|
||||
)
|
||||
log.info('User \'%s\' does not exist for DB \'%s\'', name, database)
|
||||
else:
|
||||
log.info('Cluster admin \'{0}\' does not exist'.format(name))
|
||||
log.info('Cluster admin \'%s\' does not exist', name)
|
||||
return False
|
||||
|
||||
client = _client(user=user, password=password, host=host, port=port)
|
||||
|
@ -32,15 +32,19 @@ API documents can be found on your infoblox server at:
|
||||
api_key=passs
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import time
|
||||
|
||||
# Import Salt libs
|
||||
from salt.ext import six
|
||||
|
||||
|
||||
IMPORT_ERR = None
|
||||
try:
|
||||
import libinfoblox
|
||||
except Exception as ex:
|
||||
IMPORT_ERR = str(ex)
|
||||
except Exception as exc:
|
||||
IMPORT_ERR = six.text_type(exc)
|
||||
__virtualname__ = 'infoblox'
|
||||
|
||||
|
||||
|
@ -10,13 +10,14 @@ Edit ini files
|
||||
(for example /etc/sysctl.conf)
|
||||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import re
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils.files
|
||||
import salt.utils.json
|
||||
import salt.utils.stringutils
|
||||
from salt.exceptions import CommandExecutionError
|
||||
from salt.utils.odict import OrderedDict
|
||||
|
||||
@ -286,7 +287,7 @@ class _Section(OrderedDict):
|
||||
value = sect
|
||||
value_plain = value.as_dict()
|
||||
else:
|
||||
value = str(value)
|
||||
value = six.text_type(value)
|
||||
value_plain = value
|
||||
|
||||
if key not in self:
|
||||
@ -341,7 +342,7 @@ class _Section(OrderedDict):
|
||||
return dict(self)
|
||||
|
||||
def dump(self):
|
||||
print(str(self))
|
||||
print(six.text_type(self))
|
||||
|
||||
def __repr__(self, _repr_running=None):
|
||||
_repr_running = _repr_running or {}
|
||||
@ -368,7 +369,7 @@ class _Ini(_Section):
|
||||
if inicontents is None:
|
||||
try:
|
||||
with salt.utils.files.fopen(self.name) as rfh:
|
||||
inicontents = rfh.read()
|
||||
inicontents = salt.utils.stringutils.to_unicode(rfh.read())
|
||||
except (OSError, IOError) as exc:
|
||||
if __opts__['test'] is False:
|
||||
raise CommandExecutionError(
|
||||
@ -397,7 +398,7 @@ class _Ini(_Section):
|
||||
with salt.utils.files.fopen(self.name, 'w') as outfile:
|
||||
ini_gen = self.gen_ini()
|
||||
next(ini_gen)
|
||||
outfile.writelines(ini_gen)
|
||||
outfile.writelines(salt.utils.stringutils.to_str(ini_gen))
|
||||
except (OSError, IOError) as exc:
|
||||
raise CommandExecutionError(
|
||||
"Unable to write file '{0}'. "
|
||||
|
@ -17,7 +17,7 @@
|
||||
'''
|
||||
Module for full system inspection.
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
import os
|
||||
import getpass
|
||||
@ -26,6 +26,7 @@ from salt.modules.inspectlib.exceptions import (InspectorQueryException,
|
||||
InspectorKiwiProcessorException)
|
||||
|
||||
# Import Salt libs
|
||||
from salt.ext import six
|
||||
import salt.utils.fsutils
|
||||
import salt.utils.platform
|
||||
from salt.exceptions import CommandExecutionError
|
||||
@ -57,7 +58,7 @@ def _(module):
|
||||
mod = importlib.import_module("salt.modules.inspectlib.{0}".format(module))
|
||||
except ImportError as err:
|
||||
# No importlib around (2.6)
|
||||
mod = getattr(__import__("salt.modules.inspectlib", globals(), locals(), fromlist=[str(module)]), module)
|
||||
mod = getattr(__import__("salt.modules.inspectlib", globals(), locals(), fromlist=[six.text_type(module)]), module)
|
||||
# pylint: enable=E0598
|
||||
|
||||
mod.__grains__ = __grains__
|
||||
@ -267,7 +268,7 @@ def delete(all=False, *databases):
|
||||
inspector = _("collector").Inspector(cachedir=__opts__['cachedir'],
|
||||
piddir=os.path.dirname(__opts__['pidfile']))
|
||||
for dbid in all and inspector.db.list() or databases:
|
||||
ret[dbid] = inspector.db._db.purge(str(dbid))
|
||||
ret[dbid] = inspector.db._db.purge(six.text_type(dbid))
|
||||
return ret
|
||||
except InspectorSnapshotException as err:
|
||||
raise CommandExecutionError(err)
|
||||
|
@ -5,7 +5,7 @@ usable by Salt States
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
|
||||
# Import 3rd-party libs
|
||||
|
@ -32,7 +32,10 @@ systems hardware through IPMI drivers. It uses a python module `pyghmi`.
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt libs
|
||||
from salt.ext import six
|
||||
|
||||
|
||||
IMPORT_ERR = None
|
||||
@ -40,7 +43,7 @@ try:
|
||||
from pyghmi.ipmi import command
|
||||
from pyghmi.ipmi.private import session
|
||||
except Exception as ex:
|
||||
IMPORT_ERR = str(ex)
|
||||
IMPORT_ERR = six.text_type(ex)
|
||||
|
||||
__virtualname__ = 'ipmi'
|
||||
|
||||
@ -73,7 +76,6 @@ class _IpmiCommand(object):
|
||||
o = None
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
#cache_key = api_host + api_user + str(api_port)
|
||||
config = _get_config(**kwargs)
|
||||
self.o = command.Command(bmc=config['api_host'], userid=config['api_user'],
|
||||
password=config['api_pass'], port=config['api_port'],
|
||||
@ -95,7 +97,6 @@ class _IpmiSession(object):
|
||||
raise Exception(response['error'])
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
#cache_key = api_host + api_user + str(api_port)
|
||||
config = _get_config(**kwargs)
|
||||
self.o = session.Session(bmc=config['api_host'],
|
||||
userid=config['api_user'],
|
||||
|
@ -4,7 +4,7 @@ Support for ipset
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
|
||||
# Import Salt libs
|
||||
@ -458,7 +458,6 @@ def check(set=None, entry=None, family='ipv4'):
|
||||
for current_member in current_members:
|
||||
for entry in entries:
|
||||
if _member_contains(current_member, entry):
|
||||
# print "{0} contains {1}".format(current_member, entry)
|
||||
return True
|
||||
|
||||
return False
|
||||
@ -521,10 +520,8 @@ def flush(set=None, family='ipv4'):
|
||||
|
||||
ipset_family = _IPSET_FAMILIES[family]
|
||||
if set:
|
||||
# cmd = '{0} flush {1} family {2}'.format(_ipset_cmd(), set, ipset_family)
|
||||
cmd = '{0} flush {1}'.format(_ipset_cmd(), set)
|
||||
else:
|
||||
# cmd = '{0} flush family {1}'.format(_ipset_cmd(), ipset_family)
|
||||
cmd = '{0} flush'.format(_ipset_cmd())
|
||||
out = __salt__['cmd.run'](cmd, python_shell=False)
|
||||
|
||||
|
@ -3,8 +3,11 @@
|
||||
Support for Wireless Tools for Linux
|
||||
'''
|
||||
|
||||
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
|
||||
from salt.exceptions import SaltInvocationError
|
||||
|
||||
|
@ -20,11 +20,13 @@ Its output may be stored in a file or in a grain.
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os.path
|
||||
|
||||
# Import Salt libs
|
||||
from salt.ext import six
|
||||
import salt.utils.files
|
||||
import salt.utils.stringutils
|
||||
|
||||
|
||||
def __virtual__():
|
||||
@ -103,7 +105,7 @@ def generate_ticket(name, output=None, grain=None, key=None, overwrite=True):
|
||||
# Executing the command.
|
||||
ticket = __salt__['icinga2.generate_ticket'](name).strip()
|
||||
if ticket:
|
||||
ret['comment'] = str(ticket)
|
||||
ret['comment'] = six.text_type(ticket)
|
||||
|
||||
if output == 'grain':
|
||||
if grain and not key:
|
||||
@ -120,7 +122,7 @@ def generate_ticket(name, output=None, grain=None, key=None, overwrite=True):
|
||||
elif output:
|
||||
ret['changes']['ticket'] = "Executed. Output into {0}".format(output)
|
||||
with salt.utils.files.fopen(output, 'w') as output_file:
|
||||
output_file.write(str(ticket))
|
||||
output_file.write(salt.utils.stringutils.to_str(ticket))
|
||||
else:
|
||||
ret['changes']['ticket'] = "Executed"
|
||||
|
||||
|
@ -24,6 +24,9 @@ The api key can be specified in the master or minion configuration like below:
|
||||
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -41,6 +41,8 @@ then a new cron job will be added to the user's crontab.
|
||||
.. versionadded:: 0.17.0
|
||||
|
||||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def _check_cron(user,
|
||||
|
@ -9,6 +9,9 @@ Management of Influxdb 0.8 databases
|
||||
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -9,6 +9,9 @@ Management of InfluxDB 0.8 users
|
||||
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -8,6 +8,9 @@ Management of Influxdb continuous queries
|
||||
(compatible with InfluxDB version 0.9+)
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -6,6 +6,9 @@ Management of Influxdb databases
|
||||
(compatible with InfluxDB version 0.9+)
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -8,6 +8,9 @@ Management of Influxdb retention policies
|
||||
(compatible with InfluxDB version 0.9+)
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -6,6 +6,9 @@ Management of InfluxDB users
|
||||
(compatible with InfluxDB version 0.9+)
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def __virtual__():
|
||||
'''
|
||||
|
@ -10,6 +10,9 @@ functions accept api_opts:
|
||||
api_password: [default to pillar value]
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def present(name=None, ipv4addr=None, data=None, ensure_data=True, **api_opts):
|
||||
'''
|
||||
|
@ -10,6 +10,9 @@ functions accept api_opts:
|
||||
api_password: [default to pillar value]
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def present(name=None, data=None, ensure_data=True, **api_opts):
|
||||
'''
|
||||
|
@ -10,6 +10,9 @@ functions accept api_opts:
|
||||
api_password: [default to pillar value]
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def present(name=None, data=None, ensure_data=True, **api_opts):
|
||||
'''
|
||||
|
@ -10,6 +10,9 @@ functions accept api_opts:
|
||||
api_password: [default to pillar value]
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
def present(name=None, start_addr=None, end_addr=None, data=None, **api_opts):
|
||||
'''
|
||||
|
@ -11,7 +11,7 @@ Manage ini files
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt libs
|
||||
from salt.ext import six
|
||||
@ -65,7 +65,7 @@ def options_present(name, sections=None, separator='=', strict=False):
|
||||
return ret
|
||||
for key in sections[section]:
|
||||
cur_value = cur_section.get(key)
|
||||
if cur_value == str(sections[section][key]):
|
||||
if cur_value == six.text_type(sections[section][key]):
|
||||
ret['comment'] += 'Key {0}{1} unchanged.\n'.format(key, section_name)
|
||||
continue
|
||||
ret['comment'] += 'Changed key {0}{1}.\n'.format(key, section_name)
|
||||
|
@ -36,15 +36,17 @@ Every call can override the config defaults:
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Salt libs
|
||||
from salt.ext import six
|
||||
|
||||
def __virtual__():
|
||||
IMPORT_ERR = None
|
||||
try:
|
||||
from pyghmi.ipmi import command
|
||||
except Exception as ex:
|
||||
IMPORT_ERR = str(ex)
|
||||
except Exception as exc:
|
||||
IMPORT_ERR = six.text_type(exc)
|
||||
return (IMPORT_ERR is None, IMPORT_ERR)
|
||||
|
||||
|
||||
|
@ -52,9 +52,9 @@ in IPTables Firewalls.
|
||||
ipset.flush:
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -276,7 +276,7 @@ def absent(name, entry=None, entries=None, family='ipv4', **kwargs):
|
||||
entry_opts = '{0} comment "{1}"'.format(entry_opts, kwargs['comment'])
|
||||
_entry = ' '.join([entry, entry_opts]).strip()
|
||||
|
||||
log.debug('_entry {0}'.format(_entry))
|
||||
log.debug('_entry %s', _entry)
|
||||
if not __salt__['ipset.check'](kwargs['set_name'],
|
||||
_entry,
|
||||
family) is True:
|
||||
|
@ -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.unit import TestCase, skipIf
|
||||
|
@ -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 tempfile
|
||||
|
||||
@ -121,7 +121,7 @@ class IniManageTestCase(TestCase):
|
||||
'SectionB': {'test3': 'new value 3B'},
|
||||
})
|
||||
with salt.utils.files.fopen(self.tfile.name, 'r') as fp:
|
||||
file_content = fp.read()
|
||||
file_content = salt.utils.stringutils.to_unicode(fp.read())
|
||||
expected = '{0}{1}{0}'.format(os.linesep, 'empty_option = ')
|
||||
self.assertIn(expected, file_content, 'empty_option was not preserved')
|
||||
|
||||
@ -156,7 +156,7 @@ class IniManageTestCase(TestCase):
|
||||
''
|
||||
])
|
||||
with salt.utils.files.fopen(self.tfile.name, 'r') as fp:
|
||||
file_content = fp.read()
|
||||
file_content = salt.utils.stringutils.to_unicode(fp.read())
|
||||
self.assertEqual(expected, file_content)
|
||||
|
||||
def test_empty_lines_preserved_after_multiple_edits(self):
|
||||
|
@ -17,7 +17,7 @@
|
||||
:codeauthor: :email:`Bo Maryniuk <bo@suse.de>`
|
||||
'''
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
|
||||
# Import Salt Testing Libs
|
||||
|
@ -19,7 +19,7 @@
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import io
|
||||
|
||||
# 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 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
|
||||
|
@ -3,7 +3,7 @@
|
||||
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
||||
'''
|
||||
# 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
|
||||
|
@ -3,7 +3,7 @@
|
||||
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
||||
'''
|
||||
# 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
|
||||
|
@ -3,7 +3,7 @@
|
||||
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
||||
'''
|
||||
# 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
|
||||
|
@ -3,7 +3,7 @@
|
||||
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
||||
'''
|
||||
# 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
|
||||
|
@ -3,7 +3,7 @@
|
||||
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
||||
'''
|
||||
# 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
|
||||
|
@ -3,7 +3,7 @@
|
||||
:codeauthor: :email:`Jayesh Kariya <jayeshk@saltstack.com>`
|
||||
'''
|
||||
# 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