blob: 4abc2cbeabc9bba91afba89009dfc156c92fa42a [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;
19import org.onosproject.net.DeviceId;
20import org.onosproject.net.PortNumber;
21
22/**
23 * Representation of a node used in k8s-networking service.
24 */
25public interface K8sNode {
26
27 /**
28 * Lists of kubernetes node types.
29 */
30 enum Type {
31 /**
32 * Signifies that this is a kubernetes master node.
33 */
34 MASTER,
35
36 /**
37 * Signifies that this is a kubernetes minion node.
38 */
39 MINION
40 }
41
42 /**
43 * Returns hostname of the node.
44 *
45 * @return hostname
46 */
47 String hostname();
48
49 /**
50 * Returns the type of the node.
51 *
52 * @return node type
53 */
54 Type type();
55
56 /**
57 * Returns the OVSDB device ID of the node.
58 *
59 * @return ovsdb device id
60 */
61 DeviceId ovsdb();
62
63 /**
64 * Returns the device ID of the integration bridge at the node.
65 *
66 * @return device id
67 */
68 DeviceId intgBridge();
69
70 /**
71 * Returns the management network IP address of the node.
72 *
73 * @return ip address
74 */
75 IpAddress managementIp();
76
77 /**
78 * Returns the data network IP address used for tunneling.
79 *
80 * @return ip address; null if vxlan mode is not enabled
81 */
82 IpAddress dataIp();
83
84 /**
85 * Returns the initialization state of the node.
86 *
87 * @return node state
88 */
89 K8sNodeState state();
90
91 /**
Jian Li49109b52019-01-22 00:17:28 +090092 * Returns new kubernetes node instance with given state.
93 *
94 * @param newState updated state
95 * @return updated kubernetes node
96 */
97 K8sNode updateState(K8sNodeState newState);
98
99 /**
Jian Li9e43ec12019-01-21 23:04:23 +0900100 * Returns the GRE tunnel port number.
101 *
102 * @return GRE port number; null if the GRE tunnel port does not exist
103 */
104 PortNumber grePortNum();
105
106 /**
107 * Returns the VXLAN tunnel port number.
108 *
109 * @return VXLAN port number; null if tunnel port does not exist
110 */
111 PortNumber vxlanPortNum();
112
113 /**
114 * Returns the GENEVE tunnel port number.
115 *
116 * @return GENEVE port number; null if the GRE tunnel port does not exist
117 */
118 PortNumber genevePortNum();
119
120 /**
Jian Li4aa17642019-01-30 00:01:11 +0900121 * Returns the host port number.
122 *
123 * @return host port number; null if the host port does not exist
124 */
125 PortNumber intBridgePortNum();
126
127 /**
Jian Li9e43ec12019-01-21 23:04:23 +0900128 * Builder of new node entity.
129 */
130 interface Builder {
131
132 /**
133 * Builds an immutable kubernetes node instance.
134 *
135 * @return kubernetes node instance
136 */
137 K8sNode build();
138
139 /**
140 * Returns kubernetes node builder with supplied hostname.
141 *
142 * @param hostname hostname of the node
143 * @return kubernetes node builder
144 */
145 Builder hostname(String hostname);
146
147 /**
148 * Returns kubernetes node builder with supplied type.
149 *
150 * @param type kubernetes node type
151 * @return kubernetes node builder
152 */
153 Builder type(Type type);
154
155 /**
156 * Returns kubernetes node builder with supplied bridge name.
157 *
158 * @param deviceId integration bridge device ID
159 * @return kubernetes node builder
160 */
161 Builder intgBridge(DeviceId deviceId);
162
163 /**
164 * Returns kubernetes node builder with supplied management IP address.
165 *
166 * @param managementIp management IP address
167 * @return kubernetes node builder
168 */
169 Builder managementIp(IpAddress managementIp);
170
171 /**
172 * Returns kubernetes node builder with supplied data IP address.
173 *
174 * @param dataIp data IP address
175 * @return kubernetes node builder
176 */
177 Builder dataIp(IpAddress dataIp);
178
179 /**
180 * Returns kubernetes node builder with supplied node state.
181 *
182 * @param state kubernetes node state
183 * @return kubernetes node builder
184 */
185 Builder state(K8sNodeState state);
186 }
187}