mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-28 21:31:26 -07:00
added response_timestamps to ios_xr_command module (#50095)
This commit is contained in:
parent
daf1cfbde0
commit
2a0c356da9
4 changed files with 17 additions and 6 deletions
|
@ -24,6 +24,7 @@ import json
|
|||
|
||||
from ansible.errors import AnsibleConnectionFailure
|
||||
from ansible.module_utils._text import to_text
|
||||
from ansible.module_utils.basic import get_timestamp
|
||||
from ansible.module_utils.common._collections_compat import Mapping
|
||||
from ansible.module_utils.connection import ConnectionError
|
||||
from ansible.module_utils.network.common.config import NetworkConfig, dumps
|
||||
|
@ -172,10 +173,11 @@ class Cliconf(CliconfBase):
|
|||
|
||||
self.send_command(**cmd_obj)
|
||||
|
||||
def run_commands(self, commands=None, check_rc=True):
|
||||
def run_commands(self, commands=None, check_rc=True, return_timestamps=False):
|
||||
if commands is None:
|
||||
raise ValueError("'commands' value is required")
|
||||
responses = list()
|
||||
timestamps = list()
|
||||
for cmd in to_list(commands):
|
||||
if not isinstance(cmd, Mapping):
|
||||
cmd = {'command': cmd}
|
||||
|
@ -185,6 +187,7 @@ class Cliconf(CliconfBase):
|
|||
raise ValueError("'output' value %s is not supported for run_commands" % output)
|
||||
|
||||
try:
|
||||
timestamp = get_timestamp()
|
||||
out = self.send_command(**cmd)
|
||||
except AnsibleConnectionFailure as e:
|
||||
if check_rc:
|
||||
|
@ -203,7 +206,11 @@ class Cliconf(CliconfBase):
|
|||
pass
|
||||
|
||||
responses.append(out)
|
||||
return responses
|
||||
timestamps.append(timestamp)
|
||||
if return_timestamps:
|
||||
return responses, timestamps
|
||||
else:
|
||||
return responses
|
||||
|
||||
def discard_changes(self):
|
||||
self.send_command('abort')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue