blob: 2db552eb4de079c7f8b94973cbec5c74a742305d [file] [log] [blame]
Jian Li8fe714d2021-01-11 02:35:06 +09001/*
2 * Copyright 2021-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.kubevirtnetworking.api;
17
18import org.onlab.packet.IpAddress;
Jian Li556709c2021-02-03 17:54:28 +090019import org.onosproject.net.DeviceId;
Jian Li858ccd72021-02-04 17:25:01 +090020import org.onosproject.net.PortNumber;
Jian Li8fe714d2021-01-11 02:35:06 +090021
22import java.util.Set;
23
24/**
25 * Representation of kubevirt network.
26 */
27public interface KubevirtNetwork {
28
29 /**
30 * Lists of network type.
31 */
32 enum Type {
33
34 /**
35 * VXLAN typed virtual network.
36 */
37 VXLAN,
38
39 /**
40 * GRE typed virtual network.
41 */
42 GRE,
43
44 /**
45 * GENEVE typed virtual network.
46 */
47 GENEVE,
48
49 /**
50 * FLAT typed provider network.
51 */
52 FLAT,
Jian Li2ce718e2021-02-17 20:42:15 +090053
54 /**
55 * VLAN typed virtual network.
56 */
57 VLAN,
Jian Li8fe714d2021-01-11 02:35:06 +090058 }
59
60 /**
61 * Returns the kubernetes network ID.
62 *
63 * @return kubernetes network ID
64 */
65 String networkId();
66
67 /**
68 * Returns kubernetes network type.
69 *
70 * @return kubernetes network type
71 */
72 Type type();
73
74 /**
75 * Returns kubernetes network name.
76 *
77 * @return kubernetes network name
78 */
79 String name();
80
81 /**
82 * Returns maximum transmission unit (MTU) value to address fragmentation.
83 *
84 * @return maximum transmission unit (MTU) value to address fragmentation
85 */
86 Integer mtu();
87
88 /**
89 * Returns segmentation ID.
90 *
91 * @return segmentation ID
92 */
93 String segmentId();
94
95 /**
96 * Returns gateway IP address.
97 *
98 * @return gateway IP address
99 */
100 IpAddress gatewayIp();
101
102 /**
103 * Returns network CIDR.
104 *
105 * @return network CIDR
106 */
107 String cidr();
108
109 /**
110 * Returns host routes.
111 *
112 * @return host routes
113 */
Jian Lifc0b8902021-01-12 16:34:49 +0900114 Set<KubevirtHostRoute> hostRoutes();
Jian Li8fe714d2021-01-11 02:35:06 +0900115
116 /**
Jian Lie2abe812021-08-12 18:03:30 +0900117 * Returns default route flag.
118 *
119 * @return default route
120 */
121 boolean defaultRoute();
122
123 /**
Jian Li8fe714d2021-01-11 02:35:06 +0900124 * Returns the IP pool.
125 *
126 * @return IP pool
127 */
128 KubevirtIpPool ipPool();
129
130 /**
Jian Li4c35a262021-02-01 20:36:45 +0900131 * Returns a set of DNS.
132 *
133 * @return a set of DNS
134 */
135 Set<IpAddress> dnses();
136
137 /**
Jian Li556709c2021-02-03 17:54:28 +0900138 * Returns the tenant integration bridge name in case the bridge type
139 * is VXLAN/GRE/GENEVE.
140 *
141 * @return tunnel bridge name
142 */
143 String tenantBridgeName();
144
145 /**
146 * Returns the tenant integration bridge's device identifier.
147 *
148 * @param hostname kubevirt node hostname
149 * @return device identifier
150 */
151 DeviceId tenantDeviceId(String hostname);
152
153 /**
Jian Li8f944d42021-03-23 00:43:29 +0900154 * Returns the tunnel bridge to tenant bridge port number.
Jian Li858ccd72021-02-04 17:25:01 +0900155 *
156 * @param deviceId device identifier
157 * @return port number
158 */
159 PortNumber tunnelToTenantPort(DeviceId deviceId);
160
161 /**
Jian Li8f944d42021-03-23 00:43:29 +0900162 * Returns the tenant bridge to tunnel bridge patch port number.
163 *
164 * @param deviceId device identifier
165 * @return port number
166 */
167 PortNumber tenantToTunnelPort(DeviceId deviceId);
168
169 /**
Jian Li8fe714d2021-01-11 02:35:06 +0900170 * Builder of new network.
171 */
172 interface Builder {
173
174 /**
175 * Builds an immutable network instance.
176 *
177 * @return kubernetes network
178 */
179 KubevirtNetwork build();
180
181 /**
182 * Returns network builder with supplied network ID.
183 *
184 * @param networkId network ID
185 * @return network builder
186 */
187 Builder networkId(String networkId);
188
189 /**
190 * Returns network builder with supplied network name.
191 *
192 * @param name network name
193 * @return network builder
194 */
195 Builder name(String name);
196
197 /**
198 * Returns network builder with supplied network type.
199 *
200 * @param type network type
201 * @return network builder
202 */
203 Builder type(Type type);
204
205 /**
206 * Returns network builder with supplied MTU.
207 *
208 * @param mtu maximum transmission unit
209 * @return network builder
210 */
211 Builder mtu(Integer mtu);
212
213 /**
214 * Returns network builder with supplied segment ID.
215 *
216 * @param segmentId segment ID
217 * @return network builder
218 */
219 Builder segmentId(String segmentId);
220
221 /**
222 * Returns network builder with supplied gateway IP address.
223 *
224 * @param ipAddress gateway IP address
225 * @return network builder
226 */
227 Builder gatewayIp(IpAddress ipAddress);
228
229 /**
Jian Lie2abe812021-08-12 18:03:30 +0900230 * Returns network builder with supplied default route flag.
231 *
232 * @param flag default route
233 * @return network builder
234 */
235 Builder defaultRoute(boolean flag);
236
237 /**
Jian Li8fe714d2021-01-11 02:35:06 +0900238 * Returns network builder with supplied network CIDR.
239 *
240 * @param cidr Classless Inter-Domain Routing
241 * @return network builder
242 */
243 Builder cidr(String cidr);
244
245 /**
Jian Li4c35a262021-02-01 20:36:45 +0900246 * Returns network builder with the supplied IP pool.
Jian Li8fe714d2021-01-11 02:35:06 +0900247 *
248 * @param ipPool IP pool
249 * @return network builder
250 */
251 Builder ipPool(KubevirtIpPool ipPool);
252
253 /**
Jian Li4c35a262021-02-01 20:36:45 +0900254 * Returns network builder with the host routes.
Jian Li8fe714d2021-01-11 02:35:06 +0900255 *
256 * @param hostRoutes host routes
257 * @return network builder
258 */
259 Builder hostRoutes(Set<KubevirtHostRoute> hostRoutes);
Jian Li4c35a262021-02-01 20:36:45 +0900260
261 /**
262 * Returns network builder with supplied DNSes.
263 *
264 * @param dnses a set of DNS
265 * @return network builder
266 */
267 Builder dnses(Set<IpAddress> dnses);
Jian Li8fe714d2021-01-11 02:35:06 +0900268 }
269}