blob: 90c39dfff87f970eb87e2fd2582fc43c4f3e9f2e [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,
53 }
54
55 /**
56 * Returns the kubernetes network ID.
57 *
58 * @return kubernetes network ID
59 */
60 String networkId();
61
62 /**
63 * Returns kubernetes network type.
64 *
65 * @return kubernetes network type
66 */
67 Type type();
68
69 /**
70 * Returns kubernetes network name.
71 *
72 * @return kubernetes network name
73 */
74 String name();
75
76 /**
77 * Returns maximum transmission unit (MTU) value to address fragmentation.
78 *
79 * @return maximum transmission unit (MTU) value to address fragmentation
80 */
81 Integer mtu();
82
83 /**
84 * Returns segmentation ID.
85 *
86 * @return segmentation ID
87 */
88 String segmentId();
89
90 /**
91 * Returns gateway IP address.
92 *
93 * @return gateway IP address
94 */
95 IpAddress gatewayIp();
96
97 /**
98 * Returns network CIDR.
99 *
100 * @return network CIDR
101 */
102 String cidr();
103
104 /**
105 * Returns host routes.
106 *
107 * @return host routes
108 */
Jian Lifeb84802021-01-12 16:34:49 +0900109 Set<KubevirtHostRoute> hostRoutes();
Jian Li3e81b182021-01-11 02:35:06 +0900110
111 /**
112 * Returns the IP pool.
113 *
114 * @return IP pool
115 */
116 KubevirtIpPool ipPool();
117
118 /**
Jian Li97e6fc32021-02-01 20:36:45 +0900119 * Returns a set of DNS.
120 *
121 * @return a set of DNS
122 */
123 Set<IpAddress> dnses();
124
125 /**
Jian Lib5ab63c2021-02-03 17:54:28 +0900126 * Returns the tenant integration bridge name in case the bridge type
127 * is VXLAN/GRE/GENEVE.
128 *
129 * @return tunnel bridge name
130 */
131 String tenantBridgeName();
132
133 /**
134 * Returns the tenant integration bridge's device identifier.
135 *
136 * @param hostname kubevirt node hostname
137 * @return device identifier
138 */
139 DeviceId tenantDeviceId(String hostname);
140
141 /**
Jian Li543fe852021-02-04 17:25:01 +0900142 * Returns the tunnel to tenant port number.
143 *
144 * @param deviceId device identifier
145 * @return port number
146 */
147 PortNumber tunnelToTenantPort(DeviceId deviceId);
148
149 /**
Jian Li3e81b182021-01-11 02:35:06 +0900150 * Builder of new network.
151 */
152 interface Builder {
153
154 /**
155 * Builds an immutable network instance.
156 *
157 * @return kubernetes network
158 */
159 KubevirtNetwork build();
160
161 /**
162 * Returns network builder with supplied network ID.
163 *
164 * @param networkId network ID
165 * @return network builder
166 */
167 Builder networkId(String networkId);
168
169 /**
170 * Returns network builder with supplied network name.
171 *
172 * @param name network name
173 * @return network builder
174 */
175 Builder name(String name);
176
177 /**
178 * Returns network builder with supplied network type.
179 *
180 * @param type network type
181 * @return network builder
182 */
183 Builder type(Type type);
184
185 /**
186 * Returns network builder with supplied MTU.
187 *
188 * @param mtu maximum transmission unit
189 * @return network builder
190 */
191 Builder mtu(Integer mtu);
192
193 /**
194 * Returns network builder with supplied segment ID.
195 *
196 * @param segmentId segment ID
197 * @return network builder
198 */
199 Builder segmentId(String segmentId);
200
201 /**
202 * Returns network builder with supplied gateway IP address.
203 *
204 * @param ipAddress gateway IP address
205 * @return network builder
206 */
207 Builder gatewayIp(IpAddress ipAddress);
208
209 /**
210 * Returns network builder with supplied network CIDR.
211 *
212 * @param cidr Classless Inter-Domain Routing
213 * @return network builder
214 */
215 Builder cidr(String cidr);
216
217 /**
Jian Li97e6fc32021-02-01 20:36:45 +0900218 * Returns network builder with the supplied IP pool.
Jian Li3e81b182021-01-11 02:35:06 +0900219 *
220 * @param ipPool IP pool
221 * @return network builder
222 */
223 Builder ipPool(KubevirtIpPool ipPool);
224
225 /**
Jian Li97e6fc32021-02-01 20:36:45 +0900226 * Returns network builder with the host routes.
Jian Li3e81b182021-01-11 02:35:06 +0900227 *
228 * @param hostRoutes host routes
229 * @return network builder
230 */
231 Builder hostRoutes(Set<KubevirtHostRoute> hostRoutes);
Jian Li97e6fc32021-02-01 20:36:45 +0900232
233 /**
234 * Returns network builder with supplied DNSes.
235 *
236 * @param dnses a set of DNS
237 * @return network builder
238 */
239 Builder dnses(Set<IpAddress> dnses);
Jian Li3e81b182021-01-11 02:35:06 +0900240 }
241}