blob: 2c539f39f5a4557d8a6d771d1cba38ec89c92c2f [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 Li1cee9882019-02-13 11:25:25 +090072 * Returns new kubernetes node instance with given integration bridge.
73 *
74 * @param deviceId integration bridge device ID
75 * @return updated kubernetes node
76 */
77 K8sNode updateIntgBridge(DeviceId deviceId);
78
79 /**
Jian Li9e43ec12019-01-21 23:04:23 +090080 * Returns the management network IP address of the node.
81 *
82 * @return ip address
83 */
84 IpAddress managementIp();
85
86 /**
87 * Returns the data network IP address used for tunneling.
88 *
89 * @return ip address; null if vxlan mode is not enabled
90 */
91 IpAddress dataIp();
92
93 /**
94 * Returns the initialization state of the node.
95 *
96 * @return node state
97 */
98 K8sNodeState state();
99
100 /**
Jian Li49109b52019-01-22 00:17:28 +0900101 * Returns new kubernetes node instance with given state.
102 *
103 * @param newState updated state
104 * @return updated kubernetes node
105 */
106 K8sNode updateState(K8sNodeState newState);
107
108 /**
Jian Li9e43ec12019-01-21 23:04:23 +0900109 * Returns the GRE tunnel port number.
110 *
111 * @return GRE port number; null if the GRE tunnel port does not exist
112 */
113 PortNumber grePortNum();
114
115 /**
116 * Returns the VXLAN tunnel port number.
117 *
118 * @return VXLAN port number; null if tunnel port does not exist
119 */
120 PortNumber vxlanPortNum();
121
122 /**
123 * Returns the GENEVE tunnel port number.
124 *
125 * @return GENEVE port number; null if the GRE tunnel port does not exist
126 */
127 PortNumber genevePortNum();
128
129 /**
Jian Li4aa17642019-01-30 00:01:11 +0900130 * Returns the host port number.
131 *
132 * @return host port number; null if the host port does not exist
133 */
134 PortNumber intBridgePortNum();
135
136 /**
Jian Li7d111d72019-04-12 13:58:44 +0900137 * Returns the integration bridge's MAC address.
138 *
139 * @return MAC address; null if the MAC address does not exist
140 */
141 MacAddress intBridgeMac();
142
143 /**
Jian Li9e43ec12019-01-21 23:04:23 +0900144 * Builder of new node entity.
145 */
146 interface Builder {
147
148 /**
149 * Builds an immutable kubernetes node instance.
150 *
151 * @return kubernetes node instance
152 */
153 K8sNode build();
154
155 /**
156 * Returns kubernetes node builder with supplied hostname.
157 *
158 * @param hostname hostname of the node
159 * @return kubernetes node builder
160 */
161 Builder hostname(String hostname);
162
163 /**
164 * Returns kubernetes node builder with supplied type.
165 *
166 * @param type kubernetes node type
167 * @return kubernetes node builder
168 */
169 Builder type(Type type);
170
171 /**
172 * Returns kubernetes node builder with supplied bridge name.
173 *
174 * @param deviceId integration bridge device ID
175 * @return kubernetes node builder
176 */
177 Builder intgBridge(DeviceId deviceId);
178
179 /**
180 * Returns kubernetes node builder with supplied management IP address.
181 *
182 * @param managementIp management IP address
183 * @return kubernetes node builder
184 */
185 Builder managementIp(IpAddress managementIp);
186
187 /**
188 * Returns kubernetes node builder with supplied data IP address.
189 *
190 * @param dataIp data IP address
191 * @return kubernetes node builder
192 */
193 Builder dataIp(IpAddress dataIp);
194
195 /**
196 * Returns kubernetes node builder with supplied node state.
197 *
198 * @param state kubernetes node state
199 * @return kubernetes node builder
200 */
201 Builder state(K8sNodeState state);
202 }
203}