From 75b8cf6ab3cb0afb91702118e64b7e872d6f2e9d Mon Sep 17 00:00:00 2001 From: Peter Sprygada Date: Mon, 4 Jul 2016 22:14:54 -0400 Subject: [PATCH] captures the responses from running commands and adds response to object The Command object can now store the response from executing the command to allow it to be retrieved later by command name. This update will update the Command instance with the response before returning. --- lib/ansible/module_utils/network.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/ansible/module_utils/network.py b/lib/ansible/module_utils/network.py index fbca8f05b0b..d3cedf997e2 100644 --- a/lib/ansible/module_utils/network.py +++ b/lib/ansible/module_utils/network.py @@ -16,6 +16,7 @@ # You should have received a copy of the GNU General Public License # along with Ansible. If not, see . # +import itertools from ansible.module_utils.basic import AnsibleModule from ansible.module_utils.basic import env_fallback, get_exception @@ -68,12 +69,15 @@ def disconnect(module): class Command(object): - def __init__(self, command, output=None, prompt=None, response=None): + def __init__(self, command, output=None, prompt=None, response=None, + is_reboot=False, delay=0): + self.command = command self.output = output self.prompt = prompt self.response = response - self.conditions = set() + self.is_reboot = is_reboot + self.delay = delay def __str__(self): return self.command @@ -103,7 +107,10 @@ class Cli(object): self.commands.extend(commands) def run_commands(self): - return self.connection.run_commands(self.commands) + responses = self.connection.run_commands(self.commands) + for resp, cmd in itertools.izip(responses, self.commands): + cmd.response = resp + return responses class Config(object):