mirror of
https://github.com/valitydev/salt.git
synced 2024-11-07 00:55:19 +00:00
Merge branch 'oxygen' into scheduler_cron_tests
This commit is contained in:
commit
ba7ff8b2e0
2
.gitignore
vendored
2
.gitignore
vendored
@ -94,6 +94,8 @@ tests/integration/cloud/providers/pki/minions
|
||||
/.tox/
|
||||
|
||||
# Kitchen tests files
|
||||
.kitchen.local.yml
|
||||
.kitchen/
|
||||
.bundle/
|
||||
Gemfile.lock
|
||||
/artifacts/
|
||||
|
31
.kitchen.yml
31
.kitchen.yml
@ -3,6 +3,7 @@
|
||||
<% version = '2017.7.1' %>
|
||||
<% platformsfile = ENV['SALT_KITCHEN_PLATFORMS'] || '.kitchen/platforms.yml' %>
|
||||
<% driverfile = ENV['SALT_KITCHEN_DRIVER'] || '.kitchen/driver.yml' %>
|
||||
<% verifierfile = ENV['SALT_KITCHEN_VERIFIER'] || '.kitchen/verifier.yml' %>
|
||||
|
||||
<% if File.exists?(driverfile) %>
|
||||
<%= ERB.new(File.read(driverfile)).result %>
|
||||
@ -52,7 +53,6 @@ provisioner:
|
||||
base:
|
||||
"*":
|
||||
- git.salt
|
||||
- kitchen
|
||||
<% if File.exists?(platformsfile) %>
|
||||
<%= ERB.new(File.read(platformsfile)).result %>
|
||||
<% else %>
|
||||
@ -156,6 +156,8 @@ platforms:
|
||||
<% end %>
|
||||
suites:
|
||||
- name: py2
|
||||
verifier:
|
||||
python_bin: python2.7
|
||||
provisioner:
|
||||
pillars:
|
||||
top.sls:
|
||||
@ -170,6 +172,8 @@ suites:
|
||||
excludes:
|
||||
- centos-6
|
||||
- ubuntu-14.04
|
||||
verifier:
|
||||
python_bin: python3
|
||||
provisioner:
|
||||
pillars:
|
||||
top.sls:
|
||||
@ -181,12 +185,23 @@ suites:
|
||||
clone_repo: false
|
||||
py3: true
|
||||
salttesting_namespec: salttesting==2017.6.1
|
||||
verifier:
|
||||
name: shell
|
||||
remote_exec: true
|
||||
live_stream: {}
|
||||
<% if ENV['TESTOPTS'].nil? %>
|
||||
command: 'sudo -E $(kitchen) /tmp/kitchen/testing/tests/runtests.py -v --run-destructive --sysinfo --transport=zeromq --output-columns=80 --ssh --coverage-xml=/tmp/coverage.xml --xml=/tmp/xml-unittests-output'
|
||||
|
||||
<% if File.exists?(verifierfile) %>
|
||||
<%= ERB.new(File.read(verifierfile)).result %>
|
||||
<% else %>
|
||||
command: 'sudo -E $(kitchen) /tmp/kitchen/testing/tests/runtests.py -v --run-destructive --output-columns 80 <%= ENV["TESTOPTS"] %>'
|
||||
verifier:
|
||||
name: runtests
|
||||
sudo: true
|
||||
verbose: true
|
||||
run_destructive: true
|
||||
transport: zeromq
|
||||
types:
|
||||
- ssh
|
||||
xml: /tmp/xml-unittests-output/
|
||||
coverage_xml: /tmp/coverage.xml
|
||||
save:
|
||||
/tmp/xml-unittests-output: artifacts/
|
||||
/tmp/coverage.xml: artifacts/coverage/coverage.xml
|
||||
/var/log/salt/minion: artifacts/logs/minion
|
||||
/tmp/salt-runtests.log: artifacts/logs/salt-runtests.log
|
||||
<% end %>
|
||||
|
2
Gemfile
2
Gemfile
@ -2,7 +2,7 @@
|
||||
|
||||
source 'https://rubygems.org'
|
||||
|
||||
gem 'test-kitchen'
|
||||
gem 'test-kitchen', :git => 'https://github.com/test-kitchen/test-kitchen.git'
|
||||
gem 'kitchen-salt', :git => 'https://github.com/saltstack/kitchen-salt.git'
|
||||
gem 'kitchen-sync'
|
||||
gem 'git'
|
||||
|
@ -40,7 +40,7 @@ Use the following Pg database schema:
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
from contextlib import contextmanager
|
||||
import sys
|
||||
|
||||
@ -93,7 +93,7 @@ def _conn(commit=False):
|
||||
yield cursor
|
||||
except psycopg2.DatabaseError as err:
|
||||
error = err.args
|
||||
sys.stderr.write(str(error))
|
||||
sys.stderr.write(six.text_type(error))
|
||||
cursor.execute("ROLLBACK")
|
||||
raise err
|
||||
else:
|
||||
@ -107,7 +107,7 @@ def _conn(commit=False):
|
||||
|
||||
def _list_tables(cur):
|
||||
cmd = "select relname from pg_class where relkind='r' and relname !~ '^(pg_|sql_)';"
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
cur.execute(cmd)
|
||||
result = cur.fetchall()
|
||||
return [x[0] for x in result]
|
||||
@ -116,7 +116,7 @@ def _list_tables(cur):
|
||||
def _create_table(cur, queue):
|
||||
cmd = 'CREATE TABLE {0}(id SERIAL PRIMARY KEY, '\
|
||||
'data jsonb NOT NULL)'.format(queue)
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
cur.execute(cmd)
|
||||
return True
|
||||
|
||||
@ -127,7 +127,7 @@ def _list_items(queue):
|
||||
'''
|
||||
with _conn() as cur:
|
||||
cmd = 'SELECT data FROM {0}'.format(queue)
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
cur.execute(cmd)
|
||||
contents = cur.fetchall()
|
||||
return contents
|
||||
@ -174,8 +174,7 @@ def _queue_exists(queue):
|
||||
def handle_queue_creation(queue):
|
||||
if not _queue_exists(queue):
|
||||
with _conn(commit=True) as cur:
|
||||
log.debug('Queue %s does not exist.'
|
||||
' Creating', queue)
|
||||
log.debug('Queue %s does not exist. Creating', queue)
|
||||
_create_table(cur, queue)
|
||||
else:
|
||||
log.debug('Queue %s already exists.', queue)
|
||||
@ -191,7 +190,7 @@ def insert(queue, items):
|
||||
if isinstance(items, dict):
|
||||
items = salt.utils.json.dumps(items)
|
||||
cmd = str('''INSERT INTO {0}(data) VALUES('{1}')''').format(queue, items) # future lint: disable=blacklisted-function
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
try:
|
||||
cur.execute(cmd)
|
||||
except psycopg2.IntegrityError as esc:
|
||||
@ -200,7 +199,7 @@ def insert(queue, items):
|
||||
if isinstance(items, list):
|
||||
items = [(salt.utils.json.dumps(el),) for el in items]
|
||||
cmd = str("INSERT INTO {0}(data) VALUES (%s)").format(queue) # future lint: disable=blacklisted-function
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
try:
|
||||
cur.executemany(cmd, items)
|
||||
except psycopg2.IntegrityError as esc:
|
||||
@ -218,13 +217,13 @@ def delete(queue, items):
|
||||
cmd = str("""DELETE FROM {0} WHERE data = '{1}'""").format( # future lint: disable=blacklisted-function
|
||||
queue,
|
||||
salt.utils.json.dumps(items))
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
cur.execute(cmd)
|
||||
return True
|
||||
if isinstance(items, list):
|
||||
items = [(salt.utils.json.dumps(el),) for el in items]
|
||||
cmd = 'DELETE FROM {0} WHERE data = %s'.format(queue)
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
cur.executemany(cmd, items)
|
||||
return True
|
||||
|
||||
@ -242,7 +241,7 @@ def pop(queue, quantity=1, is_runner=False):
|
||||
'Error: "{0}".'.format(exc))
|
||||
raise SaltInvocationError(error_txt)
|
||||
cmd = ''.join([cmd, ' LIMIT {0};'.format(quantity)])
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
items = []
|
||||
with _conn(commit=True) as cur:
|
||||
cur.execute(cmd)
|
||||
@ -254,7 +253,7 @@ def pop(queue, quantity=1, is_runner=False):
|
||||
del_cmd = '''DELETE FROM {0} WHERE id IN ('{1}');'''.format(
|
||||
queue, idlist)
|
||||
|
||||
log.debug('SQL Query: {0}'.format(del_cmd))
|
||||
log.debug('SQL Query: %s', del_cmd)
|
||||
|
||||
cur.execute(del_cmd)
|
||||
return items
|
||||
|
@ -13,7 +13,7 @@ to another location::
|
||||
sqlite_queue_dir: /home/myuser/salt/master/queues
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import, print_function
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import glob
|
||||
import logging
|
||||
import os
|
||||
@ -43,7 +43,7 @@ def _conn(queue):
|
||||
'''
|
||||
queue_dir = __opts__['sqlite_queue_dir']
|
||||
db = os.path.join(queue_dir, '{0}.db'.format(queue))
|
||||
log.debug('Connecting to: {0}'.format(db))
|
||||
log.debug('Connecting to: %s', db)
|
||||
|
||||
con = sqlite3.connect(db)
|
||||
tables = _list_tables(con)
|
||||
@ -56,7 +56,7 @@ def _list_tables(con):
|
||||
with con:
|
||||
cur = con.cursor()
|
||||
cmd = 'SELECT name FROM sqlite_master WHERE type = "table"'
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
cur.execute(cmd)
|
||||
result = cur.fetchall()
|
||||
return [x[0] for x in result]
|
||||
@ -67,7 +67,7 @@ def _create_table(con, queue):
|
||||
cur = con.cursor()
|
||||
cmd = 'CREATE TABLE {0}(id INTEGER PRIMARY KEY, '\
|
||||
'name TEXT UNIQUE)'.format(queue)
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
cur.execute(cmd)
|
||||
return True
|
||||
|
||||
@ -80,7 +80,7 @@ def _list_items(queue):
|
||||
with con:
|
||||
cur = con.cursor()
|
||||
cmd = 'SELECT name FROM {0}'.format(queue)
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
cur.execute(cmd)
|
||||
contents = cur.fetchall()
|
||||
return contents
|
||||
@ -144,7 +144,7 @@ def insert(queue, items):
|
||||
if isinstance(items, six.string_types):
|
||||
items = _quote_escape(items)
|
||||
cmd = '''INSERT INTO {0}(name) VALUES('{1}')'''.format(queue, items)
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
try:
|
||||
cur.execute(cmd)
|
||||
except sqlite3.IntegrityError as esc:
|
||||
@ -153,7 +153,7 @@ def insert(queue, items):
|
||||
if isinstance(items, list):
|
||||
items = [_quote_escape(el) for el in items]
|
||||
cmd = "INSERT INTO {0}(name) VALUES(?)".format(queue)
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
newitems = []
|
||||
for item in items:
|
||||
newitems.append((item,))
|
||||
@ -167,7 +167,7 @@ def insert(queue, items):
|
||||
items = salt.utils.json.dumps(items).replace('"', "'")
|
||||
items = _quote_escape(items)
|
||||
cmd = str('''INSERT INTO {0}(name) VALUES('{1}')''').format(queue, items) # future lint: disable=blacklisted-function
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
try:
|
||||
cur.execute(cmd)
|
||||
except sqlite3.IntegrityError as esc:
|
||||
@ -186,13 +186,13 @@ def delete(queue, items):
|
||||
if isinstance(items, six.string_types):
|
||||
items = _quote_escape(items)
|
||||
cmd = """DELETE FROM {0} WHERE name = '{1}'""".format(queue, items)
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
cur.execute(cmd)
|
||||
return True
|
||||
if isinstance(items, list):
|
||||
items = [_quote_escape(el) for el in items]
|
||||
cmd = 'DELETE FROM {0} WHERE name = ?'.format(queue)
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
newitems = []
|
||||
for item in items:
|
||||
newitems.append((item,))
|
||||
@ -202,7 +202,7 @@ def delete(queue, items):
|
||||
items = salt.utils.json.dumps(items).replace('"', "'")
|
||||
items = _quote_escape(items)
|
||||
cmd = ("""DELETE FROM {0} WHERE name = '{1}'""").format(queue, items) # future lint: disable=blacklisted-function
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
cur.execute(cmd)
|
||||
return True
|
||||
return True
|
||||
@ -221,7 +221,7 @@ def pop(queue, quantity=1, is_runner=False):
|
||||
'Error: "{0}".'.format(exc))
|
||||
raise SaltInvocationError(error_txt)
|
||||
cmd = ''.join([cmd, ' LIMIT {0}'.format(quantity)])
|
||||
log.debug('SQL Query: {0}'.format(cmd))
|
||||
log.debug('SQL Query: %s', cmd)
|
||||
con = _conn(queue)
|
||||
items = []
|
||||
with con:
|
||||
@ -234,7 +234,7 @@ def pop(queue, quantity=1, is_runner=False):
|
||||
del_cmd = '''DELETE FROM {0} WHERE name IN ("{1}")'''.format(
|
||||
queue, itemlist)
|
||||
|
||||
log.debug('SQL Query: {0}'.format(del_cmd))
|
||||
log.debug('SQL Query: %s', del_cmd)
|
||||
|
||||
cur.execute(del_cmd)
|
||||
con.commit()
|
||||
|
@ -5,7 +5,7 @@ hit from the master rather than acting as an independent entity. This covers
|
||||
hitting minions without zeromq in place via an ssh agent, and connecting to
|
||||
systems that cannot or should not host a minion agent.
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import salt libs
|
||||
import salt.loader
|
||||
@ -13,7 +13,7 @@ import salt.syspaths
|
||||
|
||||
import os
|
||||
import logging
|
||||
from salt.ext.six import string_types
|
||||
from salt.ext import six
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
@ -68,7 +68,7 @@ class Roster(object):
|
||||
self.opts = opts
|
||||
if isinstance(backends, list):
|
||||
self.backends = backends
|
||||
elif isinstance(backends, string_types):
|
||||
elif isinstance(backends, six.string_types):
|
||||
self.backends = backends.split(',')
|
||||
else:
|
||||
self.backends = backends
|
||||
@ -104,9 +104,9 @@ class Roster(object):
|
||||
try:
|
||||
targets.update(self.rosters[f_str](tgt, tgt_type))
|
||||
except salt.exceptions.SaltRenderError as exc:
|
||||
log.error('Unable to render roster file: {0}'.format(exc))
|
||||
log.error('Unable to render roster file: %s', exc)
|
||||
except IOError as exc:
|
||||
pass
|
||||
|
||||
log.debug('Matched minions: {0}'.format(targets))
|
||||
log.debug('Matched minions: %s', targets)
|
||||
return targets
|
||||
|
@ -88,7 +88,7 @@ This is the format that an inventory script needs to output to work with ansible
|
||||
Any of the [groups] or direct hostnames will return. The 'all' is special, and returns everything.
|
||||
'''
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import re
|
||||
import fnmatch
|
||||
|
@ -93,7 +93,7 @@ This should be especially useful for the other roster keys:
|
||||
- ssh:auth:private_key
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Python
|
||||
import logging
|
||||
@ -172,9 +172,9 @@ def targets(tgt, tgt_type='glob', **kwargs): # pylint: disable=W0613
|
||||
if 'host' in minion_res:
|
||||
ret[minion_id] = minion_res
|
||||
else:
|
||||
log.warning('Could not determine host information for minion {0}'.format(minion_id))
|
||||
log.warning('Could not determine host information for minion %s', minion_id)
|
||||
|
||||
log.debug('Roster lookup result: {0}'.format(ret))
|
||||
log.debug('Roster lookup result: %s', ret)
|
||||
|
||||
return ret
|
||||
|
||||
@ -183,15 +183,15 @@ def _load_minion(minion_id, cache):
|
||||
data_minion, grains, pillar = salt.utils.minions.get_minion_data(minion_id, __opts__)
|
||||
|
||||
if minion_id != data_minion:
|
||||
log.error('Asked for minion {0}, got {1}'.format(minion_id, data_minion))
|
||||
log.error('Asked for minion %s, got %s', minion_id, data_minion)
|
||||
raise LookupError
|
||||
|
||||
if not grains:
|
||||
log.warning('No grain data for minion id {0}'.format(minion_id))
|
||||
log.warning('No grain data for minion id %s', minion_id)
|
||||
grains = {}
|
||||
|
||||
if not pillar:
|
||||
log.warning('No pillar data for minion id {0}'.format(minion_id))
|
||||
log.warning('No pillar data for minion id %s', minion_id)
|
||||
pillar = {}
|
||||
|
||||
addrs = {
|
||||
@ -211,7 +211,7 @@ def _data_lookup(ref, lookup):
|
||||
res = []
|
||||
for data_key in lookup:
|
||||
data = salt.utils.data.traverse_dict_and_list(ref, data_key, None)
|
||||
# log.debug('Fetched {0} in {1}: {2}'.format(data_key, ref, data))
|
||||
# log.debug('Fetched %s in %s: %s', data_key, ref, data)
|
||||
if data:
|
||||
res.append(data)
|
||||
|
||||
@ -246,12 +246,12 @@ def _minion_lookup(minion_id, key, minion):
|
||||
try:
|
||||
net = ipaddress.ip_network(key, strict=True)
|
||||
except ValueError:
|
||||
log.error('{0} is an invalid CIDR network'.format(net))
|
||||
log.error('%s is an invalid CIDR network', net)
|
||||
return None
|
||||
|
||||
for addr in addrs[net.version]:
|
||||
if addr in net:
|
||||
return str(addr)
|
||||
return six.text_type(addr)
|
||||
else:
|
||||
# Take the addresses from the grains and filter them
|
||||
filters = {
|
||||
@ -270,6 +270,6 @@ def _minion_lookup(minion_id, key, minion):
|
||||
try:
|
||||
for addr in addrs[ip_ver]:
|
||||
if filters[key](addr):
|
||||
return str(addr)
|
||||
return six.text_type(addr)
|
||||
except KeyError:
|
||||
raise KeyError('Invalid filter {0} specified in roster_order'.format(key))
|
||||
|
@ -19,7 +19,7 @@ usually located at /etc/salt/cloud. For example, add the following:
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import copy
|
||||
|
||||
|
@ -13,9 +13,10 @@ When you want to use host globs for target matching, use ``--roster clustershell
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import socket
|
||||
import copy
|
||||
from salt.ext import six
|
||||
from salt.ext.six.moves import map # pylint: disable=import-error,redefined-builtin
|
||||
|
||||
REQ_ERROR = None
|
||||
@ -37,13 +38,13 @@ def targets(tgt, tgt_type='glob', **kwargs):
|
||||
ports = __opts__['ssh_scan_ports']
|
||||
if not isinstance(ports, list):
|
||||
# Comma-separate list of integers
|
||||
ports = list(map(int, str(ports).split(',')))
|
||||
ports = list(map(int, six.text_type(ports).split(',')))
|
||||
|
||||
hosts = list(NodeSet(tgt))
|
||||
host_addrs = dict([(h, socket.gethostbyname(h)) for h in hosts])
|
||||
|
||||
for host, addr in host_addrs.items():
|
||||
addr = str(addr)
|
||||
addr = six.text_type(addr)
|
||||
ret[addr] = copy.deepcopy(__opts__.get('roster_defaults', {}))
|
||||
for port in ports:
|
||||
try:
|
||||
|
@ -2,7 +2,7 @@
|
||||
'''
|
||||
Read in the roster from a flat file using the renderer system
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import fnmatch
|
||||
@ -21,8 +21,8 @@ except ImportError:
|
||||
# Import Salt libs
|
||||
import salt.loader
|
||||
import salt.config
|
||||
from salt.ext import six
|
||||
from salt.template import compile_template
|
||||
from salt.ext.six import string_types
|
||||
from salt.roster import get_roster_file
|
||||
|
||||
import logging
|
||||
@ -45,7 +45,7 @@ def targets(tgt, tgt_type='glob', **kwargs):
|
||||
**kwargs)
|
||||
conditioned_raw = {}
|
||||
for minion in raw:
|
||||
conditioned_raw[str(minion)] = salt.config.apply_sdb(raw[minion])
|
||||
conditioned_raw[six.text_type(minion)] = salt.config.apply_sdb(raw[minion])
|
||||
rmatcher = RosterMatcher(conditioned_raw, tgt, tgt_type, 'ipv4')
|
||||
return rmatcher.targets()
|
||||
|
||||
@ -145,7 +145,7 @@ class RosterMatcher(object):
|
||||
Return the configured ip
|
||||
'''
|
||||
ret = copy.deepcopy(__opts__.get('roster_defaults', {}))
|
||||
if isinstance(self.raw[minion], string_types):
|
||||
if isinstance(self.raw[minion], six.string_types):
|
||||
ret.update({'host': self.raw[minion]})
|
||||
return ret
|
||||
elif isinstance(self.raw[minion], dict):
|
||||
@ -162,5 +162,5 @@ def _convert_range_to_list(tgt, range_server):
|
||||
try:
|
||||
return r.expand(tgt)
|
||||
except seco.range.RangeException as err:
|
||||
log.error('Range server exception: {0}'.format(err))
|
||||
log.error('Range server exception: %s', err)
|
||||
return []
|
||||
|
@ -11,7 +11,7 @@ When you want to use a range query for target matching, use ``--roster range``.
|
||||
salt-ssh --roster range '%%%example.range.cluster' test.ping
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import fnmatch
|
||||
import copy
|
||||
|
||||
@ -38,16 +38,16 @@ def targets(tgt, tgt_type='range', **kwargs):
|
||||
'''
|
||||
|
||||
r = seco.range.Range(__opts__['range_server'])
|
||||
log.debug('Range connection to \'{0}\' established'.format(__opts__['range_server']))
|
||||
log.debug('Range connection to \'%s\' established', __opts__['range_server'])
|
||||
|
||||
hosts = []
|
||||
try:
|
||||
log.debug('Querying range for \'{0}\''.format(tgt))
|
||||
log.debug('Querying range for \'%s\'', tgt)
|
||||
hosts = r.expand(tgt)
|
||||
except seco.range.RangeException as err:
|
||||
log.error('Range server exception: %s', err)
|
||||
return {}
|
||||
log.debug('Range responded with: \'{0}\''.format(hosts))
|
||||
log.debug('Range responded with: \'%s\'', hosts)
|
||||
|
||||
# Currently we only support giving a raw range entry, no target filtering supported other than what range returns :S
|
||||
tgt_func = {
|
||||
@ -56,12 +56,12 @@ def targets(tgt, tgt_type='range', **kwargs):
|
||||
# 'glob': target_glob,
|
||||
}
|
||||
|
||||
log.debug('Filtering using tgt_type: \'{0}\''.format(tgt_type))
|
||||
log.debug('Filtering using tgt_type: \'%s\'', tgt_type)
|
||||
try:
|
||||
targeted_hosts = tgt_func[tgt_type](tgt, hosts)
|
||||
except KeyError:
|
||||
raise NotImplementedError
|
||||
log.debug('Targeting data for salt-ssh: \'{0}\''.format(targeted_hosts))
|
||||
log.debug('Targeting data for salt-ssh: \'%s\'', targeted_hosts)
|
||||
|
||||
return targeted_hosts
|
||||
|
||||
|
@ -4,7 +4,7 @@ Scan a netmask or ipaddr for open ssh ports
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import socket
|
||||
import logging
|
||||
import copy
|
||||
@ -12,6 +12,7 @@ import copy
|
||||
# Import salt libs
|
||||
import salt.utils.network
|
||||
from salt._compat import ipaddress
|
||||
from salt.ext import six
|
||||
|
||||
# Import 3rd-party libs
|
||||
from salt.ext.six.moves import map # pylint: disable=import-error,redefined-builtin
|
||||
@ -46,7 +47,7 @@ class RosterMatcher(object):
|
||||
ports = __opts__['ssh_scan_ports']
|
||||
if not isinstance(ports, list):
|
||||
# Comma-separate list of integers
|
||||
ports = list(map(int, str(ports).split(',')))
|
||||
ports = list(map(int, six.text_type(ports).split(',')))
|
||||
try:
|
||||
addrs = [ipaddress.ip_address(self.tgt)]
|
||||
except ValueError:
|
||||
@ -55,11 +56,11 @@ class RosterMatcher(object):
|
||||
except ValueError:
|
||||
pass
|
||||
for addr in addrs:
|
||||
addr = str(addr)
|
||||
addr = six.text_type(addr)
|
||||
ret[addr] = copy.deepcopy(__opts__.get('roster_defaults', {}))
|
||||
log.trace('Scanning host: {0}'.format(addr))
|
||||
log.trace('Scanning host: %s', addr)
|
||||
for port in ports:
|
||||
log.trace('Scanning port: {0}'.format(port))
|
||||
log.trace('Scanning port: %s', port)
|
||||
try:
|
||||
sock = salt.utils.network.get_socket(addr, socket.SOCK_STREAM)
|
||||
sock.settimeout(float(__opts__['ssh_scan_timeout']))
|
||||
|
@ -6,7 +6,7 @@ Parses roster entries out of Host directives from SSH config
|
||||
|
||||
salt-ssh --roster sshconfig '*' -r "echo hi"
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import os
|
||||
@ -16,7 +16,8 @@ import re
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils.files
|
||||
from salt.ext.six import string_types
|
||||
import salt.utils.stringutils
|
||||
from salt.ext import six
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
@ -52,6 +53,7 @@ def parse_ssh_config(lines):
|
||||
# sublist represents a single Host definition
|
||||
hosts = []
|
||||
for line in lines:
|
||||
line = salt.utils.stringutils.to_unicode(line)
|
||||
if not line or line.startswith('#'):
|
||||
continue
|
||||
elif line.startswith('Host '):
|
||||
@ -139,7 +141,7 @@ class RosterMatcher(object):
|
||||
'''
|
||||
Return the configured ip
|
||||
'''
|
||||
if isinstance(self.raw[minion], string_types):
|
||||
if isinstance(self.raw[minion], six.string_types):
|
||||
return {'host': self.raw[minion]}
|
||||
if isinstance(self.raw[minion], dict):
|
||||
return self.raw[minion]
|
||||
|
@ -46,7 +46,7 @@ it must be specified in the URI:
|
||||
'''
|
||||
|
||||
# import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import salt.cache
|
||||
|
||||
__func_alias__ = {
|
||||
|
@ -35,11 +35,11 @@ The module can be configured via sdb in the minion config:
|
||||
Module Documentation
|
||||
====================
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
import copy
|
||||
import logging
|
||||
|
||||
# Import third party libs
|
||||
try:
|
||||
|
@ -27,7 +27,7 @@ requires very little. For example:
|
||||
The ``driver`` refers to the Consul module, all other options are optional.
|
||||
For option details see: https://python-consul.readthedocs.io/en/latest/#consul
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
from salt.exceptions import CommandExecutionError
|
||||
|
||||
|
@ -36,7 +36,7 @@ Additional contributions to build true map-reduce functionality into this module
|
||||
would be welcome.
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import Python libraries
|
||||
import logging
|
||||
|
@ -57,10 +57,10 @@ in the environment:
|
||||
..snip
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# import python libs
|
||||
from os import environ
|
||||
# Import Python libs
|
||||
import os
|
||||
|
||||
__func_alias__ = {
|
||||
'set_': 'set'
|
||||
@ -79,7 +79,7 @@ def set_(key, value, profile=None):
|
||||
Set a key/value pair
|
||||
'''
|
||||
# pylint: disable=unused-argument
|
||||
return environ.setdefault(key, value)
|
||||
return os.environ.setdefault(key, value)
|
||||
|
||||
|
||||
def get(key, profile=None):
|
||||
@ -87,4 +87,4 @@ def get(key, profile=None):
|
||||
Get a value
|
||||
'''
|
||||
# pylint: disable=unused-argument
|
||||
return environ.get(key)
|
||||
return os.environ.get(key)
|
||||
|
@ -33,7 +33,7 @@ is hosting the etcd database and ``etcd.port`` refers to the port on that host.
|
||||
'''
|
||||
|
||||
# import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
|
||||
try:
|
||||
|
@ -44,7 +44,7 @@ https://pypi.python.org/pypi/keyring
|
||||
|
||||
.. versionadded:: 2014.1.4
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# import python libs
|
||||
import logging
|
||||
|
@ -30,7 +30,7 @@ and ``mymemcached`` refers to the name that will appear in the URI:
|
||||
password: sdb://mymemcached/mykey
|
||||
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# import python libs
|
||||
import logging
|
||||
|
@ -66,7 +66,7 @@ For instance:
|
||||
'''
|
||||
|
||||
# import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
|
||||
import salt.loader
|
||||
|
@ -42,7 +42,7 @@ create the table(s) and get and set values.
|
||||
get_query: "SELECT d FROM advanced WHERE a=:key"
|
||||
set_query: "INSERT OR REPLACE INTO advanced (a, d) VALUES (:key, :value)"
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
# Import python libs
|
||||
import logging
|
||||
|
@ -29,12 +29,13 @@ configuration.
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
|
||||
# Import Salt libs
|
||||
import salt.utils.json
|
||||
import salt.utils.http as http
|
||||
from salt.ext import six
|
||||
from salt.exceptions import SaltConfigurationError
|
||||
|
||||
log = logging.getLogger(__name__)
|
||||
@ -68,7 +69,10 @@ def get(key, service=None, profile=None): # pylint: disable=W0613
|
||||
decrypted = result.get('body')
|
||||
|
||||
if not decrypted:
|
||||
log.warning('tism.get sdb decryption request failed with error {0}'.format(result.get('error', 'unknown')))
|
||||
return "ERROR"+str(result.get('status', 'unknown'))
|
||||
log.warning(
|
||||
'tism.get sdb decryption request failed with error %s',
|
||||
result.get('error', 'unknown')
|
||||
)
|
||||
return 'ERROR' + six.text_type(result.get('status', 'unknown'))
|
||||
|
||||
return decrypted
|
||||
|
@ -41,7 +41,7 @@ The above URI is analogous to running the following vault command:
|
||||
'''
|
||||
|
||||
# import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
import salt.exceptions
|
||||
|
||||
@ -64,16 +64,16 @@ def set_(key, value, profile=None):
|
||||
url = 'v1/{0}'.format(path)
|
||||
data = {key: value}
|
||||
response = __utils__['vault.make_request'](
|
||||
'POST',
|
||||
url,
|
||||
profile,
|
||||
json=data
|
||||
)
|
||||
'POST',
|
||||
url,
|
||||
profile,
|
||||
json=data)
|
||||
|
||||
if response.status_code != 204:
|
||||
response.raise_for_status()
|
||||
return True
|
||||
except Exception as e:
|
||||
log.error('Failed to write secret! {0}: {1}'.format(type(e).__name__, e))
|
||||
log.error('Failed to write secret! %s: %s', type(e).__name__, e)
|
||||
raise salt.exceptions.CommandExecutionError(e)
|
||||
|
||||
|
||||
@ -94,5 +94,5 @@ def get(key, profile=None):
|
||||
|
||||
return data[key]
|
||||
except Exception as e:
|
||||
log.error('Failed to read secret! {0}: {1}'.format(type(e).__name__, e))
|
||||
log.error('Failed to read secret! %s: %s', type(e).__name__, e)
|
||||
raise salt.exceptions.CommandExecutionError(e)
|
||||
|
@ -40,7 +40,7 @@ GPG-encrypted data using the :py:mod:`GPG renderer <salt.renderers.gpg>`.
|
||||
'''
|
||||
|
||||
# import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
|
||||
import salt.exceptions
|
||||
@ -96,9 +96,9 @@ def _get_values(profile=None):
|
||||
ret = salt.utils.dictupdate.merge(
|
||||
ret, contents, **profile.get('merge', {}))
|
||||
except IOError:
|
||||
log.error("File not found '{0}'".format(fname))
|
||||
except TypeError:
|
||||
log.error("Error deserializing sdb file '{0}'".format(fname))
|
||||
log.error("File '%s' not found ", fname)
|
||||
except TypeError as exc:
|
||||
log.error("Error deserializing sdb file '%s': %s", fname, exc)
|
||||
return ret
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@
|
||||
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
from salt.exceptions import SaltException, SaltRenderError
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
'''
|
||||
|
||||
# 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
|
||||
@ -90,10 +90,10 @@ def _read_dict(configparser, dictionary):
|
||||
Cribbed from python3's ConfigParser.read_dict function.
|
||||
'''
|
||||
for section, keys in dictionary.items():
|
||||
section = str(section)
|
||||
section = six.text_type(section)
|
||||
configparser.add_section(section)
|
||||
for key, value in keys.items():
|
||||
key = configparser.optionxform(str(key))
|
||||
key = configparser.optionxform(six.text_type(key))
|
||||
if value is not None:
|
||||
value = str(value)
|
||||
value = six.text_type(value)
|
||||
configparser.set(section, key, value)
|
||||
|
@ -7,9 +7,9 @@
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import copy
|
||||
import logging
|
||||
from copy import copy
|
||||
|
||||
# Import Salt Libs
|
||||
from salt.log import setup_console_logger
|
||||
@ -87,7 +87,7 @@ else: # msgpack.version < 0.2.0
|
||||
return dict(data)
|
||||
elif isinstance(obj, (list, tuple)):
|
||||
return [_encoder(value) for value in obj]
|
||||
return copy(obj)
|
||||
return copy.copy(obj)
|
||||
|
||||
def _decoder(obj):
|
||||
return obj
|
||||
|
@ -103,10 +103,10 @@
|
||||
# pylint: disable=too-few-public-methods,too-many-public-methods
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
import logging
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import copy
|
||||
import datetime
|
||||
from copy import copy
|
||||
import logging
|
||||
|
||||
|
||||
# Import Salt Libs
|
||||
@ -270,7 +270,7 @@ class Loader(BaseLoader): # pylint: disable=W0232
|
||||
except:
|
||||
raise ConstructorError('unable to build reset')
|
||||
|
||||
node = copy(node)
|
||||
node = copy.copy(node)
|
||||
node.tag = tag
|
||||
obj = self.construct_object(node, deep)
|
||||
if obj is None:
|
||||
@ -287,7 +287,7 @@ class Loader(BaseLoader): # pylint: disable=W0232
|
||||
except:
|
||||
raise ConstructorError('unable to build reset')
|
||||
|
||||
node = copy(node)
|
||||
node = copy.copy(node)
|
||||
node.tag = tag
|
||||
|
||||
return self.construct_object(node, deep)
|
||||
|
@ -6,7 +6,7 @@ This module provides the point of entry to SPM, the Salt Package Manager
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import, print_function
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import yaml
|
||||
import tarfile
|
||||
@ -137,7 +137,7 @@ class SPMClient(object):
|
||||
else:
|
||||
raise SPMInvocationError('Invalid command \'{0}\''.format(command))
|
||||
except SPMException as exc:
|
||||
self.ui.error(str(exc))
|
||||
self.ui.error(six.text_type(exc))
|
||||
|
||||
def _pkgdb_fun(self, func, *args, **kwargs):
|
||||
try:
|
||||
@ -653,11 +653,11 @@ class SPMClient(object):
|
||||
raise SPMException('Auth defined, but password is not set for username: \'{0}\''
|
||||
.format(repo_info['username']))
|
||||
except SPMException as exc:
|
||||
self.ui.error(str(exc))
|
||||
self.ui.error(six.text_type(exc))
|
||||
else:
|
||||
query = http.query(dl_path, text=True)
|
||||
except SPMException as exc:
|
||||
self.ui.error(str(exc))
|
||||
self.ui.error(six.text_type(exc))
|
||||
|
||||
try:
|
||||
if query:
|
||||
@ -668,7 +668,7 @@ class SPMClient(object):
|
||||
else:
|
||||
raise SPMException('Response is empty, please check for Errors above.')
|
||||
except SPMException as exc:
|
||||
self.ui.error(str(exc))
|
||||
self.ui.error(six.text_type(exc))
|
||||
|
||||
return response
|
||||
|
||||
@ -757,35 +757,25 @@ class SPMClient(object):
|
||||
if use_formula is True:
|
||||
# Ignore/archive/delete the old version
|
||||
log.debug(
|
||||
'{0} {1}-{2} had been added, but {3}-{4} will replace it'.format(
|
||||
spm_name,
|
||||
cur_info['version'],
|
||||
cur_info['release'],
|
||||
new_info['version'],
|
||||
new_info['release'],
|
||||
)
|
||||
'%s %s-%s had been added, but %s-%s will replace it',
|
||||
spm_name, cur_info['version'], cur_info['release'],
|
||||
new_info['version'], new_info['release']
|
||||
)
|
||||
old_files.append(repo_metadata[spm_name]['filename'])
|
||||
else:
|
||||
# Ignore/archive/delete the new version
|
||||
log.debug(
|
||||
'{0} {1}-{2} has been found, but is older than {3}-{4}'.format(
|
||||
spm_name,
|
||||
new_info['version'],
|
||||
new_info['release'],
|
||||
cur_info['version'],
|
||||
cur_info['release'],
|
||||
)
|
||||
'%s %s-%s has been found, but is older than %s-%s',
|
||||
spm_name, new_info['version'], new_info['release'],
|
||||
cur_info['version'], cur_info['release']
|
||||
)
|
||||
old_files.append(spm_file)
|
||||
|
||||
if use_formula is True:
|
||||
log.debug(
|
||||
'adding {0}-{1}-{2} to the repo'.format(
|
||||
formula_conf['name'],
|
||||
formula_conf['version'],
|
||||
formula_conf['release'],
|
||||
)
|
||||
'adding %s-%s-%s to the repo',
|
||||
formula_conf['name'], formula_conf['version'],
|
||||
formula_conf['release']
|
||||
)
|
||||
repo_metadata[spm_name] = {
|
||||
'info': formula_conf.copy(),
|
||||
@ -803,33 +793,31 @@ class SPMClient(object):
|
||||
Dumper=SafeOrderedDumper
|
||||
)
|
||||
|
||||
log.debug('Wrote {0}'.format(metadata_filename))
|
||||
log.debug('Wrote %s', metadata_filename)
|
||||
|
||||
for file_ in old_files:
|
||||
if self.opts['spm_repo_dups'] == 'ignore':
|
||||
# ignore old packages, but still only add the latest
|
||||
log.debug('{0} will be left in the directory'.format(file_))
|
||||
log.debug('%s will be left in the directory', file_)
|
||||
elif self.opts['spm_repo_dups'] == 'archive':
|
||||
# spm_repo_archive_path is where old packages are moved
|
||||
if not os.path.exists('./archive'):
|
||||
try:
|
||||
os.makedirs('./archive')
|
||||
log.debug('{0} has been archived'.format(file_))
|
||||
log.debug('%s has been archived', file_)
|
||||
except IOError:
|
||||
log.error('Unable to create archive directory')
|
||||
try:
|
||||
shutil.move(file_, './archive')
|
||||
except (IOError, OSError):
|
||||
log.error(
|
||||
'Unable to archive {0}'.format(file_)
|
||||
)
|
||||
log.error('Unable to archive %s', file_)
|
||||
elif self.opts['spm_repo_dups'] == 'delete':
|
||||
# delete old packages from the repo
|
||||
try:
|
||||
os.remove(file_)
|
||||
log.debug('{0} has been deleted'.format(file_))
|
||||
log.debug('%s has been deleted', file_)
|
||||
except IOError:
|
||||
log.error('Unable to delete {0}'.format(file_))
|
||||
log.error('Unable to delete %s', file_)
|
||||
except OSError:
|
||||
# The file has already been deleted
|
||||
pass
|
||||
|
@ -5,11 +5,11 @@ This module allows SPM to use sqlite3 as the backend for SPM's package database.
|
||||
.. versionadded:: 2015.8.0
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import
|
||||
import os.path
|
||||
import logging
|
||||
import sqlite3
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import datetime
|
||||
import logging
|
||||
import os
|
||||
import sqlite3
|
||||
from sqlite3 import OperationalError
|
||||
from salt.ext.six.moves import zip
|
||||
|
||||
@ -22,11 +22,11 @@ def init():
|
||||
Get an sqlite3 connection, and initialize the package database if necessary
|
||||
'''
|
||||
if not os.path.exists(__opts__['spm_cache_dir']):
|
||||
log.debug('Creating SPM cache directory at {0}'.format(__opts__['spm_db']))
|
||||
log.debug('Creating SPM cache directory at %s', __opts__['spm_db'])
|
||||
os.makedirs(__opts__['spm_cache_dir'])
|
||||
|
||||
if not os.path.exists(__opts__['spm_db']):
|
||||
log.debug('Creating new package database at {0}'.format(__opts__['spm_db']))
|
||||
log.debug('Creating new package database at %s', __opts__['spm_db'])
|
||||
|
||||
sqlite3.enable_callback_tracebacks(True)
|
||||
conn = sqlite3.connect(__opts__['spm_db'], isolation_level=None)
|
||||
|
@ -6,7 +6,7 @@ This module allows SPM to use the local filesystem to install files for SPM.
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import os.path
|
||||
import logging
|
||||
@ -16,6 +16,9 @@ import salt.syspaths
|
||||
import salt.utils.files
|
||||
import salt.utils.stringutils
|
||||
|
||||
# Import 3rd-party libs
|
||||
from salt.ext import six
|
||||
|
||||
# Get logging started
|
||||
log = logging.getLogger(__name__)
|
||||
FILE_TYPES = ('c', 'd', 'g', 'l', 'r', 's', 'm')
|
||||
@ -52,7 +55,7 @@ def check_existing(package, pkg_files, formula_def, conn=None):
|
||||
if conn is None:
|
||||
conn = init()
|
||||
|
||||
node_type = str(__opts__.get('spm_node_type'))
|
||||
node_type = six.text_type(__opts__.get('spm_node_type'))
|
||||
|
||||
existing_files = []
|
||||
for member in pkg_files:
|
||||
@ -92,7 +95,7 @@ def check_existing(package, pkg_files, formula_def, conn=None):
|
||||
if os.path.exists(out_file):
|
||||
existing_files.append(out_file)
|
||||
if not __opts__['force']:
|
||||
log.error('{0} already exists, not installing'.format(out_file))
|
||||
log.error('%s already exists, not installing', out_file)
|
||||
|
||||
return existing_files
|
||||
|
||||
@ -107,7 +110,7 @@ def install_file(package, formula_tar, member, formula_def, conn=None):
|
||||
if conn is None:
|
||||
conn = init()
|
||||
|
||||
node_type = str(__opts__.get('spm_node_type'))
|
||||
node_type = six.text_type(__opts__.get('spm_node_type'))
|
||||
|
||||
out_path = conn['formula_path']
|
||||
|
||||
@ -115,7 +118,7 @@ def install_file(package, formula_tar, member, formula_def, conn=None):
|
||||
new_name = member.name.replace('{0}/'.format(package), '', 1)
|
||||
if not new_name.startswith(tld) and not new_name.startswith('_') and not \
|
||||
new_name.startswith('pillar.example') and not new_name.startswith('README'):
|
||||
log.debug('{0} not in top level directory, not installing'.format(new_name))
|
||||
log.debug('%s not in top level directory, not installing', new_name)
|
||||
return False
|
||||
|
||||
for line in formula_def.get('files', []):
|
||||
@ -160,7 +163,7 @@ def install_file(package, formula_tar, member, formula_def, conn=None):
|
||||
if len(comps) > 1 and comps[0] == comps[1]:
|
||||
member.path = '/'.join(comps[1:])
|
||||
|
||||
log.debug('Installing package file {0} to {1}'.format(member.name, out_path))
|
||||
log.debug('Installing package file %s to %s', member.name, out_path)
|
||||
formula_tar.extract(member, out_path)
|
||||
|
||||
return out_path
|
||||
@ -173,7 +176,7 @@ def remove_file(path, conn=None):
|
||||
if conn is None:
|
||||
conn = init()
|
||||
|
||||
log.debug('Removing package file {0}'.format(path))
|
||||
log.debug('Removing package file %s', path)
|
||||
os.remove(path)
|
||||
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
'''
|
||||
Encapsulate the different transports available to Salt.
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
|
||||
# Import third party libs
|
||||
@ -57,8 +57,10 @@ class MessageClientPool(object):
|
||||
def __init__(self, tgt, opts, args=None, kwargs=None):
|
||||
sock_pool_size = opts['sock_pool_size'] if 'sock_pool_size' in opts else 1
|
||||
if sock_pool_size < 1:
|
||||
log.warn('sock_pool_size is not correctly set, \
|
||||
the option should be greater than 0 but, {0}'.format(sock_pool_size))
|
||||
log.warning(
|
||||
'sock_pool_size is not correctly set, the option should be '
|
||||
'greater than 0 but is instead %s', sock_pool_size
|
||||
)
|
||||
sock_pool_size = 1
|
||||
|
||||
if args is None:
|
||||
|
@ -6,7 +6,7 @@ This includes client side transport, for the ReqServer and the Publisher
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
|
||||
# Import Salt Libs
|
||||
@ -156,7 +156,7 @@ class AsyncPubChannel(AsyncChannel):
|
||||
# switch on available ttypes
|
||||
if ttype == 'detect':
|
||||
opts['detect_mode'] = True
|
||||
log.info('Transport is set to detect; using {0}'.format(ttype))
|
||||
log.info('Transport is set to detect; using %s', ttype)
|
||||
if ttype == 'zeromq':
|
||||
import salt.transport.zeromq
|
||||
return salt.transport.zeromq.AsyncZeroMQPubChannel(opts, **kwargs)
|
||||
|
@ -3,7 +3,7 @@
|
||||
Helper functions for transport components to handle message framing
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import msgpack
|
||||
from salt.ext import six
|
||||
|
||||
|
@ -4,7 +4,7 @@ IPC transport classes
|
||||
'''
|
||||
|
||||
# Import Python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
import socket
|
||||
import weakref
|
||||
@ -119,7 +119,7 @@ class IPCServer(object):
|
||||
Blocks until socket is established
|
||||
'''
|
||||
# Start up the ioloop
|
||||
log.trace('IPCServer: binding to socket: {0}'.format(self.socket_path))
|
||||
log.trace('IPCServer: binding to socket: %s', self.socket_path)
|
||||
if isinstance(self.socket_path, int):
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
@ -177,25 +177,24 @@ class IPCServer(object):
|
||||
body = framed_msg['body']
|
||||
self.io_loop.spawn_callback(self.payload_handler, body, write_callback(stream, framed_msg['head']))
|
||||
except tornado.iostream.StreamClosedError:
|
||||
log.trace('Client disconnected '
|
||||
'from IPC {0}'.format(self.socket_path))
|
||||
log.trace('Client disconnected from IPC %s', self.socket_path)
|
||||
break
|
||||
except socket.error as exc:
|
||||
# On occasion an exception will occur with
|
||||
# an error code of 0, it's a spurious exception.
|
||||
if exc.errno == 0:
|
||||
log.trace('Exception occured with error number 0, '
|
||||
'spurious exception: {0}'.format(exc))
|
||||
'spurious exception: %s', exc)
|
||||
else:
|
||||
log.error('Exception occurred while '
|
||||
'handling stream: {0}'.format(exc))
|
||||
'handling stream: %s', exc)
|
||||
except Exception as exc:
|
||||
log.error('Exception occurred while '
|
||||
'handling stream: {0}'.format(exc))
|
||||
'handling stream: %s', exc)
|
||||
|
||||
def handle_connection(self, connection, address):
|
||||
log.trace('IPCServer: Handling connection '
|
||||
'to address: {0}'.format(address))
|
||||
'to address: %s', address)
|
||||
try:
|
||||
stream = IOStream(
|
||||
connection,
|
||||
@ -203,7 +202,7 @@ class IPCServer(object):
|
||||
)
|
||||
self.io_loop.spawn_callback(self.handle_stream, stream)
|
||||
except Exception as exc:
|
||||
log.error('IPC streaming error: {0}'.format(exc))
|
||||
log.error('IPC streaming error: %s', exc)
|
||||
|
||||
def close(self):
|
||||
'''
|
||||
@ -248,17 +247,17 @@ class IPCClient(object):
|
||||
loop_instance_map = IPCClient.instance_map[io_loop]
|
||||
|
||||
# FIXME
|
||||
key = str(socket_path)
|
||||
key = six.text_type(socket_path)
|
||||
|
||||
client = loop_instance_map.get(key)
|
||||
if client is None:
|
||||
log.debug('Initializing new IPCClient for path: {0}'.format(key))
|
||||
log.debug('Initializing new IPCClient for path: %s', key)
|
||||
client = object.__new__(cls)
|
||||
# FIXME
|
||||
client.__singleton_init__(io_loop=io_loop, socket_path=socket_path)
|
||||
loop_instance_map[key] = client
|
||||
else:
|
||||
log.debug('Re-using IPCClient for {0}'.format(key))
|
||||
log.debug('Re-using IPCClient for %s', key)
|
||||
return client
|
||||
|
||||
def __singleton_init__(self, socket_path, io_loop=None):
|
||||
@ -336,7 +335,7 @@ class IPCClient(object):
|
||||
)
|
||||
|
||||
try:
|
||||
log.trace('IPCClient: Connecting to socket: {0}'.format(self.socket_path))
|
||||
log.trace('IPCClient: Connecting to socket: %s', self.socket_path)
|
||||
yield self.stream.connect(sock_addr)
|
||||
self._connecting_future.set_result(True)
|
||||
break
|
||||
@ -374,7 +373,7 @@ class IPCClient(object):
|
||||
# count of the entry has not yet gone to zero.
|
||||
if self.io_loop in IPCClient.instance_map:
|
||||
loop_instance_map = IPCClient.instance_map[self.io_loop]
|
||||
key = str(self.socket_path)
|
||||
key = six.text_type(self.socket_path)
|
||||
if key in loop_instance_map:
|
||||
del loop_instance_map[key]
|
||||
|
||||
@ -500,7 +499,7 @@ class IPCMessagePublisher(object):
|
||||
Blocks until socket is established
|
||||
'''
|
||||
# Start up the ioloop
|
||||
log.trace('IPCMessagePublisher: binding to socket: {0}'.format(self.socket_path))
|
||||
log.trace('IPCMessagePublisher: binding to socket: %s', self.socket_path)
|
||||
if isinstance(self.socket_path, int):
|
||||
self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
|
||||
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
||||
@ -523,10 +522,10 @@ class IPCMessagePublisher(object):
|
||||
try:
|
||||
yield stream.write(pack)
|
||||
except tornado.iostream.StreamClosedError:
|
||||
log.trace('Client disconnected from IPC {0}'.format(self.socket_path))
|
||||
log.trace('Client disconnected from IPC %s', self.socket_path)
|
||||
self.streams.discard(stream)
|
||||
except Exception as exc:
|
||||
log.error('Exception occurred while handling stream: {0}'.format(exc))
|
||||
log.error('Exception occurred while handling stream: %s', exc)
|
||||
if not stream.closed():
|
||||
stream.close()
|
||||
self.streams.discard(stream)
|
||||
@ -544,10 +543,10 @@ class IPCMessagePublisher(object):
|
||||
self.io_loop.spawn_callback(self._write, stream, pack)
|
||||
|
||||
def handle_connection(self, connection, address):
|
||||
log.trace('IPCServer: Handling connection to address: {0}'.format(address))
|
||||
log.trace('IPCServer: Handling connection to address: %s', address)
|
||||
try:
|
||||
if self.opts['ipc_write_buffer'] > 0:
|
||||
log.trace('Setting IPC connection write buffer: {0}'.format((self.opts['ipc_write_buffer'])))
|
||||
log.trace('Setting IPC connection write buffer: %s', (self.opts['ipc_write_buffer']))
|
||||
stream = IOStream(
|
||||
connection,
|
||||
io_loop=self.io_loop,
|
||||
@ -560,7 +559,7 @@ class IPCMessagePublisher(object):
|
||||
)
|
||||
self.streams.add(stream)
|
||||
except Exception as exc:
|
||||
log.error('IPC streaming error: {0}'.format(exc))
|
||||
log.error('IPC streaming error: %s', exc)
|
||||
|
||||
def close(self):
|
||||
'''
|
||||
@ -664,11 +663,11 @@ class IPCMessageSubscriber(IPCClient):
|
||||
# Keep 'self._read_stream_future' alive.
|
||||
ret = None
|
||||
except tornado.iostream.StreamClosedError as exc:
|
||||
log.trace('Subscriber disconnected from IPC {0}'.format(self.socket_path))
|
||||
log.trace('Subscriber disconnected from IPC %s', self.socket_path)
|
||||
self._read_stream_future = None
|
||||
exc_to_raise = exc
|
||||
except Exception as exc:
|
||||
log.error('Exception occurred in Subscriber while handling stream: {0}'.format(exc))
|
||||
log.error('Exception occurred in Subscriber while handling stream: %s', exc)
|
||||
self._read_stream_future = None
|
||||
exc_to_raise = exc
|
||||
|
||||
@ -716,10 +715,10 @@ class IPCMessageSubscriber(IPCClient):
|
||||
body = framed_msg['body']
|
||||
self.io_loop.spawn_callback(callback, body)
|
||||
except tornado.iostream.StreamClosedError:
|
||||
log.trace('Subscriber disconnected from IPC {0}'.format(self.socket_path))
|
||||
log.trace('Subscriber disconnected from IPC %s', self.socket_path)
|
||||
break
|
||||
except Exception as exc:
|
||||
log.error('Exception occurred while Subscriber handling stream: {0}'.format(exc))
|
||||
log.error('Exception occurred while Subscriber handling stream: %s', exc)
|
||||
|
||||
@tornado.gen.coroutine
|
||||
def read_async(self, callback):
|
||||
@ -732,10 +731,10 @@ class IPCMessageSubscriber(IPCClient):
|
||||
try:
|
||||
yield self.connect(timeout=5)
|
||||
except tornado.iostream.StreamClosedError:
|
||||
log.trace('Subscriber closed stream on IPC {0} before connect'.format(self.socket_path))
|
||||
log.trace('Subscriber closed stream on IPC %s before connect', self.socket_path)
|
||||
yield tornado.gen.sleep(1)
|
||||
except Exception as exc:
|
||||
log.error('Exception occurred while Subscriber connecting: {0}'.format(exc))
|
||||
log.error('Exception occurred while Subscriber connecting: %s', exc)
|
||||
yield tornado.gen.sleep(1)
|
||||
yield self._read_async(callback)
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import, print_function
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
|
||||
# Import Salt Libs
|
||||
@ -23,7 +23,7 @@ class LocalChannel(ReqChannel):
|
||||
def send(self, load, tries=3, timeout=60, raw=False):
|
||||
|
||||
if self.tries == 0:
|
||||
log.debug('LocalChannel load: {0}').format(load)
|
||||
log.debug('LocalChannel load: %s', load)
|
||||
#data = json.loads(load)
|
||||
#{'path': 'apt-cacher-ng/map.jinja', 'saltenv': 'base', 'cmd': '_serve_file', 'loc': 0}
|
||||
#f = open(data['path'])
|
||||
|
@ -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 multiprocessing
|
||||
import ctypes
|
||||
import logging
|
||||
@ -51,7 +51,7 @@ class AESPubClientMixin(object):
|
||||
@tornado.gen.coroutine
|
||||
def _decode_payload(self, payload):
|
||||
# we need to decrypt it
|
||||
log.trace('Decoding payload: {0}'.format(payload))
|
||||
log.trace('Decoding payload: %s', payload)
|
||||
if payload['enc'] == 'aes':
|
||||
self._verify_master_signature(payload)
|
||||
try:
|
||||
@ -172,12 +172,10 @@ class AESReqServerMixin(object):
|
||||
'''
|
||||
|
||||
if not salt.utils.verify.valid_id(self.opts, load['id']):
|
||||
log.info(
|
||||
'Authentication request from invalid id {id}'.format(**load)
|
||||
)
|
||||
log.info('Authentication request from invalid id %s', load['id'])
|
||||
return {'enc': 'clear',
|
||||
'load': {'ret': False}}
|
||||
log.info('Authentication request from {id}'.format(**load))
|
||||
log.info('Authentication request from %s', load['id'])
|
||||
|
||||
# 0 is default which should be 'unlimited'
|
||||
if self.opts['max_minions'] > 0:
|
||||
@ -231,8 +229,8 @@ class AESReqServerMixin(object):
|
||||
pass
|
||||
elif os.path.isfile(pubfn_rejected):
|
||||
# The key has been rejected, don't place it in pending
|
||||
log.info('Public key rejected for {0}. Key is present in '
|
||||
'rejection key dir.'.format(load['id']))
|
||||
log.info('Public key rejected for %s. Key is present in '
|
||||
'rejection key dir.', load['id'])
|
||||
eload = {'result': False,
|
||||
'id': load['id'],
|
||||
'pub': load['pub']}
|
||||
@ -245,9 +243,9 @@ class AESReqServerMixin(object):
|
||||
with salt.utils.files.fopen(pubfn, 'r') as pubfn_handle:
|
||||
if pubfn_handle.read().strip() != load['pub'].strip():
|
||||
log.error(
|
||||
'Authentication attempt from {id} failed, the public '
|
||||
'Authentication attempt from %s failed, the public '
|
||||
'keys did not match. This may be an attempt to compromise '
|
||||
'the Salt cluster.'.format(**load)
|
||||
'the Salt cluster.', load['id']
|
||||
)
|
||||
# put denied minion key into minions_denied
|
||||
with salt.utils.files.fopen(pubfn_denied, 'w+') as fp_:
|
||||
@ -264,9 +262,7 @@ class AESReqServerMixin(object):
|
||||
# The key has not been accepted, this is a new minion
|
||||
if os.path.isdir(pubfn_pend):
|
||||
# The key path is a directory, error out
|
||||
log.info(
|
||||
'New public key {id} is a directory'.format(**load)
|
||||
)
|
||||
log.info('New public key %s is a directory', load['id'])
|
||||
eload = {'result': False,
|
||||
'id': load['id'],
|
||||
'pub': load['pub']}
|
||||
@ -276,14 +272,12 @@ class AESReqServerMixin(object):
|
||||
|
||||
if auto_reject:
|
||||
key_path = pubfn_rejected
|
||||
log.info('New public key for {id} rejected via autoreject_file'
|
||||
.format(**load))
|
||||
log.info('New public key for %s rejected via autoreject_file', load['id'])
|
||||
key_act = 'reject'
|
||||
key_result = False
|
||||
elif not auto_sign:
|
||||
key_path = pubfn_pend
|
||||
log.info('New public key for {id} placed in pending'
|
||||
.format(**load))
|
||||
log.info('New public key for %s placed in pending', load['id'])
|
||||
key_act = 'pend'
|
||||
key_result = True
|
||||
else:
|
||||
@ -314,8 +308,8 @@ class AESReqServerMixin(object):
|
||||
shutil.move(pubfn_pend, pubfn_rejected)
|
||||
except (IOError, OSError):
|
||||
pass
|
||||
log.info('Pending public key for {id} rejected via '
|
||||
'autoreject_file'.format(**load))
|
||||
log.info('Pending public key for %s rejected via '
|
||||
'autoreject_file', load['id'])
|
||||
ret = {'enc': 'clear',
|
||||
'load': {'ret': False}}
|
||||
eload = {'result': False,
|
||||
@ -333,10 +327,9 @@ class AESReqServerMixin(object):
|
||||
with salt.utils.files.fopen(pubfn_pend, 'r') as pubfn_handle:
|
||||
if pubfn_handle.read() != load['pub']:
|
||||
log.error(
|
||||
'Authentication attempt from {id} failed, the public '
|
||||
'Authentication attempt from %s failed, the public '
|
||||
'key in pending did not match. This may be an '
|
||||
'attempt to compromise the Salt cluster.'
|
||||
.format(**load)
|
||||
'attempt to compromise the Salt cluster.', load['id']
|
||||
)
|
||||
# put denied minion key into minions_denied
|
||||
with salt.utils.files.fopen(pubfn_denied, 'w+') as fp_:
|
||||
@ -350,9 +343,9 @@ class AESReqServerMixin(object):
|
||||
'load': {'ret': False}}
|
||||
else:
|
||||
log.info(
|
||||
'Authentication failed from host {id}, the key is in '
|
||||
'Authentication failed from host %s, the key is in '
|
||||
'pending and needs to be accepted with salt-key '
|
||||
'-a {id}'.format(**load)
|
||||
'-a %s', load['id'], load['id']
|
||||
)
|
||||
eload = {'result': True,
|
||||
'act': 'pend',
|
||||
@ -369,10 +362,9 @@ class AESReqServerMixin(object):
|
||||
with salt.utils.files.fopen(pubfn_pend, 'r') as pubfn_handle:
|
||||
if pubfn_handle.read() != load['pub']:
|
||||
log.error(
|
||||
'Authentication attempt from {id} failed, the public '
|
||||
'Authentication attempt from %s failed, the public '
|
||||
'keys in pending did not match. This may be an '
|
||||
'attempt to compromise the Salt cluster.'
|
||||
.format(**load)
|
||||
'attempt to compromise the Salt cluster.', load['id']
|
||||
)
|
||||
# put denied minion key into minions_denied
|
||||
with salt.utils.files.fopen(pubfn_denied, 'w+') as fp_:
|
||||
@ -396,7 +388,7 @@ class AESReqServerMixin(object):
|
||||
return {'enc': 'clear',
|
||||
'load': {'ret': False}}
|
||||
|
||||
log.info('Authentication accepted from {id}'.format(**load))
|
||||
log.info('Authentication accepted from %s', load['id'])
|
||||
# only write to disk if you are adding the file, and in open mode,
|
||||
# which implies we accept any key from a minion.
|
||||
if not os.path.isfile(pubfn) and not self.opts['open_mode']:
|
||||
@ -424,7 +416,7 @@ class AESReqServerMixin(object):
|
||||
with salt.utils.files.fopen(pubfn) as f:
|
||||
pub = RSA.importKey(f.read())
|
||||
except (ValueError, IndexError, TypeError) as err:
|
||||
log.error('Corrupt public key "{0}": {1}'.format(pubfn, err))
|
||||
log.error('Corrupt public key "%s": %s', pubfn, err)
|
||||
return {'enc': 'clear',
|
||||
'load': {'ret': False}}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
RAET transport classes
|
||||
'''
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import time
|
||||
|
||||
# Import Salt Libs
|
||||
@ -77,7 +77,7 @@ class RAETReqChannel(ReqChannel):
|
||||
self.stack = jobber_stack
|
||||
else:
|
||||
self.stack = jobber_stack = self._setup_stack(ryn=self.ryn)
|
||||
log.debug("RAETReqChannel Using Jobber Stack at = {0}\n".format(self.stack.ha))
|
||||
log.debug("RAETReqChannel Using Jobber Stack at = %s\n", self.stack.ha)
|
||||
|
||||
def _setup_stack(self, ryn='manor'):
|
||||
'''
|
||||
@ -117,7 +117,7 @@ class RAETReqChannel(ReqChannel):
|
||||
name=ryn,
|
||||
lanename=lanename,
|
||||
dirpath=self.opts['sock_dir']))
|
||||
log.debug("Created Channel Jobber Stack {0}\n".format(stack.name))
|
||||
log.debug("Created Channel Jobber Stack %s\n", stack.name)
|
||||
return stack
|
||||
|
||||
def crypted_transfer_decode_dictentry(self, load, dictkey=None, tries=3, timeout=60):
|
||||
|
@ -6,7 +6,7 @@ This includes server side transport, for the ReqServer and the Publisher
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
|
||||
|
||||
class ReqServerChannel(object):
|
||||
|
@ -7,7 +7,7 @@ Wire protocol: "len(payload) msgpack({'head': SOMEHEADER, 'body': SOMEBODY})"
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import logging
|
||||
import msgpack
|
||||
import socket
|
||||
@ -224,7 +224,7 @@ class AsyncTCPReqChannel(salt.transport.client.ReqChannel):
|
||||
key = cls.__key(opts, **kwargs)
|
||||
obj = loop_instance_map.get(key)
|
||||
if obj is None:
|
||||
log.debug('Initializing new AsyncTCPReqChannel for {0}'.format(key))
|
||||
log.debug('Initializing new AsyncTCPReqChannel for %s', key)
|
||||
# we need to make a local variable for this, as we are going to store
|
||||
# it in a WeakValueDictionary-- which will remove the item if no one
|
||||
# references it-- this forces a reference while we return to the caller
|
||||
@ -232,7 +232,7 @@ class AsyncTCPReqChannel(salt.transport.client.ReqChannel):
|
||||
obj.__singleton_init__(opts, **kwargs)
|
||||
loop_instance_map[key] = obj
|
||||
else:
|
||||
log.debug('Re-using AsyncTCPReqChannel for {0}'.format(key))
|
||||
log.debug('Re-using AsyncTCPReqChannel for %s', key)
|
||||
return obj
|
||||
|
||||
@classmethod
|
||||
@ -475,9 +475,7 @@ class AsyncTCPPubChannel(salt.transport.mixins.auth.AESPubClientMixin, salt.tran
|
||||
except salt.exceptions.SaltReqTimeoutError:
|
||||
log.info('fire_master failed: master could not be contacted. Request timed out.')
|
||||
except Exception:
|
||||
log.info('fire_master failed: {0}'.format(
|
||||
traceback.format_exc())
|
||||
)
|
||||
log.info('fire_master failed: %s', traceback.format_exc())
|
||||
else:
|
||||
self._reconnected = True
|
||||
|
||||
@ -512,7 +510,7 @@ class AsyncTCPPubChannel(salt.transport.mixins.auth.AESPubClientMixin, salt.tran
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except Exception as exc:
|
||||
if '-|RETRY|-' not in str(exc):
|
||||
if '-|RETRY|-' not in six.text_type(exc):
|
||||
raise SaltClientError('Unable to sign_in to master: {0}'.format(exc)) # TODO: better error message
|
||||
|
||||
def on_recv(self, callback):
|
||||
@ -667,7 +665,7 @@ class TCPReqServerChannel(salt.transport.mixins.auth.AESReqServerMixin, salt.tra
|
||||
req_opts['tgt'],
|
||||
), header=header))
|
||||
else:
|
||||
log.error('Unknown req_fun {0}'.format(req_fun))
|
||||
log.error('Unknown req_fun %s', req_fun)
|
||||
# always attempt to return an error to the minion
|
||||
stream.write('Server-side exception handling payload')
|
||||
stream.close()
|
||||
@ -680,7 +678,7 @@ class TCPReqServerChannel(salt.transport.mixins.auth.AESReqServerMixin, salt.tra
|
||||
log.error('Connection was unexpectedly closed', exc_info=True)
|
||||
except Exception as exc: # pylint: disable=broad-except
|
||||
# Absorb any other exceptions
|
||||
log.error('Unexpected exception occurred: {0}'.format(exc), exc_info=True)
|
||||
log.error('Unexpected exception occurred: %s', exc, exc_info=True)
|
||||
|
||||
raise tornado.gen.Return()
|
||||
|
||||
@ -701,7 +699,7 @@ class SaltMessageServer(tornado.tcpserver.TCPServer, object):
|
||||
'''
|
||||
Handle incoming streams and add messages to the incoming queue
|
||||
'''
|
||||
log.trace('Req client {0} connected'.format(address))
|
||||
log.trace('Req client %s connected', address)
|
||||
self.clients.append((stream, address))
|
||||
unpacker = msgpack.Unpacker()
|
||||
try:
|
||||
@ -717,10 +715,10 @@ class SaltMessageServer(tornado.tcpserver.TCPServer, object):
|
||||
self.io_loop.spawn_callback(self.message_handler, stream, header, framed_msg['body'])
|
||||
|
||||
except tornado.iostream.StreamClosedError:
|
||||
log.trace('req client disconnected {0}'.format(address))
|
||||
log.trace('req client disconnected %s', address)
|
||||
self.clients.remove((stream, address))
|
||||
except Exception as e:
|
||||
log.trace('other master-side exception: {0}'.format(e))
|
||||
log.trace('other master-side exception: %s', e)
|
||||
self.clients.remove((stream, address))
|
||||
stream.close()
|
||||
|
||||
@ -989,9 +987,9 @@ class SaltMessageClient(object):
|
||||
if self._on_recv is not None:
|
||||
self.io_loop.spawn_callback(self._on_recv, header, body)
|
||||
else:
|
||||
log.error('Got response for message_id {0} that we are not tracking'.format(message_id))
|
||||
log.error('Got response for message_id %s that we are not tracking', message_id)
|
||||
except tornado.iostream.StreamClosedError as e:
|
||||
log.debug('tcp stream to {0}:{1} closed, unable to recv'.format(self.host, self.port))
|
||||
log.debug('tcp stream to %s:%s closed, unable to recv', self.host, self.port)
|
||||
for future in six.itervalues(self.send_future_map):
|
||||
future.set_exception(e)
|
||||
self.send_future_map = {}
|
||||
@ -1266,7 +1264,7 @@ class PubServer(tornado.tcpserver.TCPServer, object):
|
||||
client.id_ = load['id']
|
||||
self._add_client_present(client)
|
||||
except tornado.iostream.StreamClosedError as e:
|
||||
log.debug('tcp stream to {0} closed, unable to recv'.format(client.address))
|
||||
log.debug('tcp stream to %s closed, unable to recv', client.address)
|
||||
client.close()
|
||||
self._remove_client_present(client)
|
||||
self.clients.discard(client)
|
||||
@ -1276,7 +1274,7 @@ class PubServer(tornado.tcpserver.TCPServer, object):
|
||||
continue
|
||||
|
||||
def handle_stream(self, stream, address):
|
||||
log.trace('Subscriber at {0} connected'.format(address))
|
||||
log.trace('Subscriber at %s connected', address)
|
||||
client = Subscriber(stream, address)
|
||||
self.clients.add(client)
|
||||
self.io_loop.spawn_callback(self._stream_read, client)
|
||||
@ -1284,7 +1282,7 @@ class PubServer(tornado.tcpserver.TCPServer, object):
|
||||
# TODO: ACK the publish through IPC
|
||||
@tornado.gen.coroutine
|
||||
def publish_payload(self, package, _):
|
||||
log.debug('TCP PubServer sending payload: {0}'.format(package))
|
||||
log.debug('TCP PubServer sending payload: %s', package)
|
||||
payload = salt.transport.frame.frame_msg(package['payload'])
|
||||
|
||||
to_remove = []
|
||||
@ -1305,7 +1303,7 @@ class PubServer(tornado.tcpserver.TCPServer, object):
|
||||
except tornado.iostream.StreamClosedError:
|
||||
to_remove.append(client)
|
||||
else:
|
||||
log.debug('Publish target {0} not connected'.format(topic))
|
||||
log.debug('Publish target %s not connected', topic)
|
||||
else:
|
||||
for client in self.clients:
|
||||
try:
|
||||
@ -1315,7 +1313,7 @@ class PubServer(tornado.tcpserver.TCPServer, object):
|
||||
except tornado.iostream.StreamClosedError:
|
||||
to_remove.append(client)
|
||||
for client in to_remove:
|
||||
log.debug('Subscriber at {0} has disconnected from publisher'.format(client.address))
|
||||
log.debug('Subscriber at %s has disconnected from publisher', client.address)
|
||||
client.close()
|
||||
self._remove_client_present(client)
|
||||
self.clients.discard(client)
|
||||
@ -1378,7 +1376,7 @@ class TCPPubServerChannel(salt.transport.server.PubServerChannel):
|
||||
)
|
||||
|
||||
# Securely create socket
|
||||
log.info('Starting the Salt Puller on {0}'.format(pull_uri))
|
||||
log.info('Starting the Salt Puller on %s', pull_uri)
|
||||
old_umask = os.umask(0o177)
|
||||
try:
|
||||
pull_sock.start()
|
||||
|
@ -4,7 +4,7 @@ Zeromq transport classes
|
||||
'''
|
||||
|
||||
# Import Python Libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import sys
|
||||
import copy
|
||||
@ -125,16 +125,16 @@ class AsyncZeroMQReqChannel(salt.transport.client.ReqChannel):
|
||||
key = cls.__key(opts, **kwargs)
|
||||
obj = loop_instance_map.get(key)
|
||||
if obj is None:
|
||||
log.debug('Initializing new AsyncZeroMQReqChannel for {0}'.format(key))
|
||||
log.debug('Initializing new AsyncZeroMQReqChannel for %s', key)
|
||||
# we need to make a local variable for this, as we are going to store
|
||||
# it in a WeakValueDictionary-- which will remove the item if no one
|
||||
# references it-- this forces a reference while we return to the caller
|
||||
obj = object.__new__(cls)
|
||||
obj.__singleton_init__(opts, **kwargs)
|
||||
loop_instance_map[key] = obj
|
||||
log.trace('Inserted key into loop_instance_map id {0} for key {1} and process {2}'.format(id(loop_instance_map), key, os.getpid()))
|
||||
log.trace('Inserted key into loop_instance_map id %s for key %s and process %s', id(loop_instance_map), key, os.getpid())
|
||||
else:
|
||||
log.debug('Re-using AsyncZeroMQReqChannel for {0}'.format(key))
|
||||
log.debug('Re-using AsyncZeroMQReqChannel for %s', key)
|
||||
return obj
|
||||
|
||||
def __deepcopy__(self, memo):
|
||||
@ -377,18 +377,20 @@ class AsyncZeroMQPubChannel(salt.transport.mixins.auth.AESPubClientMixin, salt.t
|
||||
self.opts['recon_default'] + self.opts['recon_max']
|
||||
)
|
||||
|
||||
log.debug("Generated random reconnect delay between '{0}ms' and '{1}ms' ({2})".format(
|
||||
log.debug(
|
||||
"Generated random reconnect delay between '%sms' and '%sms' (%s)",
|
||||
self.opts['recon_default'],
|
||||
self.opts['recon_default'] + self.opts['recon_max'],
|
||||
recon_delay)
|
||||
recon_delay
|
||||
)
|
||||
|
||||
log.debug("Setting zmq_reconnect_ivl to '{0}ms'".format(recon_delay))
|
||||
log.debug("Setting zmq_reconnect_ivl to '%sms'", recon_delay)
|
||||
self._socket.setsockopt(zmq.RECONNECT_IVL, recon_delay)
|
||||
|
||||
if hasattr(zmq, 'RECONNECT_IVL_MAX'):
|
||||
log.debug("Setting zmq_reconnect_ivl_max to '{0}ms'".format(
|
||||
self.opts['recon_default'] + self.opts['recon_max'])
|
||||
log.debug(
|
||||
"Setting zmq_reconnect_ivl_max to '%sms'",
|
||||
self.opts['recon_default'] + self.opts['recon_max']
|
||||
)
|
||||
|
||||
self._socket.setsockopt(
|
||||
@ -452,7 +454,7 @@ class AsyncZeroMQPubChannel(salt.transport.mixins.auth.AESPubClientMixin, salt.t
|
||||
# 2 includes a header which says who should do it
|
||||
elif messages_len == 2:
|
||||
if messages[0] not in ('broadcast', self.hexid):
|
||||
log.debug('Publish received for not this minion: {0}'.format(messages[0]))
|
||||
log.debug('Publish received for not this minion: %s', messages[0])
|
||||
raise tornado.gen.Return(None)
|
||||
payload = self.serial.loads(messages[1])
|
||||
else:
|
||||
@ -607,7 +609,7 @@ class ZeroMQReqServerChannel(salt.transport.mixins.auth.AESReqServerMixin, salt.
|
||||
self.w_uri = 'ipc://{0}'.format(
|
||||
os.path.join(self.opts['sock_dir'], 'workers.ipc')
|
||||
)
|
||||
log.info('Worker binding to socket {0}'.format(self.w_uri))
|
||||
log.info('Worker binding to socket %s', self.w_uri)
|
||||
self._socket.connect(self.w_uri)
|
||||
|
||||
salt.transport.mixins.auth.AESReqServerMixin.post_fork(self, payload_handler, io_loop)
|
||||
@ -644,7 +646,7 @@ class ZeroMQReqServerChannel(salt.transport.mixins.auth.AESReqServerMixin, salt.
|
||||
|
||||
# TODO helper functions to normalize payload?
|
||||
if not isinstance(payload, dict) or not isinstance(payload.get('load'), dict):
|
||||
log.error('payload and load must be a dict. Payload was: {0} and load was {1}'.format(payload, payload.get('load')))
|
||||
log.error('payload and load must be a dict. Payload was: %s and load was %s', payload, payload.get('load'))
|
||||
stream.send(self.serial.dumps('payload and load must be a dict'))
|
||||
raise tornado.gen.Return()
|
||||
|
||||
@ -687,7 +689,7 @@ class ZeroMQReqServerChannel(salt.transport.mixins.auth.AESReqServerMixin, salt.
|
||||
req_opts['tgt'],
|
||||
)))
|
||||
else:
|
||||
log.error('Unknown req_fun {0}'.format(req_fun))
|
||||
log.error('Unknown req_fun %s', req_fun)
|
||||
# always attempt to return an error to the minion
|
||||
stream.send('Server-side exception handling payload')
|
||||
raise tornado.gen.Return()
|
||||
@ -790,11 +792,11 @@ class ZeroMQPubServerChannel(salt.transport.server.PubServerChannel):
|
||||
salt.utils.zeromq.check_ipc_path_max_len(pull_uri)
|
||||
|
||||
# Start the minion command publisher
|
||||
log.info('Starting the Salt Publisher on {0}'.format(pub_uri))
|
||||
log.info('Starting the Salt Publisher on %s', pub_uri)
|
||||
pub_sock.bind(pub_uri)
|
||||
|
||||
# Securely create socket
|
||||
log.info('Starting the Salt Puller on {0}'.format(pull_uri))
|
||||
log.info('Starting the Salt Puller on %s', pull_uri)
|
||||
old_umask = os.umask(0o177)
|
||||
try:
|
||||
pull_sock.bind(pull_uri)
|
||||
@ -893,7 +895,7 @@ class ZeroMQPubServerChannel(salt.transport.server.PubServerChannel):
|
||||
tgt_type=load['tgt_type'])
|
||||
match_ids = _res['minions']
|
||||
|
||||
log.debug("Publish Side Match: {0}".format(match_ids))
|
||||
log.debug("Publish Side Match: %s", match_ids)
|
||||
# Send list of miions thru so zmq can target them
|
||||
int_payload['topic_lst'] = match_ids
|
||||
|
||||
@ -1057,7 +1059,7 @@ class AsyncReqMessageClient(object):
|
||||
del self.send_timeout_map[message]
|
||||
if future.attempts < future.tries:
|
||||
future.attempts += 1
|
||||
log.debug('SaltReqTimeoutError, retrying. ({0}/{1})'.format(future.attempts, future.tries))
|
||||
log.debug('SaltReqTimeoutError, retrying. (%s/%s)', future.attempts, future.tries)
|
||||
self.send(
|
||||
message,
|
||||
timeout=future.timeout,
|
||||
@ -1146,7 +1148,7 @@ class ZeroMQSocketMonitor(object):
|
||||
def monitor_callback(self, msg):
|
||||
evt = zmq.utils.monitor.parse_monitor_message(msg)
|
||||
evt['description'] = self.event_map[evt['event']]
|
||||
log.debug("ZeroMQ event: {0}".format(evt))
|
||||
log.debug("ZeroMQ event: %s", evt)
|
||||
if evt['event'] == zmq.EVENT_MONITOR_STOPPED:
|
||||
self.stop()
|
||||
|
||||
|
@ -54,4 +54,4 @@ AcceptEnv LANG LC_*
|
||||
|
||||
Subsystem sftp /usr/lib/openssh/sftp-server
|
||||
|
||||
#UsePAM yes
|
||||
UsePAM yes
|
||||
|
@ -2,7 +2,7 @@
|
||||
'''
|
||||
Test case for env sdb module
|
||||
'''
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import textwrap
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
Tests for the spm build utility
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
Tests for the spm files utility
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
Tests for the spm info utility
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import shutil
|
||||
|
||||
# Import Salt Testing libs
|
||||
|
@ -3,7 +3,7 @@
|
||||
Tests for the spm install utility
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
Tests for the spm remove utility
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
Tests for the spm repo
|
||||
'''
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
@ -4,7 +4,7 @@ Test case for the YAML SDB 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.unit import skipIf, TestCase
|
||||
|
@ -710,7 +710,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
|
||||
'''
|
||||
Test to ensure that a named directory is present and has the right perms
|
||||
'''
|
||||
name = '/etc/grub.conf'
|
||||
name = '/etc/testdir'
|
||||
user = 'salt'
|
||||
group = 'saltstack'
|
||||
|
||||
@ -809,7 +809,7 @@ class TestFileState(TestCase, LoaderModuleMockMixin):
|
||||
else:
|
||||
comt = ('The following files will be changed:\n{0}:'
|
||||
' directory - new\n'.format(name))
|
||||
p_chg = {'/etc/grub.conf': {'directory': 'new'}}
|
||||
p_chg = {'/etc/testdir': {'directory': 'new'}}
|
||||
ret.update({
|
||||
'comment': comt,
|
||||
'result': None,
|
||||
|
@ -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 Libs
|
||||
import salt.transport.client
|
||||
|
@ -4,7 +4,7 @@
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import errno
|
||||
import socket
|
||||
@ -21,6 +21,7 @@ import salt.transport.server
|
||||
import salt.transport.client
|
||||
import salt.utils.platform
|
||||
|
||||
from salt.ext import six
|
||||
from salt.ext.six.moves import range
|
||||
|
||||
# Import Salt Testing libs
|
||||
@ -125,7 +126,7 @@ class IPCMessageClient(BaseIPCReqCase):
|
||||
self.assertEqual(self.payloads[:-1], msgs)
|
||||
|
||||
def test_very_big_message(self):
|
||||
long_str = ''.join([str(num) for num in range(10**5)])
|
||||
long_str = ''.join([six.text_type(num) for num in range(10**5)])
|
||||
msg = {'long_str': long_str, 'stop': True}
|
||||
self.channel.send(msg)
|
||||
self.wait()
|
||||
|
@ -4,7 +4,7 @@
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import threading
|
||||
|
||||
import tornado.gen
|
||||
|
@ -4,7 +4,7 @@
|
||||
'''
|
||||
|
||||
# Import python libs
|
||||
from __future__ import absolute_import
|
||||
from __future__ import absolute_import, print_function, unicode_literals
|
||||
import os
|
||||
import time
|
||||
import threading
|
||||
|
Loading…
Reference in New Issue
Block a user