File 0058-Adds-custom-timeout-and-gather_job_timeout-to-local_.patch of Package salt.4663
From b715563659fd74614b8b34641041e64cd4ea06a3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Pablo=20Su=C3=A1rez=20Hern=C3=A1ndez?=
<psuarezhernandez@suse.com>
Date: Fri, 24 Mar 2017 12:02:36 +0000
Subject: [PATCH 58/58] Adds custom 'timeout' and 'gather_job_timeout' to
'local_batch' client
Fixes 'local_batch' client to be aware of 'timeout' and 'gather_job_timeout' parameters that are coming from kwargs.
Fixes testing opts dict for batch unit tests
---
salt/cli/batch.py | 5 ++++-
salt/client/__init__.py | 6 ++++++
tests/unit/cli/batch_test.py | 8 +++++++-
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/salt/cli/batch.py b/salt/cli/batch.py
index efc0a59..d615ac4 100644
--- a/salt/cli/batch.py
+++ b/salt/cli/batch.py
@@ -50,7 +50,9 @@ class Batch(object):
else:
args.append(self.opts.get('expr_form', 'glob'))
- ping_gen = self.local.cmd_iter(*args, **self.eauth)
+ ping_gen = self.local.cmd_iter(*args,
+ gather_job_timeout=self.opts['gather_job_timeout'],
+ **self.eauth)
fret = set()
try:
@@ -141,6 +143,7 @@ class Batch(object):
ret=self.opts.get('return', ''),
show_jid=show_jid,
verbose=show_verbose,
+ gather_job_timeout=self.opts['gather_job_timeout'],
**self.eauth)
# add it to our iterators and to the minion_tracker
iters.append(new_iter)
diff --git a/salt/client/__init__.py b/salt/client/__init__.py
index 504f5ed..71e1111 100644
--- a/salt/client/__init__.py
+++ b/salt/client/__init__.py
@@ -410,6 +410,12 @@ class LocalClient(object):
'ret': ret,
'batch': batch,
'raw': kwargs.get('raw', False)}
+
+ if 'timeout' in kwargs:
+ opts['timeout'] = kwargs['timeout']
+ if 'gather_job_timeout' in kwargs:
+ opts['gather_job_timeout'] = kwargs['gather_job_timeout']
+
for key, val in six.iteritems(self.opts):
if key not in opts:
opts[key] = val
diff --git a/tests/unit/cli/batch_test.py b/tests/unit/cli/batch_test.py
index 7739689..5a67c6a 100644
--- a/tests/unit/cli/batch_test.py
+++ b/tests/unit/cli/batch_test.py
@@ -24,7 +24,13 @@ class BatchTestCase(TestCase):
'''
def setUp(self):
- opts = {'batch': '', 'conf_file': {}, 'tgt': '', 'transport': '', 'timeout': 5}
+ opts = {'batch': '',
+ 'conf_file': {},
+ 'tgt': '',
+ 'transport': '',
+ 'timeout': 5,
+ 'gather_job_timeout': 5}
+
mock_client = MagicMock()
with patch('salt.client.get_local_client', MagicMock(return_value=mock_client)):
with patch('salt.client.LocalClient.cmd_iter', MagicMock(return_value=[])):
--
2.10.1