mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #16573 from privateip/network
captures the responses from running commands and adds response to object
This commit is contained in:
commit
58eab8ee9f
1 changed files with 10 additions and 3 deletions
|
@ -16,6 +16,7 @@
|
||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
|
||||||
#
|
#
|
||||||
|
import itertools
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
from ansible.module_utils.basic import env_fallback, get_exception
|
from ansible.module_utils.basic import env_fallback, get_exception
|
||||||
|
@ -68,12 +69,15 @@ def disconnect(module):
|
||||||
|
|
||||||
class Command(object):
|
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.command = command
|
||||||
self.output = output
|
self.output = output
|
||||||
self.prompt = prompt
|
self.prompt = prompt
|
||||||
self.response = response
|
self.response = response
|
||||||
self.conditions = set()
|
self.is_reboot = is_reboot
|
||||||
|
self.delay = delay
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.command
|
return self.command
|
||||||
|
@ -103,7 +107,10 @@ class Cli(object):
|
||||||
self.commands.extend(commands)
|
self.commands.extend(commands)
|
||||||
|
|
||||||
def run_commands(self):
|
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):
|
class Config(object):
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue