1 from vpp_object import VppObject
2 from vpp_ip import INVALID_INDEX
6 """ sse2 qos action """
8 def __init__(self, type, dscp):
13 return {'type': self.type, 'dscp': self.dscp}
16 class VppPolicer(VppObject):
19 def __init__(self, test, name, cir, eir, commited_burst, excess_burst,
20 rate_type=0, round_type=0, type=0, color_aware=False,
21 conform_action=PolicerAction(1, 0),
22 exceed_action=PolicerAction(0, 0),
23 violate_action=PolicerAction(0, 0)):
28 self.commited_burst = commited_burst
29 self.excess_burst = excess_burst
30 self.rate_type = rate_type
31 self.round_type = round_type
33 self.color_aware = color_aware
34 self.conform_action = conform_action
35 self.exceed_action = exceed_action
36 self.violate_action = violate_action
37 self._policer_index = INVALID_INDEX
40 def policer_index(self):
41 return self._policer_index
43 def add_vpp_config(self):
44 r = self._test.vapi.policer_add_del(
45 name=self.name, cir=self.cir,
46 eir=self.eir, cb=self.commited_burst, eb=self.excess_burst,
47 rate_type=self.rate_type, round_type=self.round_type,
48 type=self.type, color_aware=self.color_aware,
49 conform_action=self.conform_action.encode(),
50 exceed_action=self.exceed_action.encode(),
51 violate_action=self.violate_action.encode())
52 self._test.registry.register(self, self._test.logger)
53 self._policer_index = r.policer_index
56 def remove_vpp_config(self):
57 self._test.vapi.policer_add_del(is_add=False, name=self.name)
58 self._policer_index = INVALID_INDEX
60 def query_vpp_config(self):
61 dump = self._test.vapi.policer_dump(
62 match_name_valid=True, match_name=self.name)
64 if policer.name == self.name:
69 return ("policer-%s" % (self.name))