blob: b1bf3368af91c02b64b37166399026f6d917b983 [file] [log] [blame]
Jian Li3e81b182021-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 Lib5ab63c2021-02-03 17:54:28 +090019import org.onosproject.net.DeviceId;
Jian Li543fe852021-02-04 17:25:01 +090020import org.onosproject.net.PortNumber;
Jian Li3e81b182021-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 Li81b1aab2021-02-17 20:42:15 +090053
54 /**
55 * VLAN typed virtual network.
56 */
57 VLAN,
Jian Li3e81b182021-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 Lifeb84802021-01-12 16:34:49 +0900114 Set<KubevirtHostRoute> hostRoutes();
Jian Li3e81b182021-01-11 02:35:06 +0900115
116 /**
117 * Returns the IP pool.
118 *
119 * @return IP pool
120 */
121 KubevirtIpPool ipPool();
122
123 /**
Jian Li97e6fc32021-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 Lib5ab63c2021-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 Li543fe852021-02-04 17:25:01 +0900147 * Returns the tunnel to tenant port number.
148 *
149 * @param deviceId device identifier
150 * @return port number
151 */
152 PortNumber tunnelToTenantPort(DeviceId deviceId);
153
154 /**
Jian Li3e81b182021-01-11 02:35:06 +0900155 * Builder of new network.
156 */
157 interface Builder {
158
159 /**
160 * Builds an immutable network instance.
161 *
162 * @return kubernetes network
163 */
164 KubevirtNetwork build();
165
166 /**
167 * Returns network builder with supplied network ID.
168 *
169 * @param networkId network ID
170 * @return network builder
171 */
172 Builder networkId(String networkId);
173
174 /**
175 * Returns network builder with supplied network name.
176 *
177 * @param name network name
178 * @return network builder
179 */
180 Builder name(String name);
181
182 /**
183 * Returns network builder with supplied network type.
184 *
185 * @param type network type
186 * @return network builder
187 */
188 Builder type(Type type);
189
190 /**
191 * Returns network builder with supplied MTU.
192 *
193 * @param mtu maximum transmission unit
194 * @return network builder
195 */
196 Builder mtu(Integer mtu);
197
198 /**
199 * Returns network builder with supplied segment ID.
200 *
201 * @param segmentId segment ID
202 * @return network builder
203 */
204 Builder segmentId(String segmentId);
205
206 /**
207 * Returns network builder with supplied gateway IP address.
208 *
209 * @param ipAddress gateway IP address
210 * @return network builder
211 */
212 Builder gatewayIp(IpAddress ipAddress);
213
214 /**
215 * Returns network builder with supplied network CIDR.
216 *
217 * @param cidr Classless Inter-Domain Routing
218 * @return network builder
219 */
220 Builder cidr(String cidr);
221
222 /**
Jian Li97e6fc32021-02-01 20:36:45 +0900223 * Returns network builder with the supplied IP pool.
Jian Li3e81b182021-01-11 02:35:06 +0900224 *
225 * @param ipPool IP pool
226 * @return network builder
227 */
228 Builder ipPool(KubevirtIpPool ipPool);
229
230 /**
Jian Li97e6fc32021-02-01 20:36:45 +0900231 * Returns network builder with the host routes.
Jian Li3e81b182021-01-11 02:35:06 +0900232 *
233 * @param hostRoutes host routes
234 * @return network builder
235 */
236 Builder hostRoutes(Set<KubevirtHostRoute> hostRoutes);
Jian Li97e6fc32021-02-01 20:36:45 +0900237
238 /**
239 * Returns network builder with supplied DNSes.
240 *
241 * @param dnses a set of DNS
242 * @return network builder
243 */
244 Builder dnses(Set<IpAddress> dnses);
Jian Li3e81b182021-01-11 02:35:06 +0900245 }
246}