blob: ab33cfe450dea5ce740cd3abcf9e06310ec93e7d [file] [log] [blame]
Jian Lie2a04ce2020-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 Li077b07e2020-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 Li019ce6a2020-09-09 10:23:21 +090065 * Returns the set of router bridges belong to the host.
66 *
67 * @return a set of router bridges
68 */
69 Set<K8sRouterBridge> routerBridges();
70
71 /**
Jian Lie2a04ce2020-07-01 19:07:02 +090072 * Returns new kubernetes host instance with given state.
73 *
74 * @param newState updated state
75 * @return updated kubernetes host
76 */
77 K8sHost updateState(K8sHostState newState);
78
79 /**
Jian Li077b07e2020-09-01 16:55:25 +090080 * Returns new kubernetes host instance with given node names.
Jian Lie2a04ce2020-07-01 19:07:02 +090081 *
82 * @param nodeNames a set of node names
83 * @return updated kubernetes host
84 */
85 K8sHost updateNodeNames(Set<String> nodeNames);
86
87 /**
88 * Builder of new host entity.
89 */
90 interface Builder {
91
92 /**
93 * Builds an immutable kubernetes host instance.
94 *
95 * @return kubernetes host instance
96 */
97 K8sHost build();
98
99 /**
100 * Returns kubernetes host builder with supplied host IP address.
101 *
102 * @param hostIp host IP address
103 * @return kubernetes host builder
104 */
105 Builder hostIp(IpAddress hostIp);
106
107 /**
108 * Returns kubernetes host builder with supplied node names.
109 *
110 * @param nodeNames node names
111 * @return kubernetes host builder
112 */
113 Builder nodeNames(Set<String> nodeNames);
114
115 /**
116 * Returns kubernetes host builder with supplied host state.
117 *
118 * @param state host state
119 * @return kubernetes host builder
120 */
121 Builder state(K8sHostState state);
Jian Li077b07e2020-09-01 16:55:25 +0900122
123 /**
124 * Returns kubernetes host builder with supplied tunnel bridges set.
125 *
126 * @param tunBridges tunnel bridges
127 * @return kubernetes host builder
128 */
129 Builder tunBridges(Set<K8sTunnelBridge> tunBridges);
Jian Li019ce6a2020-09-09 10:23:21 +0900130
131 /**
132 * Returns kubernetes host builder with supplied router bridges set.
133 *
134 * @param routerBridges router bridges
135 * @return kubernetes host builder
136 */
137 Builder routerBridges(Set<K8sRouterBridge> routerBridges);
Jian Lie2a04ce2020-07-01 19:07:02 +0900138 }
139}