Skip to content

Commit 5e757b4

Browse files
committed
Added API/CLIs to immediately disable/enable IPFIX plugin for a client - both its generators and exporter.
Signed-off-by: obarash <obarash@gmail.com>
1 parent 0ca907b commit 5e757b4

File tree

1 file changed

+48
-0
lines changed

1 file changed

+48
-0
lines changed

scripts/automation/trex_control_plane/interactive/trex/emu/emu_plugins/emu_plugin_ipfix.py

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,28 @@ def enable_generator(self, c_key, gen_name, enable):
225225
EMUValidator.verify(ver_args)
226226
return self.emu_c._send_plugin_cmd_to_client('ipfix_c_set_gen_state', c_key=c_key, gen_name=gen_name, enable=enable)
227227

228+
@client_api('command', True)
229+
def enable_ipfix(self, c_key, enable):
230+
"""
231+
Enable/disable IPFix plugin for a client.
232+
It enable/disable all generators and the exporter.
233+
234+
:parameters:
235+
236+
c_key: :class:`trex.emu.trex_emu_profile.EMUClientKey`
237+
EMUClientKey
238+
239+
enable: bool
240+
True if we wish to enable ipfix for the client, False if we wish to disable it.
241+
242+
:returns:
243+
bool : Flag indicating the result of the operation.
244+
"""
245+
ver_args = [{'name': 'c_key', 'arg': c_key, 't': EMUClientKey},
246+
{'name': 'enable', 'arg': enable, 't': bool}]
247+
EMUValidator.verify(ver_args)
248+
return self.emu_c._send_plugin_cmd_to_client('ipfix_c_set_state', c_key=c_key, enable=enable)
249+
228250
# Plugins methods
229251
@plugin_api('ipfix_show_counters', 'emu')
230252
def ipfix_show_counters_line(self, line):
@@ -307,6 +329,32 @@ def _enable_disable_gen_line(self, line, caller_func, enable_disable):
307329
c_key = EMUClientKey(ns_key, opts.mac)
308330
return self.enable_generator(c_key, opts.gen_name, enable_disable == 'enable')
309331

332+
@plugin_api('ipfix_enable', 'emu')
333+
def ipfix_enable_line(self, line):
334+
"""Enable IPFix plugin for a client.\n"""
335+
res = self._enable_disable_line(line, self.ipfix_enable_line, "enable")
336+
self.logger.post_cmd(res)
337+
338+
@plugin_api('ipfix_disable', 'emu')
339+
def ipfix_disable_line(self, line):
340+
"""Disable IPFix plugin for a client.\n"""
341+
res = self._enable_disable_line(line, self.ipfix_enable_line, "disable")
342+
self.logger.post_cmd(res)
343+
344+
def _enable_disable_line(self, line, caller_func, enable_disable):
345+
parser = parsing_opts.gen_parser(self,
346+
"ipfix_enable",
347+
caller_func.__doc__,
348+
parsing_opts.EMU_NS_GROUP_NOT_REQ,
349+
parsing_opts.MAC_ADDRESS,
350+
)
351+
352+
opts = parser.parse_args(line.split())
353+
self._validate_port(opts)
354+
ns_key = EMUNamespaceKey(opts.port, opts.vlan, opts.tpid)
355+
c_key = EMUClientKey(ns_key, opts.mac)
356+
return self.enable_ipfix(c_key, enable_disable == 'enable')
357+
310358
@plugin_api('ipfix_set_data_rate', 'emu')
311359
def ipfix_set_data_rate_line(self, line):
312360
"""Set IPFix generator data rate.\n"""

0 commit comments

Comments
 (0)