Skip to content

Commit db334f5

Browse files
authored
Merge pull request #267 from mirceaulinic/develop
Release 2022.10.0
2 parents e902a6e + da4a9a1 commit db334f5

File tree

4 files changed

+41
-18
lines changed

4 files changed

+41
-18
lines changed

requirements-dev.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
-r requirements.txt
2-
tox==3.21.4
2+
tox==3.24.1
33
black==19.10b0
44
pylint==2.6.0
55
SaltPylint==2020.9.28
6-
CherryPy==18.1.0
6+
CherryPy==18.6.1

salt_sproxy/_runners/proxy.py

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,22 @@ def _receive_replies_sync(ret_queue, static_queue, done_queue, progress_bar):
207207
done_queue.put(_SENTINEL)
208208

209209

210+
class PingBatch(Batch):
211+
def __init__(
212+
self, opts, eauth=None, quiet=False, parser=None
213+
): # pylint: disable=super-init-not-called
214+
self.opts = opts
215+
self.eauth = eauth if eauth else {}
216+
self.pub_kwargs = eauth if eauth else {}
217+
self.quiet = quiet
218+
self.local = salt.client.get_local_client(opts['conf_file'])
219+
self.minions, self.ping_gen, self.down_minions = self.gather_minions()
220+
self.options = parser
221+
222+
def _gather_minions(self):
223+
return self.minions, self.ping_gen, self.down_minions
224+
225+
210226
class NoPingBatch(Batch):
211227
'''
212228
Similar to the native Salt Batch. but without issuing test.ping to ensure
@@ -221,11 +237,11 @@ def __init__(
221237
self.pub_kwargs = eauth if eauth else {}
222238
self.quiet = quiet
223239
self.local = salt.client.get_local_client(opts['conf_file'])
224-
self.minions, self.ping_gen, self.down_minions = self.__gather_minions()
240+
self.minions, self.ping_gen, self.down_minions = self.opts['tgt'], [], []
225241
self.options = parser
226242

227-
def __gather_minions(self):
228-
return self.opts['tgt'], [], []
243+
def gather_minions(self):
244+
return self.minions, self.ping_gen, self.down_minions
229245

230246

231247
# The SProxyMinion class is back-ported from Salt 2019.2.0 (to be released soon)
@@ -621,9 +637,11 @@ def salt_call(
621637
opts['proxy_test_ping'] = test_ping
622638
opts['proxy_use_cached_grains'] = use_cached_grains
623639
if use_cached_grains:
624-
opts['proxy_cached_grains'] = __salt__['cache.fetch'](
625-
'minions/{}/data'.format(minion_id), 'grains'
640+
cache_data = __salt__['cache.fetch'](
641+
'minions/{}'.format(minion_id), 'data'
626642
)
643+
if cache_data and 'grains' in cache_data:
644+
opts['proxy_cached_grains'] = cache_data['grains']
627645
opts['roster_opts'] = roster_opts
628646
opts['returner'] = returner
629647
if not returner_kwargs:
@@ -702,17 +720,17 @@ def salt_call(
702720
log.warning(
703721
'Returner %s is not available. Check that the dependencies are properly installed'
704722
)
723+
cache_data = {}
705724
if cache_grains:
706725
log.debug('Caching Grains for %s', minion_id)
707726
log.debug(sa_proxy.opts['grains'])
708-
cache_store = __salt__['cache.store'](
709-
'minions/{}/data'.format(minion_id), 'grains', sa_proxy.opts['grains']
710-
)
727+
cache_data['grains'] = copy.deepcopy(sa_proxy.opts['grains'])
711728
if cache_pillar:
712729
log.debug('Caching Pillar for %s', minion_id)
713-
cached_store = __salt__['cache.store'](
714-
'minions/{}/data'.format(minion_id), 'pillar', sa_proxy.opts['pillar']
715-
)
730+
cache_data['pillar'] = copy.deepcopy(sa_proxy.opts['pillar'])
731+
cached_store = __salt__['cache.store'](
732+
'minions/{}'.format(minion_id), 'data', cache_data
733+
)
716734
return ret, retcode
717735

718736

@@ -966,7 +984,9 @@ def execute_devices(
966984
batch_opts['ret_config'] = returner_config
967985
batch_opts['ret_kwargs'] = returner_kwargs
968986
if test_ping:
969-
cli_batch = Batch(batch_opts, quiet=True)
987+
cli_batch = PingBatch(batch_opts, quiet=True)
988+
cli_batch.minions, cli_batch.ping_gen, cli_batch.down_minions = cli_batch.gather_minions()
989+
cli_batch.gather_minions = cli_batch._gather_minions
970990
else:
971991
cli_batch = NoPingBatch(batch_opts, quiet=True)
972992
log.debug('Batching detected the following Minions responsive')

salt_sproxy/cli.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from salt.ext import six
3131
import salt.defaults.exitcodes # pylint: disable=W0611
3232
import salt.utils.stringutils
33+
import salt.version
3334

3435
try:
3536
from salt.utils.files import fopen
@@ -62,9 +63,11 @@ def run(self):
6263
sys.stdout.write(safe_dump(self.config, default_flow_style=False))
6364
return self.config
6465

65-
# Setup file logging!
66-
self.setup_logfile_logger()
67-
verify_log(self.config)
66+
if salt.version.__saltstack_version__.major < 3005:
67+
# Setup file logging!
68+
self.setup_logfile_logger()
69+
verify_log(self.config)
70+
6871
profiling_enabled = self.options.profiling_enabled
6972
curpath = os.path.dirname(os.path.realpath(__file__))
7073
saltenv = self.config.get('saltenv_cli', self.config.get('saltenv'))

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
setup(
2222
name=name,
23-
version='2021.6.1',
23+
version='2022.10.0',
2424
namespace_packages=['salt_sproxy'],
2525
packages=find_packages(),
2626
author='Mircea Ulinic',

0 commit comments

Comments
 (0)