nxos_vlan refactor to support non structured output (#43805)

* nxos_vlan refactor to support non structured output

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* unittest fix

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* minor fixes

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* use check_rc

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* address review comment

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>

* remove additional return statement

* address Nate's review

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
Trishna Guha
2018-08-10 21:03:56 +05:30
committed by GitHub
parent f221105882
commit 96346938ee
9 changed files with 197 additions and 147 deletions

View File

@@ -154,7 +154,18 @@ class Cli:
connection = self._get_connection()
try:
return connection.run_commands(commands, check_rc)
out = connection.run_commands(commands, check_rc)
if check_rc == 'retry_json':
capabilities = self.get_capabilities()
network_api = capabilities.get('network_api')
if network_api == 'cliconf' and out:
for index, resp in enumerate(out):
if 'Invalid command at' in resp and 'json' in resp:
if commands[index]['output'] == 'json':
commands[index]['output'] = 'text'
out = connection.run_commands(commands, check_rc)
return out
except ConnectionError as exc:
self._module.fail_json(msg=to_text(exc))