blob: 2eeb9c13484592819b34cb8d62de8a8b61abe557 [file] [log] [blame]
Jian Li58b33982020-07-01 19:07:02 +09001/*
2 * Copyright 2020-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;
20
21import java.util.Set;
22
23/**
24 * Representation of a host used in k8s-networking service.
25 */
26public interface K8sHost {
27
28 /**
29 * Returns the host IP address. Note that the host IP address is unique, and
30 * will be used as an identifier for the host.
31 *
32 * @return host IP address
33 */
34 IpAddress hostIp();
35
36 /**
37 * A set of node names included in this host.
38 *
39 * @return node names
40 */
41 Set<String> nodeNames();
42
43 /**
44 * Returns kubernetes host state.
45 *
46 * @return host state
47 */
48 K8sHostState state();
49
50 /**
51 * Returns the OVSDB device ID of the node.
52 *
53 * @return ovsdb device ID
54 */
55 DeviceId ovsdb();
56
57 /**
Jian Li8685dd32020-09-01 16:55:25 +090058 * Returns the set of tunnel bridges belong to the host.
59 *
60 * @return a set of tunnel bridges
61 */
62 Set<K8sTunnelBridge> tunBridges();
63
64 /**
Jian Li58b33982020-07-01 19:07:02 +090065 * Returns new kubernetes host instance with given state.
66 *
67 * @param newState updated state
68 * @return updated kubernetes host
69 */
70 K8sHost updateState(K8sHostState newState);
71
72 /**
Jian Li8685dd32020-09-01 16:55:25 +090073 * Returns new kubernetes host instance with given node names.
Jian Li58b33982020-07-01 19:07:02 +090074 *
75 * @param nodeNames a set of node names
76 * @return updated kubernetes host
77 */
78 K8sHost updateNodeNames(Set<String> nodeNames);
79
80 /**
81 * Builder of new host entity.
82 */
83 interface Builder {
84
85 /**
86 * Builds an immutable kubernetes host instance.
87 *
88 * @return kubernetes host instance
89 */
90 K8sHost build();
91
92 /**
93 * Returns kubernetes host builder with supplied host IP address.
94 *
95 * @param hostIp host IP address
96 * @return kubernetes host builder
97 */
98 Builder hostIp(IpAddress hostIp);
99
100 /**
101 * Returns kubernetes host builder with supplied node names.
102 *
103 * @param nodeNames node names
104 * @return kubernetes host builder
105 */
106 Builder nodeNames(Set<String> nodeNames);
107
108 /**
109 * Returns kubernetes host builder with supplied host state.
110 *
111 * @param state host state
112 * @return kubernetes host builder
113 */
114 Builder state(K8sHostState state);
Jian Li8685dd32020-09-01 16:55:25 +0900115
116 /**
117 * Returns kubernetes host builder with supplied tunnel bridges set.
118 *
119 * @param tunBridges tunnel bridges
120 * @return kubernetes host builder
121 */
122 Builder tunBridges(Set<K8sTunnelBridge> tunBridges);
Jian Li58b33982020-07-01 19:07:02 +0900123 }
124}