blob: d755cef70e562559552ef457159262563ea27410 [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):
19
20 def __init__(self, test, pfx, sfx, port, protocol):
21 self._test = test
22 self.pfx = pfx
23 self.sfx = sfx
24 self.port = port
25 self.protocol = protocol
26
27 def add_vpp_config(self):
28 self._test_vapi.lb_add_del_vip(pfx=self.pfx,
29 sfx=self.pfx,
30 port=self.port,
31 protocol=self.protocol)
32
33 self._test.registry.register(self, self._test.logger)
34
35 def remove_vpp_config(self):
36 self._test.vapi.lb_add_del_vip(pfx=self.pfx,
37 sfx=self.pfx,
38 port=self.port,
39 protocol=self.protocol,
40 is_del=1)
41
42 def query_vpp_config(self):
43 details = self._test.vapi.lb_add_del_vip(fx=self.pfx,
44 sfx=self.pfx,
45 port=self.port,
46 protocol=self.protocol)
47 return True if self == details else False
48
49
50class VppLbAs(vpp_object.VppObject):
51 def __init__(self, test, pfx, port, protocol, app_srv, is_del, is_flush):
52 self._test = test
53 # this is the vip
54 self.pfx = pfx
55 self.port = port
56 self.protocol = protocol
57
58 self.app_srv = app_srv
59 self.is_del = is_del
60 self.is_flush = is_flush
61
62 def add_vpp_config(self):
63 self._test_vapi.lb_add_del_as(pfx=self.pfx,
64 port=self.port,
65 protocol=self.protocol,
66 app_srv=self.app_srv,
67 is_flush=self.is_flush,
68 )
69
70 self._test.registry.register(self, self._test.logger)
71
72 def remove_vpp_config(self):
73 self._test.vapi.lb_add_del_as(pfx=self.pfx,
74 port=self.port,
75 protocol=self.protocol,
76 app_srv=self.app_srv,
77 is_flush=self.is_flush,
78 is_del=1)
79
80 def query_vpp_config(self):
81 details = self._test.vapi.lb_as_dump(pfx=self.pfx,
82 port=self.port,
83 protocol=self.protocol)
84 return True if self == details else False