summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorNataliia Solomko <natalirs1985@gmail.com>2025-10-17 15:21:41 +0300
committerNataliia Solomko <natalirs1985@gmail.com>2025-10-21 17:30:51 +0300
commit4c08b0694c65f1bb434538980a44a94e5ae15d24 (patch)
tree3dd2693a0b88338d37583aa4dbc837ef9153c246 /python
parent69a9b93f71c818bf134ea06ad73d86a513628f06 (diff)
downloadvyos-1x-4c08b0694c65f1bb434538980a44a94e5ae15d24.tar.gz
vyos-1x-4c08b0694c65f1bb434538980a44a94e5ae15d24.zip
T7938: VPP: Rewrite sFlow implementation
Execute commands for vpp sflow with API calls. Use values for polling interval and sampling rate from 'system sflow'. Add op-mode command
Diffstat (limited to 'python')
-rw-r--r--python/vyos/vpp/sflow/__init__.py3
-rw-r--r--python/vyos/vpp/sflow/sflow.py49
2 files changed, 52 insertions, 0 deletions
diff --git a/python/vyos/vpp/sflow/__init__.py b/python/vyos/vpp/sflow/__init__.py
new file mode 100644
index 000000000..8d27be75a
--- /dev/null
+++ b/python/vyos/vpp/sflow/__init__.py
@@ -0,0 +1,3 @@
+from .sflow import SFlow
+
+__all__ = ['SFlow']
diff --git a/python/vyos/vpp/sflow/sflow.py b/python/vyos/vpp/sflow/sflow.py
new file mode 100644
index 000000000..7677d32b3
--- /dev/null
+++ b/python/vyos/vpp/sflow/sflow.py
@@ -0,0 +1,49 @@
+#
+# Copyright (C) VyOS Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along
+# with this program; if not, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+from vyos.vpp import VPPControl
+
+
+class SFlow:
+ def __init__(self):
+ self.vpp = VPPControl()
+
+ def enable_sflow(self, interface):
+ """Enable sFlow on interface"""
+ self.vpp.api.sflow_enable_disable(
+ enable_disable=True,
+ sw_if_index=self.vpp.get_sw_if_index(interface),
+ )
+
+ def disable_sflow(self, interface):
+ """Disable sFlow on interface"""
+ self.vpp.api.sflow_enable_disable(
+ enable_disable=False,
+ sw_if_index=self.vpp.get_sw_if_index(interface),
+ )
+
+ def set_sampling_rate(self, sample_rate):
+ """Set sFlow sampling-rate"""
+ self.vpp.api.sflow_sampling_rate(sampling_N=sample_rate)
+
+ def set_polling_interval(self, interval):
+ """Set sFlow polling interval"""
+ self.vpp.api.sflow_polling_interval(polling_S=interval)
+
+ def set_header_bytes(self, header_bytes):
+ """Set sFlow maximum header length in bytes"""
+ self.vpp.api.sflow_header_bytes(header_B=header_bytes)