summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOle Troan <ot@cisco.com>2021-03-29 21:12:53 +0200
committerDave Wallace <dwallacelf@gmail.com>2021-03-30 14:27:53 +0000
commit3daca3f9f40d1e8c421b6905252f511e7c4e7bdd (patch)
tree18daf738b3ad30529cd343d747025d50961ce68e
parent8c517c8fb44e7003ecdb615bc03163536e24d4d4 (diff)
stats: python: handle when pattern is not list in ls
The reimplementation of python stats module mishandled the case where pattern to ls was not a list. Type: fix Signed-off-by: Ole Troan <ot@cisco.com> Change-Id: I9ba189423a76f2fd4298c4c4b19a0875f705d719
-rwxr-xr-xsrc/vpp-api/python/vpp_papi/vpp_stats.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/vpp-api/python/vpp_papi/vpp_stats.py b/src/vpp-api/python/vpp_papi/vpp_stats.py
index 30bf930469a..18f13e9c4c0 100755
--- a/src/vpp-api/python/vpp_papi/vpp_stats.py
+++ b/src/vpp-api/python/vpp_papi/vpp_stats.py
@@ -247,6 +247,8 @@ class VPPStats():
# pylint: disable=invalid-name
if not self.connected:
self.connect()
+ if not isinstance(patterns, list):
+ patterns = [patterns]
regex = [re.compile(i) for i in patterns]
return [k for k, v in self.directory.items()
if any(re.match(pattern, k) for pattern in regex)]
@@ -499,6 +501,13 @@ class TestStats(unittest.TestCase):
data = self.stat.dump(directory)
print(data)
+ def test_sys_nodes(self):
+ '''Test /sys/nodes'''
+ counters = self.stat.ls('^/sys/node')
+ print('COUNTERS:', counters)
+ print('/sys/node', self.stat.dump(counters))
+ print('/net/route/to', self.stat['/net/route/to'])
+
if __name__ == '__main__':
import cProfile
from pstats import Stats