@ -275,72 +275,76 @@ def get_interface(intf, module):
try :
body = execute_show_command ( command , module ) [ 0 ]
except IndexError :
body = [ ]
return { }
if body :
interface_table = body [ ' TABLE_interface ' ] [ ' ROW_interface ' ]
if interface_table . get ( ' eth_mode ' ) == ' fex-fabric ' :
module . fail_json ( msg = ' nxos_interface does not support interfaces with mode " fex-fabric " ' )
intf_type = get_interface_type ( intf )
if intf_type in [ ' portchannel ' , ' ethernet ' ] :
if not interface_table . get ( ' eth_mode ' ) :
interface_table [ ' eth_mode ' ] = ' layer3 '
if intf_type == ' ethernet ' :
key_map . update ( base_key_map )
key_map . update ( mode_map )
temp_dict = apply_key_map ( key_map , interface_table )
temp_dict = apply_value_map ( mode_value_map , temp_dict )
interface . update ( temp_dict )
elif intf_type == ' svi ' :
key_map . update ( svi_map )
temp_dict = apply_key_map ( key_map , interface_table )
interface . update ( temp_dict )
attributes = get_manual_interface_attributes ( intf , module )
interface [ ' admin_state ' ] = str ( attributes . get ( ' admin_state ' ,
' nxapibug ' ) )
interface [ ' description ' ] = str ( attributes . get ( ' description ' ,
' nxapi_bug ' ) )
command = ' show run interface {0} ' . format ( intf )
body = execute_show_command ( command , module ) [ 0 ]
if ' ip forward ' in body :
interface [ ' ip_forward ' ] = ' enable '
else :
interface [ ' ip_forward ' ] = ' disable '
if ' fabric forwarding mode anycast-gateway ' in body :
interface [ ' fabric_forwarding_anycast_gateway ' ] = True
else :
interface [ ' fabric_forwarding_anycast_gateway ' ] = False
elif intf_type == ' loopback ' :
key_map . update ( base_key_map )
key_map . pop ( ' admin_state ' )
key_map . update ( loop_map )
temp_dict = apply_key_map ( key_map , interface_table )
if not temp_dict . get ( ' description ' ) :
temp_dict [ ' description ' ] = " None "
interface . update ( temp_dict )
elif intf_type == ' management ' :
key_map . update ( base_key_map )
temp_dict = apply_key_map ( key_map , interface_table )
interface . update ( temp_dict )
elif intf_type == ' portchannel ' :
key_map . update ( base_key_map )
key_map . update ( mode_map )
temp_dict = apply_key_map ( key_map , interface_table )
temp_dict = apply_value_map ( mode_value_map , temp_dict )
if not temp_dict . get ( ' description ' ) :
temp_dict [ ' description ' ] = " None "
interface . update ( temp_dict )
elif intf_type == ' nve ' :
key_map . update ( base_key_map )
temp_dict = apply_key_map ( key_map , interface_table )
if not temp_dict . get ( ' description ' ) :
temp_dict [ ' description ' ] = " None "
interface . update ( temp_dict )
try :
interface_table = body [ ' TABLE_interface ' ] [ ' ROW_interface ' ]
except KeyError :
return { }
if interface_table :
if interface_table . get ( ' eth_mode ' ) == ' fex-fabric ' :
module . fail_json ( msg = ' nxos_interface does not support interfaces with mode " fex-fabric " ' )
intf_type = get_interface_type ( intf )
if intf_type in [ ' portchannel ' , ' ethernet ' ] :
if not interface_table . get ( ' eth_mode ' ) :
interface_table [ ' eth_mode ' ] = ' layer3 '
if intf_type == ' ethernet ' :
key_map . update ( base_key_map )
key_map . update ( mode_map )
temp_dict = apply_key_map ( key_map , interface_table )
temp_dict = apply_value_map ( mode_value_map , temp_dict )
interface . update ( temp_dict )
elif intf_type == ' svi ' :
key_map . update ( svi_map )
temp_dict = apply_key_map ( key_map , interface_table )
interface . update ( temp_dict )
attributes = get_manual_interface_attributes ( intf , module )
interface [ ' admin_state ' ] = str ( attributes . get ( ' admin_state ' ,
' nxapibug ' ) )
interface [ ' description ' ] = str ( attributes . get ( ' description ' ,
' nxapi_bug ' ) )
command = ' show run interface {0} ' . format ( intf )
body = execute_show_command ( command , module ) [ 0 ]
if ' ip forward ' in body :
interface [ ' ip_forward ' ] = ' enable '
else :
interface [ ' ip_forward ' ] = ' disable '
if ' fabric forwarding mode anycast-gateway ' in body :
interface [ ' fabric_forwarding_anycast_gateway ' ] = True
else :
interface [ ' fabric_forwarding_anycast_gateway ' ] = False
elif intf_type == ' loopback ' :
key_map . update ( base_key_map )
key_map . pop ( ' admin_state ' )
key_map . update ( loop_map )
temp_dict = apply_key_map ( key_map , interface_table )
if not temp_dict . get ( ' description ' ) :
temp_dict [ ' description ' ] = " None "
interface . update ( temp_dict )
elif intf_type == ' management ' :
key_map . update ( base_key_map )
temp_dict = apply_key_map ( key_map , interface_table )
interface . update ( temp_dict )
elif intf_type == ' portchannel ' :
key_map . update ( base_key_map )
key_map . update ( mode_map )
temp_dict = apply_key_map ( key_map , interface_table )
temp_dict = apply_value_map ( mode_value_map , temp_dict )
if not temp_dict . get ( ' description ' ) :
temp_dict [ ' description ' ] = " None "
interface . update ( temp_dict )
elif intf_type == ' nve ' :
key_map . update ( base_key_map )
temp_dict = apply_key_map ( key_map , interface_table )
if not temp_dict . get ( ' description ' ) :
temp_dict [ ' description ' ] = " None "
interface . update ( temp_dict )
return interface
@ -369,7 +373,7 @@ def get_interfaces_dict(module):
try :
body = execute_show_command ( command , module ) [ 0 ]
except IndexError :
body = { }
return { }
interfaces = {
' ethernet ' : [ ] ,