From 62f6e26789aa34f0546382a0c0dc65fdfecafee0 Mon Sep 17 00:00:00 2001 From: Andrey Vertiprahov Date: Fri, 27 Mar 2020 15:46:03 +0500 Subject: [PATCH 1/2] Add display_hints options to get_table script method. --- core/script/snmp/base.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/core/script/snmp/base.py b/core/script/snmp/base.py index 4838b54cea..297749c907 100644 --- a/core/script/snmp/base.py +++ b/core/script/snmp/base.py @@ -270,21 +270,27 @@ class SNMP(object): r, self.result = self.result, None return r - def get_table(self, oid, community_suffix=None, cached=False): + def get_table(self, oid, community_suffix=None, cached=False, display_hints=None): """ GETNEXT wrapper. Returns a hash of -> """ r = {} - for o, v in self.getnext(oid, community_suffix=community_suffix, cached=cached): + for o, v in self.getnext( + oid, community_suffix=community_suffix, cached=cached, display_hints=display_hints + ): r[int(o.split(".")[-1])] = v return r - def join_tables(self, oid1, oid2, community_suffix=None, cached=False): + def join_tables(self, oid1, oid2, community_suffix=None, cached=False, display_hints=None): """ Generator returning a rows of two snmp tables joined by index """ - t1 = self.get_table(oid1, community_suffix=community_suffix, cached=cached) - t2 = self.get_table(oid2, community_suffix=community_suffix, cached=cached) + t1 = self.get_table( + oid1, community_suffix=community_suffix, cached=cached, display_hints=display_hints + ) + t2 = self.get_table( + oid2, community_suffix=community_suffix, cached=cached, display_hints=display_hints + ) for k1, v1 in six.iteritems(t1): try: yield v1, t2[k1] -- GitLab From 48924c03fe74d4ee5f6e3d95e2fc64192958a1f9 Mon Sep 17 00:00:00 2001 From: Andrey Vertiprahov Date: Fri, 27 Mar 2020 15:50:47 +0500 Subject: [PATCH 2/2] Fix black. --- core/script/snmp/base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/script/snmp/base.py b/core/script/snmp/base.py index 297749c907..8fa936c95b 100644 --- a/core/script/snmp/base.py +++ b/core/script/snmp/base.py @@ -276,7 +276,7 @@ class SNMP(object): """ r = {} for o, v in self.getnext( - oid, community_suffix=community_suffix, cached=cached, display_hints=display_hints + oid, community_suffix=community_suffix, cached=cached, display_hints=display_hints ): r[int(o.split(".")[-1])] = v return r -- GitLab