Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nxos_config and nxos_facts - fixes for N35 platform. #32762

Merged
merged 5 commits into from
Nov 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 15 additions & 3 deletions lib/ansible/modules/network/nxos/nxos_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
from ansible.module_utils.nxos import get_config, load_config, run_commands
from ansible.module_utils.nxos import nxos_argument_spec
from ansible.module_utils.nxos import check_args as nxos_check_args
from ansible.module_utils.network_common import to_list


def get_running_config(module, config=None):
Expand All @@ -296,6 +297,17 @@ def get_candidate(module):
return candidate


def execute_show_commands(module, commands, output='text'):
cmds = []
for command in to_list(commands):
cmd = { 'command': command,
'output': output,
}
cmds.append(cmd)
body = run_commands(module, cmds)
return body


def main():
""" main entry point for module execution
"""
Expand Down Expand Up @@ -396,7 +408,7 @@ def main():
module.params['save_when'] = 'always'

if module.params['save_when'] != 'never':
output = run_commands(module, ['show running-config', 'show startup-config'])
output = execute_show_commands(module, ['show running-config', 'show startup-config'])

running_config = NetworkConfig(indent=1, contents=output[0], ignore_lines=diff_ignore_lines)
startup_config = NetworkConfig(indent=1, contents=output[1], ignore_lines=diff_ignore_lines)
Expand All @@ -413,7 +425,7 @@ def main():

if module._diff:
if not running_config:
output = run_commands(module, 'show running-config')
output = execute_show_commands(module, 'show running-config')
contents = output[0]
else:
contents = running_config.config_text
Expand All @@ -430,7 +442,7 @@ def main():

elif module.params['diff_against'] == 'startup':
if not startup_config:
output = run_commands(module, 'show startup-config')
output = execute_show_commands(module, 'show startup-config')
contents = output[0]
else:
contents = output[0]
Expand Down
4 changes: 2 additions & 2 deletions lib/ansible/modules/network/nxos/nxos_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
from ansible.module_utils.nxos import run_commands, get_config
from ansible.module_utils.nxos import nxos_argument_spec, check_args
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.six import iteritems
from ansible.module_utils.six import string_types, iteritems


class FactsBase(object):
Expand Down Expand Up @@ -290,7 +290,7 @@ def populate(self):
self.facts['interfaces'] = self.populate_interfaces(data)

data = self.run('show ipv6 interface', 'json')
if data:
if data and not isinstance(data, string_types):
self.parse_ipv6_interfaces(data)

data = self.run('show lldp neighbors')
Expand Down