blob: 56ae67b145fe483cf4a4b25b0cb409b7153283ae [file] [log] [blame]
Hongjun Ni3efcd0d2019-06-10 19:43:48 +08001# Copyright (c) 2019. Vinci Consulting Corp. All Rights Reserved.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15import vpp_object
16
17
18class VppLbVip(vpp_object.VppObject):
Hongjun Ni3efcd0d2019-06-10 19:43:48 +080019 def __init__(self, test, pfx, sfx, port, protocol):
20 self._test = test
21 self.pfx = pfx
22 self.sfx = sfx
23 self.port = port
24 self.protocol = protocol
25
26 def add_vpp_config(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020027 self._test_vapi.lb_add_del_vip(
28 pfx=self.pfx, sfx=self.pfx, port=self.port, protocol=self.protocol
29 )
Hongjun Ni3efcd0d2019-06-10 19:43:48 +080030
31 self._test.registry.register(self, self._test.logger)
32
33 def remove_vpp_config(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020034 self._test.vapi.lb_add_del_vip(
35 pfx=self.pfx, sfx=self.pfx, port=self.port, protocol=self.protocol, is_del=1
36 )
Hongjun Ni3efcd0d2019-06-10 19:43:48 +080037
38 def query_vpp_config(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020039 details = self._test.vapi.lb_add_del_vip(
40 fx=self.pfx, sfx=self.pfx, port=self.port, protocol=self.protocol
41 )
Hongjun Ni3efcd0d2019-06-10 19:43:48 +080042 return True if self == details else False
43
44
45class VppLbAs(vpp_object.VppObject):
46 def __init__(self, test, pfx, port, protocol, app_srv, is_del, is_flush):
47 self._test = test
48 # this is the vip
49 self.pfx = pfx
50 self.port = port
51 self.protocol = protocol
52
53 self.app_srv = app_srv
54 self.is_del = is_del
55 self.is_flush = is_flush
56
57 def add_vpp_config(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020058 self._test_vapi.lb_add_del_as(
59 pfx=self.pfx,
60 port=self.port,
61 protocol=self.protocol,
62 app_srv=self.app_srv,
63 is_flush=self.is_flush,
64 )
Hongjun Ni3efcd0d2019-06-10 19:43:48 +080065
66 self._test.registry.register(self, self._test.logger)
67
68 def remove_vpp_config(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020069 self._test.vapi.lb_add_del_as(
70 pfx=self.pfx,
71 port=self.port,
72 protocol=self.protocol,
73 app_srv=self.app_srv,
74 is_flush=self.is_flush,
75 is_del=1,
76 )
Hongjun Ni3efcd0d2019-06-10 19:43:48 +080077
78 def query_vpp_config(self):
Klement Sekerad9b0c6f2022-04-26 19:02:15 +020079 details = self._test.vapi.lb_as_dump(
80 pfx=self.pfx, port=self.port, protocol=self.protocol
81 )
Hongjun Ni3efcd0d2019-06-10 19:43:48 +080082 return True if self == details else False