nxos_vrf_interface fix (#33249)

Signed-off-by: Trishna Guha <trishnaguha17@gmail.com>
This commit is contained in:
Trishna Guha 2017-11-27 22:56:39 +05:30 committed by GitHub
parent 25a465ffcb
commit 7b19c28438
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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,7 +158,7 @@ def get_interface_info(interface, module):
if not interface.startswith('loopback'):
interface = interface.capitalize()
command = 'show run | section interface.{0}'.format(interface)
command = 'show run interface {0}'.format(interface)
vrf_regex = r".*vrf\s+member\s+(?P<vrf>\S+).*"
try: