Skip to content

Commit

Permalink
fix: Display linux name of interfaces (#9)
Browse files Browse the repository at this point in the history
* fix: Display linux name of interfaces

Signed-off-by: Nalini Chervela <nalini_chervela@dell.com>
  • Loading branch information
nchervela committed Sep 11, 2018
1 parent 024513d commit 02c8842
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 31 deletions.
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.69])
AC_INIT([opx-snmp], [1.2.1], [ops-dev@lists.openswitch.net])
AC_INIT([opx-snmp], [1.2.2], [ops-dev@lists.openswitch.net])
AM_INIT_AUTOMAKE([foreign])
AC_CONFIG_SRCDIR([config.h.in])
AC_CONFIG_HEADERS([config.h])
Expand Down
6 changes: 6 additions & 0 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
opx-snmp (1.2.2) unstable; urgency=medium

* Update: Display interface names in the same format as linux

-- Dell EMC <ops-dev@lists.openswitch.net> Tue, 11 Sep 2018 12:30:00 -0800

opx-snmp (1.2.1) unstable; urgency=medium

* Update: Remove postinst script
Expand Down
33 changes: 3 additions & 30 deletions lib/python/opx_snmp/if_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,33 +35,6 @@ def if_name_get(idx, nextf):
cps_key_attr_data_get(r, 'if/interfaces/interface/name')
)

###########################################################################
#
# Map the NAS name of an interface to the SNMP name
#

def if_name_map(nm):
if nm is None:
return None
if nm.find('null') == 0 or nm.find('npu') == 0:
return nm
if nm.find('eth') == 0:
return 'mgmt1/1/{0}'.format(int(nm[3:]) + 1)
if nm.find('br') == 0:
return nm.replace('br', 'vlan', 1)
if nm.find('bond') == 0:
return nm.replace('bond', 'port-channel', 1)
if nm.find('lo') == 0:
return nm.replace('lo', 'loopback', 1)
s = nm.split('-')
result = 'ethernet{0}/{1}/{2}'.format(int(s[0][1], 16),
s[0][2:].lstrip('0'),
s[1].lstrip('0')
)
if len(s) > 2 and s[2] != '0':
result += ':' + s[2].lstrip('0')
return result

###########################################################################
#
# Helper functions for forming handler results
Expand Down Expand Up @@ -117,17 +90,17 @@ def if_idx_get_next(module, name):

def if_descr_get(module, name):
r = if_name_get(name[-1], False)
return None if r is None else result_get(name, (r[0], v2c.OctetString(if_name_map(r[1]))))
return None if r is None else result_get(name, (r[0], v2c.OctetString(r[1])))


def if_descr_get_first(module, name):
r = if_name_get(None, True)
return None if r is None else result_get_first(name, (r[0], v2c.OctetString(if_name_map(r[1]))))
return None if r is None else result_get_first(name, (r[0], v2c.OctetString(r[1])))


def if_descr_get_next(module, name):
r = if_name_get(name[-1], True)
return None if r is None else result_get_next(name, (r[0], v2c.OctetString(if_name_map(r[1]))))
return None if r is None else result_get_next(name, (r[0], v2c.OctetString(r[1])))

###########################################################################
#
Expand Down

0 comments on commit 02c8842

Please sign in to comment.