Fixed raet transport to work on Py2 for the Oxygen release.

This commit is contained in:
Dmitry Kuzmenko 2018-01-17 17:08:38 +03:00
parent b9b3e2e37e
commit d7546318d2
No known key found for this signature in database
GPG Key ID: 4C7CAD30C95651DA
12 changed files with 31 additions and 17 deletions

View File

@ -19,7 +19,7 @@ opts['caller_floscript']
'''
# Import Python libs
from __future__ import absolute_import, print_function, unicode_literals
from __future__ import absolute_import, print_function
import os
# Import modules

View File

@ -6,7 +6,7 @@ The core behaviors used by minion and master
# pylint: disable=3rd-party-module-not-gated
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
from __future__ import absolute_import, print_function
import os
import time
import random

View File

@ -15,7 +15,7 @@ without the need for a swarm of real minions.
# pylint: disable=3rd-party-module-not-gated
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
from __future__ import absolute_import, print_function
import logging
# Import salt libs

View File

@ -6,7 +6,7 @@ Jobber Behaviors
# pylint: disable=3rd-party-module-not-gated
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
from __future__ import absolute_import, print_function
import os
import sys
import types
@ -307,13 +307,14 @@ class SaltRaetNixJobber(ioflo.base.deeding.Deed):
'non-empty list expected'.format(executors)
)
if self.opts.get('sudo_user', '') and executors[-1] != 'sudo':
executors[-1] = 'sudo.get' # replace
executors[-1] = 'sudo' # replace
log.trace("Executors list %s", executors)
for name in executors:
if name not in self.module_executors.value:
fname = '{0}.execute'.format(name)
if fname not in self.module_executors.value:
raise SaltInvocationError("Executor '{0}' is not available".format(name))
return_data = self.module_executors.value[name].execute(self.opts, data, func, args, kwargs)
return_data = self.module_executors.value[fname](self.opts, data, func, args, kwargs)
if return_data is not None:
break

View File

@ -3,7 +3,7 @@
Define the behaviors used in the maintenance process
'''
# pylint: disable=3rd-party-module-not-gated
from __future__ import absolute_import, print_function, unicode_literals
from __future__ import absolute_import, print_function
# Import python libs
import multiprocessing
import os

View File

@ -3,7 +3,7 @@
Start the reactor!
'''
# pylint: disable=3rd-party-module-not-gated
from __future__ import absolute_import, print_function, unicode_literals
from __future__ import absolute_import, print_function
# Import salt libs
import salt.utils.reactor
import salt.utils.event

View File

@ -5,7 +5,7 @@ The core behaviors used by minion and master
# pylint: disable=W0232
# pylint: disable=3rd-party-module-not-gated
from __future__ import absolute_import, print_function, unicode_literals
from __future__ import absolute_import, print_function
# Import python libs
import time

View File

@ -6,7 +6,7 @@ IoFlo behaviors for running a ZeroMQ based master
# pylint: disable=3rd-party-module-not-gated
# Import python libs
from __future__ import absolute_import, print_function, unicode_literals
from __future__ import absolute_import, print_function
import os
import logging
import hashlib

View File

@ -717,7 +717,7 @@ class RemoteFuncs(object):
'data',
{'grains': load['grains'], 'pillar': data})
if self.opts.get('minion_data_cache_events') is True:
self.event.fire_event('Minion data cache refresh', salt.utils.event.tagify(load['id'], 'refresh', 'minion'))
self.event.fire_event({'comment': 'Minion data cache refresh'}, salt.utils.event.tagify(load['id'], 'refresh', 'minion'))
return data
def _minion_event(self, load):

View File

@ -3,7 +3,7 @@
salting.py module of salt specific interfaces to raet
'''
from __future__ import absolute_import, print_function, unicode_literals
from __future__ import absolute_import, print_function
# pylint: skip-file
# pylint: disable=W0611

View File

@ -380,7 +380,7 @@ class Key(object):
io_loop=io_loop
)
self.passphrase = salt.utils.sdb.sdb_get(self.opts['signing_key_pass'], self.opts)
self.passphrase = salt.utils.sdb.sdb_get(self.opts.get('signing_key_pass'), self.opts)
def _check_minions_directories(self):
'''

View File

@ -57,8 +57,21 @@ class RAETEvent(object):
self.ryn = 'manor' # remote yard name
self.connected = False
self.cpub = False
self.__load_cache_regex()
self.__prep_stack(listen)
@classmethod
def __load_cache_regex(cls):
'''
Initialize the regular expression cache and put it in the
class namespace. The regex search strings will be prepend with '^'
'''
# This is in the class namespace, to minimize cache memory
# usage and maximize cache hits
# The prepend='^' is to reduce differences in behavior between
# the default 'startswith' and the optional 'regex' match_type
cls.cache_regex = salt.utils.cache.CacheRegex(prepend='^')
def __prep_stack(self, listen):
'''
Prepare the stack objects
@ -119,14 +132,14 @@ class RAETEvent(object):
dirpath=self.sock_dir))
return stack
def subscribe(self, tag=None):
def subscribe(self, tag=None, match_type=None):
'''
Included for compat with zeromq events, not required
'''
if not self.connected:
self.connect_pub()
def unsubscribe(self, tag=None):
def unsubscribe(self, tag=None, match_type=None):
'''
Included for compat with zeromq events, not required
'''
@ -179,7 +192,7 @@ class RAETEvent(object):
if 'tag' not in msg and 'data' not in msg:
# Invalid event, how did this get here?
continue
if not msg['tag'].startswith(tag):
if not msg['tag'].startswith(tag) and self.cache_regex.get(tag).search(msg['tag']) is None:
# Not what we are looking for, throw it away
continue
if full: