blob: 94ed1de558b5e4c86f9ddf0aa33be9b0c1d33809 [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 /**
117 * Returns the IP pool.
118 *
119 * @return IP pool
120 */
121 KubevirtIpPool ipPool();
122
123 /**
Jian Li4c35a262021-02-01 20:36:45 +0900124 * Returns a set of DNS.
125 *
126 * @return a set of DNS
127 */
128 Set<IpAddress> dnses();
129
130 /**
Jian Li556709c2021-02-03 17:54:28 +0900131 * Returns the tenant integration bridge name in case the bridge type
132 * is VXLAN/GRE/GENEVE.
133 *
134 * @return tunnel bridge name
135 */
136 String tenantBridgeName();
137
138 /**
139 * Returns the tenant integration bridge's device identifier.
140 *
141 * @param hostname kubevirt node hostname
142 * @return device identifier
143 */
144 DeviceId tenantDeviceId(String hostname);
145
146 /**
Jian Li8f944d42021-03-23 00:43:29 +0900147 * Returns the tunnel bridge to tenant bridge port number.
Jian Li858ccd72021-02-04 17:25:01 +0900148 *
149 * @param deviceId device identifier
150 * @return port number
151 */
152 PortNumber tunnelToTenantPort(DeviceId deviceId);
153
154 /**
Jian Li8f944d42021-03-23 00:43:29 +0900155 * Returns the tenant bridge to tunnel bridge patch port number.
156 *
157 * @param deviceId device identifier
158 * @return port number
159 */
160 PortNumber tenantToTunnelPort(DeviceId deviceId);
161
162 /**
Jian Li8fe714d2021-01-11 02:35:06 +0900163 * Builder of new network.
164 */
165 interface Builder {
166
167 /**
168 * Builds an immutable network instance.
169 *
170 * @return kubernetes network
171 */
172 KubevirtNetwork build();
173
174 /**
175 * Returns network builder with supplied network ID.
176 *
177 * @param networkId network ID
178 * @return network builder
179 */
180 Builder networkId(String networkId);
181
182 /**
183 * Returns network builder with supplied network name.
184 *
185 * @param name network name
186 * @return network builder
187 */
188 Builder name(String name);
189
190 /**
191 * Returns network builder with supplied network type.
192 *
193 * @param type network type
194 * @return network builder
195 */
196 Builder type(Type type);
197
198 /**
199 * Returns network builder with supplied MTU.
200 *
201 * @param mtu maximum transmission unit
202 * @return network builder
203 */
204 Builder mtu(Integer mtu);
205
206 /**
207 * Returns network builder with supplied segment ID.
208 *
209 * @param segmentId segment ID
210 * @return network builder
211 */
212 Builder segmentId(String segmentId);
213
214 /**
215 * Returns network builder with supplied gateway IP address.
216 *
217 * @param ipAddress gateway IP address
218 * @return network builder
219 */
220 Builder gatewayIp(IpAddress ipAddress);
221
222 /**
223 * Returns network builder with supplied network CIDR.
224 *
225 * @param cidr Classless Inter-Domain Routing
226 * @return network builder
227 */
228 Builder cidr(String cidr);
229
230 /**
Jian Li4c35a262021-02-01 20:36:45 +0900231 * Returns network builder with the supplied IP pool.
Jian Li8fe714d2021-01-11 02:35:06 +0900232 *
233 * @param ipPool IP pool
234 * @return network builder
235 */
236 Builder ipPool(KubevirtIpPool ipPool);
237
238 /**
Jian Li4c35a262021-02-01 20:36:45 +0900239 * Returns network builder with the host routes.
Jian Li8fe714d2021-01-11 02:35:06 +0900240 *
241 * @param hostRoutes host routes
242 * @return network builder
243 */
244 Builder hostRoutes(Set<KubevirtHostRoute> hostRoutes);
Jian Li4c35a262021-02-01 20:36:45 +0900245
246 /**
247 * Returns network builder with supplied DNSes.
248 *
249 * @param dnses a set of DNS
250 * @return network builder
251 */
252 Builder dnses(Set<IpAddress> dnses);
Jian Li8fe714d2021-01-11 02:35:06 +0900253 }
254}