blob: c93d4d1f0be16b99756b997a39ea2d32086553ae [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 /**
58 * Returns new kubernetes host instance with given state.
59 *
60 * @param newState updated state
61 * @return updated kubernetes host
62 */
63 K8sHost updateState(K8sHostState newState);
64
65 /**
66 * Returns new kuberentes host instance with given node names.
67 *
68 * @param nodeNames a set of node names
69 * @return updated kubernetes host
70 */
71 K8sHost updateNodeNames(Set<String> nodeNames);
72
73 /**
74 * Builder of new host entity.
75 */
76 interface Builder {
77
78 /**
79 * Builds an immutable kubernetes host instance.
80 *
81 * @return kubernetes host instance
82 */
83 K8sHost build();
84
85 /**
86 * Returns kubernetes host builder with supplied host IP address.
87 *
88 * @param hostIp host IP address
89 * @return kubernetes host builder
90 */
91 Builder hostIp(IpAddress hostIp);
92
93 /**
94 * Returns kubernetes host builder with supplied node names.
95 *
96 * @param nodeNames node names
97 * @return kubernetes host builder
98 */
99 Builder nodeNames(Set<String> nodeNames);
100
101 /**
102 * Returns kubernetes host builder with supplied host state.
103 *
104 * @param state host state
105 * @return kubernetes host builder
106 */
107 Builder state(K8sHostState state);
108 }
109}