added timestamps to nxos_command module (#50261)

* added timestamps to nxos_command module

nxos_command module now returns timestamps field, which shows command execution time

* –fixed unit test failure for /lib/ansible/module_utils/basic

* cosmetic changes to align with PEP 8
This commit is contained in:
vaneuk 2019-01-17 07:44:31 +03:00 committed by Trishna Guha
parent fdb91a5c02
commit e150943314
5 changed files with 45 additions and 20 deletions

View file

@ -23,6 +23,7 @@ import json
import re
from ansible.errors import AnsibleConnectionFailure
from ansible.module_utils.basic import get_timestamp
from ansible.module_utils._text import to_bytes, to_text
from ansible.module_utils.common._collections_compat import Mapping
from ansible.module_utils.connection import ConnectionError
@ -187,6 +188,7 @@ class Cliconf(CliconfBase):
raise ValueError("'commands' value is required")
responses = list()
timestamps = list()
for cmd in to_list(commands):
if not isinstance(cmd, Mapping):
cmd = {'command': cmd}
@ -196,6 +198,7 @@ class Cliconf(CliconfBase):
cmd['command'] = self._get_command_with_output(cmd['command'], output)
try:
timestamp = get_timestamp()
out = self.send_command(**cmd)
except AnsibleConnectionFailure as e:
if check_rc is True:
@ -214,7 +217,8 @@ class Cliconf(CliconfBase):
pass
responses.append(out)
return responses
timestamps.append(timestamp)
return responses, timestamps
def get_device_operations(self):
return {