blob: 8d6f57c0cf17493f14da63fd1e86109c2c8fafc8 [file] [log] [blame]
Jian Li9e43ec12019-01-21 23:04:23 +09001/*
2 * Copyright 2019-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.k8snode.api;
17
18import org.onlab.packet.IpAddress;
Jian Li7d111d72019-04-12 13:58:44 +090019import org.onlab.packet.MacAddress;
Jian Li9e43ec12019-01-21 23:04:23 +090020import org.onosproject.net.DeviceId;
21import org.onosproject.net.PortNumber;
22
23/**
24 * Representation of a node used in k8s-networking service.
25 */
26public interface K8sNode {
27
28 /**
29 * Lists of kubernetes node types.
30 */
31 enum Type {
32 /**
33 * Signifies that this is a kubernetes master node.
34 */
35 MASTER,
36
37 /**
38 * Signifies that this is a kubernetes minion node.
39 */
40 MINION
41 }
42
43 /**
44 * Returns hostname of the node.
45 *
46 * @return hostname
47 */
48 String hostname();
49
50 /**
51 * Returns the type of the node.
52 *
53 * @return node type
54 */
55 Type type();
56
57 /**
58 * Returns the OVSDB device ID of the node.
59 *
60 * @return ovsdb device id
61 */
62 DeviceId ovsdb();
63
64 /**
65 * Returns the device ID of the integration bridge at the node.
66 *
67 * @return device id
68 */
69 DeviceId intgBridge();
70
71 /**
Jian Libf562c22019-04-15 18:07:14 +090072 * Returns the device ID of the external bridge at the node.
73 *
74 * @return device id
75 */
76 DeviceId extBridge();
77
78 /**
Jian Li1cee9882019-02-13 11:25:25 +090079 * Returns new kubernetes node instance with given integration bridge.
80 *
81 * @param deviceId integration bridge device ID
82 * @return updated kubernetes node
83 */
84 K8sNode updateIntgBridge(DeviceId deviceId);
85
86 /**
Jian Libf562c22019-04-15 18:07:14 +090087 * Returns new kubernetes node instance with given external bridge.
88 *
89 * @param deviceId external bridge device ID
90 * @return updated kubernetes node
91 */
92 K8sNode updateExtBridge(DeviceId deviceId);
93
94 /**
Jian Li9e43ec12019-01-21 23:04:23 +090095 * Returns the management network IP address of the node.
96 *
97 * @return ip address
98 */
99 IpAddress managementIp();
100
101 /**
102 * Returns the data network IP address used for tunneling.
103 *
104 * @return ip address; null if vxlan mode is not enabled
105 */
106 IpAddress dataIp();
107
108 /**
109 * Returns the initialization state of the node.
110 *
111 * @return node state
112 */
113 K8sNodeState state();
114
115 /**
Jian Li49109b52019-01-22 00:17:28 +0900116 * Returns new kubernetes node instance with given state.
117 *
118 * @param newState updated state
119 * @return updated kubernetes node
120 */
121 K8sNode updateState(K8sNodeState newState);
122
123 /**
Jian Li1b08d652019-05-02 17:28:09 +0900124 * Returns new kubernetes node instance with given external gateway MAC address.
125 *
126 * @param macAddress updated MAC address
127 * @return updated kubernetes node
128 */
129 K8sNode updateExtGatewayMac(MacAddress macAddress);
130
131 /**
Jian Li9e43ec12019-01-21 23:04:23 +0900132 * Returns the GRE tunnel port number.
133 *
134 * @return GRE port number; null if the GRE tunnel port does not exist
135 */
136 PortNumber grePortNum();
137
138 /**
139 * Returns the VXLAN tunnel port number.
140 *
141 * @return VXLAN port number; null if tunnel port does not exist
142 */
143 PortNumber vxlanPortNum();
144
145 /**
146 * Returns the GENEVE tunnel port number.
147 *
148 * @return GENEVE port number; null if the GRE tunnel port does not exist
149 */
150 PortNumber genevePortNum();
151
152 /**
Jian Li4aa17642019-01-30 00:01:11 +0900153 * Returns the host port number.
154 *
155 * @return host port number; null if the host port does not exist
156 */
Jian Lieb488ea2019-04-16 01:50:02 +0900157 PortNumber intgBridgePortNum();
Jian Li4aa17642019-01-30 00:01:11 +0900158
159 /**
Jian Li2778ffa2019-05-07 13:21:52 +0900160 * Returns the integration to external patch port number.
161 *
162 * @return patch port number
163 */
164 PortNumber intgToExtPatchPortNum();
165
166 /**
167 * Returns the external to integration patch port number.
168 *
169 * @return patch port number
170 */
171 PortNumber extToIntgPatchPortNum();
172
173 /**
174 * Returns the external bridge to router port number.
175 *
176 * @return port number, null if the port does not exist
177 */
178 PortNumber extBridgePortNum();
179
180 /**
Jian Li7d111d72019-04-12 13:58:44 +0900181 * Returns the integration bridge's MAC address.
182 *
183 * @return MAC address; null if the MAC address does not exist
184 */
Jian Lieb488ea2019-04-16 01:50:02 +0900185 MacAddress intgBridgeMac();
186
187 /**
188 * Returns the external bridge's IP address.
189 *
190 * @return IP address; null if the IP address does not exist
191 */
192 IpAddress extBridgeIp();
193
194 /**
195 * Returns the external bridge's MAC address.
196 *
197 * @return MAC address; null if the MAC address does not exist
198 */
199 MacAddress extBridgeMac();
200
201 /**
202 * Returns the external gateway IP address.
203 *
204 * @return IP address; null if the IP address does not exist
205 */
206 IpAddress extGatewayIp();
207
208 /**
209 * Returns the external gateway MAC address.
210 *
211 * @return MAC address; null if the MAC address does not exist
212 */
213 MacAddress extGatewayMac();
214
215 /**
Jian Li9e43ec12019-01-21 23:04:23 +0900216 * Builder of new node entity.
217 */
218 interface Builder {
219
220 /**
221 * Builds an immutable kubernetes node instance.
222 *
223 * @return kubernetes node instance
224 */
225 K8sNode build();
226
227 /**
228 * Returns kubernetes node builder with supplied hostname.
229 *
230 * @param hostname hostname of the node
231 * @return kubernetes node builder
232 */
233 Builder hostname(String hostname);
234
235 /**
236 * Returns kubernetes node builder with supplied type.
237 *
238 * @param type kubernetes node type
239 * @return kubernetes node builder
240 */
241 Builder type(Type type);
242
243 /**
Jian Libf562c22019-04-15 18:07:14 +0900244 * Returns kubernetes node builder with supplied integration bridge name.
Jian Li9e43ec12019-01-21 23:04:23 +0900245 *
246 * @param deviceId integration bridge device ID
247 * @return kubernetes node builder
248 */
249 Builder intgBridge(DeviceId deviceId);
250
251 /**
Jian Libf562c22019-04-15 18:07:14 +0900252 * Returns kubernetes node builder with supplied external bridge name.
253 *
254 * @param deviceId external bridge deviceID
255 * @return kubernetes node builder
256 */
257 Builder extBridge(DeviceId deviceId);
258
259 /**
Jian Li9e43ec12019-01-21 23:04:23 +0900260 * Returns kubernetes node builder with supplied management IP address.
261 *
262 * @param managementIp management IP address
263 * @return kubernetes node builder
264 */
265 Builder managementIp(IpAddress managementIp);
266
267 /**
268 * Returns kubernetes node builder with supplied data IP address.
269 *
270 * @param dataIp data IP address
271 * @return kubernetes node builder
272 */
273 Builder dataIp(IpAddress dataIp);
274
275 /**
276 * Returns kubernetes node builder with supplied node state.
277 *
278 * @param state kubernetes node state
279 * @return kubernetes node builder
280 */
281 Builder state(K8sNodeState state);
Jian Li1b08d652019-05-02 17:28:09 +0900282
283 /**
284 * Returns kubernetes node builder with supplied external gateway MAC.
285 *
286 * @param extGatewayMac external gateway MAC address
287 * @return kubernetes node builder
288 */
289 Builder extGatewayMac(MacAddress extGatewayMac);
Jian Li9e43ec12019-01-21 23:04:23 +0900290 }
291}