blob: a7374d1b1d8212766636df1920963f53106f7bd2 [file] [log] [blame]
Neale Ranns5281a902019-07-23 08:16:19 -07001"""
2 QoS
3
4 object abstractions for representing QoS config VPP
5"""
6
7from vpp_object import VppObject
8
9
10class VppQosRecord(VppObject):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020011 """QoS Record(ing) configuration"""
Neale Ranns5281a902019-07-23 08:16:19 -070012
13 def __init__(self, test, intf, source):
14 self._test = test
15 self.intf = intf
16 self.source = source
17
18 def add_vpp_config(self):
19 self._test.vapi.qos_record_enable_disable(
20 enable=1,
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020021 record={"sw_if_index": self.intf.sw_if_index, "input_source": self.source},
22 )
Neale Ranns5281a902019-07-23 08:16:19 -070023 self._test.registry.register(self, self._test.logger)
24 return self
25
26 def remove_vpp_config(self):
27 self._test.vapi.qos_record_enable_disable(
28 enable=0,
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020029 record={"sw_if_index": self.intf.sw_if_index, "input_source": self.source},
30 )
Neale Ranns5281a902019-07-23 08:16:19 -070031
32 def query_vpp_config(self):
33 rs = self._test.vapi.qos_record_dump()
34
35 for r in rs:
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020036 if (
37 self.intf.sw_if_index == r.record.sw_if_index
38 and self.source == r.record.input_source
39 ):
Neale Ranns5281a902019-07-23 08:16:19 -070040 return True
41 return False
42
43 def object_id(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020044 return "qos-record-%s-%d" % (self.intf, self.source)
Neale Ranns5281a902019-07-23 08:16:19 -070045
46
Neale Ranns83832e72019-07-31 02:48:02 -070047class VppQosStore(VppObject):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020048 """QoS Store(ing) configuration"""
Neale Ranns83832e72019-07-31 02:48:02 -070049
50 def __init__(self, test, intf, source, value):
51 self._test = test
52 self.intf = intf
53 self.source = source
54 self.value = value
55
56 def add_vpp_config(self):
57 self._test.vapi.qos_store_enable_disable(
58 enable=1,
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020059 store={
60 "sw_if_index": self.intf.sw_if_index,
61 "input_source": self.source,
62 "value": self.value,
63 },
64 )
Neale Ranns83832e72019-07-31 02:48:02 -070065 self._test.registry.register(self, self._test.logger)
66 return self
67
68 def remove_vpp_config(self):
69 self._test.vapi.qos_store_enable_disable(
70 enable=0,
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020071 store={"sw_if_index": self.intf.sw_if_index, "input_source": self.source},
72 )
Neale Ranns83832e72019-07-31 02:48:02 -070073
74 def query_vpp_config(self):
75 rs = self._test.vapi.qos_store_dump()
76
77 for r in rs:
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020078 if (
79 self.intf.sw_if_index == r.store.sw_if_index
80 and self.source == r.store.input_source
81 and self.value == r.store.value
82 ):
Neale Ranns83832e72019-07-31 02:48:02 -070083 return True
84 return False
85
86 def object_id(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020087 return "qos-store-%s-%d" % (self.intf, self.source)
Neale Ranns83832e72019-07-31 02:48:02 -070088
89
Neale Ranns5281a902019-07-23 08:16:19 -070090class VppQosEgressMap(VppObject):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020091 """QoS Egress Map(ping) configuration"""
Neale Ranns5281a902019-07-23 08:16:19 -070092
93 def __init__(self, test, id, rows):
94 self._test = test
95 self.id = id
96 self.rows = rows
97
98 def add_vpp_config(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020099 self._test.vapi.qos_egress_map_update(map={"id": self.id, "rows": self.rows})
Neale Ranns5281a902019-07-23 08:16:19 -0700100 self._test.registry.register(self, self._test.logger)
101 return self
102
103 def remove_vpp_config(self):
104 self._test.vapi.qos_egress_map_delete(id=self.id)
105
106 def query_vpp_config(self):
107 rs = self._test.vapi.qos_egress_map_dump()
108
109 for r in rs:
110 if self.id == r.map.id:
111 return True
112 return False
113
114 def object_id(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200115 return "qos-map-%d" % (self.id)
Neale Ranns5281a902019-07-23 08:16:19 -0700116
117
118class VppQosMark(VppObject):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200119 """QoS Mark(ing) configuration"""
Neale Ranns5281a902019-07-23 08:16:19 -0700120
121 def __init__(self, test, intf, map, source):
122 self._test = test
123 self.intf = intf
124 self.source = source
125 self.map = map
126
127 def add_vpp_config(self):
128 self._test.vapi.qos_mark_enable_disable(
129 enable=1,
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200130 mark={
131 "sw_if_index": self.intf.sw_if_index,
132 "map_id": self.map.id,
133 "output_source": self.source,
134 },
135 )
Neale Ranns5281a902019-07-23 08:16:19 -0700136 self._test.registry.register(self, self._test.logger)
137 return self
138
139 def remove_vpp_config(self):
140 self._test.vapi.qos_mark_enable_disable(
141 enable=0,
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200142 mark={"sw_if_index": self.intf.sw_if_index, "output_source": self.source},
143 )
Neale Ranns5281a902019-07-23 08:16:19 -0700144
145 def query_vpp_config(self):
146 ms = self._test.vapi.qos_mark_dump()
147
148 for m in ms:
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200149 if (
150 self.intf.sw_if_index == m.mark.sw_if_index
151 and self.source == m.mark.output_source
152 and self.map.id == m.mark.map_id
153 ):
Neale Ranns5281a902019-07-23 08:16:19 -0700154 return True
155 return False
156
157 def object_id(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +0200158 return "qos-mark-%s-%d" % (self.intf, self.source)