From 02c88429b61af77d204474c985ca5f3093b12ce7 Mon Sep 17 00:00:00 2001 From: nchervela <37422187+nchervela@users.noreply.github.com> Date: Tue, 11 Sep 2018 14:14:45 -0700 Subject: [PATCH] fix: Display linux name of interfaces (#9) * fix: Display linux name of interfaces Signed-off-by: Nalini Chervela --- configure.ac | 2 +- debian/changelog | 6 ++++++ lib/python/opx_snmp/if_handlers.py | 33 +++--------------------------- 3 files changed, 10 insertions(+), 31 deletions(-) diff --git a/configure.ac b/configure.ac index a7843a4..5e6495f 100644 --- a/configure.ac +++ b/configure.ac @@ -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]) diff --git a/debian/changelog b/debian/changelog index 7d5002e..dab6a24 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +opx-snmp (1.2.2) unstable; urgency=medium + + * Update: Display interface names in the same format as linux + + -- Dell EMC Tue, 11 Sep 2018 12:30:00 -0800 + opx-snmp (1.2.1) unstable; urgency=medium * Update: Remove postinst script diff --git a/lib/python/opx_snmp/if_handlers.py b/lib/python/opx_snmp/if_handlers.py index a858bce..432a583 100644 --- a/lib/python/opx_snmp/if_handlers.py +++ b/lib/python/opx_snmp/if_handlers.py @@ -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 @@ -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]))) ########################################################################### #