CFLOW object for IPFIX exporter and Flowprobe feature
| 54 | |
| 55 | |
| 56 | class VppCFLOW(VppObject): |
| 57 | """CFLOW object for IPFIX exporter and Flowprobe feature""" |
| 58 | |
| 59 | def __init__( |
| 60 | self, |
| 61 | test, |
| 62 | intf="pg2", |
| 63 | active=0, |
| 64 | passive=0, |
| 65 | timeout=100, |
| 66 | mtu=1024, |
| 67 | datapath="l2", |
| 68 | layer="l2 l3 l4", |
| 69 | direction="tx", |
| 70 | ): |
| 71 | self._test = test |
| 72 | self._intf = intf |
| 73 | self._intf_obj = getattr(self._test, intf) |
| 74 | self._active = active |
| 75 | if passive == 0 or passive < active: |
| 76 | self._passive = active + 1 |
| 77 | else: |
| 78 | self._passive = passive |
| 79 | self._datapath = datapath # l2 ip4 ip6 |
| 80 | self._collect = layer # l2 l3 l4 |
| 81 | self._direction = direction # rx tx both |
| 82 | self._timeout = timeout |
| 83 | self._mtu = mtu |
| 84 | self._configured = False |
| 85 | |
| 86 | def add_vpp_config(self): |
| 87 | self.enable_exporter() |
| 88 | l2_flag = 0 |
| 89 | l3_flag = 0 |
| 90 | l4_flag = 0 |
| 91 | if "l2" in self._collect.lower(): |
| 92 | l2_flag = VppEnum.vl_api_flowprobe_record_flags_t.FLOWPROBE_RECORD_FLAG_L2 |
| 93 | if "l3" in self._collect.lower(): |
| 94 | l3_flag = VppEnum.vl_api_flowprobe_record_flags_t.FLOWPROBE_RECORD_FLAG_L3 |
| 95 | if "l4" in self._collect.lower(): |
| 96 | l4_flag = VppEnum.vl_api_flowprobe_record_flags_t.FLOWPROBE_RECORD_FLAG_L4 |
| 97 | self._test.vapi.flowprobe_set_params( |
| 98 | record_flags=(l2_flag | l3_flag | l4_flag), |
| 99 | active_timer=self._active, |
| 100 | passive_timer=self._passive, |
| 101 | ) |
| 102 | self.enable_flowprobe_feature() |
| 103 | self._test.vapi.cli("ipfix flush") |
| 104 | self._configured = True |
| 105 | |
| 106 | def remove_vpp_config(self): |
| 107 | self.disable_exporter() |
| 108 | self.disable_flowprobe_feature() |
| 109 | self._test.vapi.cli("ipfix flush") |
| 110 | self._configured = False |
| 111 | |
| 112 | def enable_exporter(self): |
| 113 | self._test.vapi.set_ipfix_exporter( |
no outgoing calls