summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrishna Guha <trishnaguha17@gmail.com>2017-11-27 22:56:39 +0530
committerToshio Kuratomi <a.badger@gmail.com>2017-12-06 12:26:34 -0800
commit4550dbc9dcefc4bfab7dd6364a4398fa7c5e9146 (patch)
tree78a74b97aeb4e24fed9a2a7994a5daca2f5fed7d
parentf78a60aaa68477f336815a942b7ef6777bd93edf (diff)
downloadansible-4550dbc9dcefc4bfab7dd6364a4398fa7c5e9146.tar.gz
nxos_vrf_interface fix (#33249)
Signed-off-by: Trishna Guha <trishnaguha17@gmail.com> (cherry picked from commit 7b19c2843810e55156a52435dcee5c0fc4aec8af)
-rw-r--r--lib/ansible/modules/network/nxos/nxos_vrf_interface.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/ansible/modules/network/nxos/nxos_vrf_interface.py b/lib/ansible/modules/network/nxos/nxos_vrf_interface.py
index ac3c200104..cd534aa391 100644
--- a/lib/ansible/modules/network/nxos/nxos_vrf_interface.py
+++ b/lib/ansible/modules/network/nxos/nxos_vrf_interface.py
@@ -121,10 +121,18 @@ def get_interface_mode(interface, intf_type, module):
if intf_type in ['ethernet', 'portchannel']:
body = execute_show_command(command, module)
- interface_table = body['TABLE_interface']['ROW_interface']
- mode = str(interface_table.get('eth_mode', 'layer3'))
- if mode == 'access' or mode == 'trunk':
- mode = 'layer2'
+ try:
+ interface_table = body['TABLE_interface']['ROW_interface']
+ except KeyError:
+ return mode
+
+ if interface_table and isinstance(interface_table, dict):
+ mode = str(interface_table.get('eth_mode', 'layer3'))
+ if mode == 'access' or mode == 'trunk':
+ mode = 'layer2'
+ else:
+ return mode
+
elif intf_type == 'loopback' or intf_type == 'svi':
mode = 'layer3'
return mode
@@ -150,8 +158,8 @@ def get_interface_info(interface, module):
if not interface.startswith('loopback'):
interface = interface.capitalize()
- command = 'show run | section interface.{0}'.format(interface)
- vrf_regex = ".*vrf\s+member\s+(?P<vrf>\S+).*"
+ command = 'show run interface {0}'.format(interface)
+ vrf_regex = r".*vrf\s+member\s+(?P<vrf>\S+).*"
try:
body = execute_show_command(command, module)