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

@@ -22,6 +22,7 @@ __metaclass__ = type
import json
from units.compat.mock import patch
from ansible.module_utils.basic import get_timestamp
from ansible.modules.network.nxos import nxos_command
from .nxos_module import TestNxosModule, load_fixture, set_module_args
@@ -44,6 +45,7 @@ class TestNxosCommandModule(TestNxosModule):
def load_from_file(*args, **kwargs):
module, commands = args
output = list()
timestamps = list()
for item in commands:
try:
@@ -53,7 +55,8 @@ class TestNxosCommandModule(TestNxosModule):
command = item['command']
filename = '%s.txt' % str(command).replace(' ', '_')
output.append(load_fixture('nxos_command', filename))
return output
timestamps.append(get_timestamp())
return output, timestamps
self.run_commands.side_effect = load_from_file