Jian Li | e2a04ce | 2020-07-01 19:07:02 +0900 | [diff] [blame] | 1 | /* |
| 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 | */ |
| 16 | package org.onosproject.k8snode.api; |
| 17 | |
| 18 | import org.onlab.packet.IpAddress; |
| 19 | import org.onosproject.net.DeviceId; |
| 20 | |
| 21 | import java.util.Set; |
| 22 | |
| 23 | /** |
| 24 | * Representation of a host used in k8s-networking service. |
| 25 | */ |
| 26 | public 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 Li | 077b07e | 2020-09-01 16:55:25 +0900 | [diff] [blame] | 58 | * 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 Li | 019ce6a | 2020-09-09 10:23:21 +0900 | [diff] [blame^] | 65 | * 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 Li | e2a04ce | 2020-07-01 19:07:02 +0900 | [diff] [blame] | 72 | * 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 Li | 077b07e | 2020-09-01 16:55:25 +0900 | [diff] [blame] | 80 | * Returns new kubernetes host instance with given node names. |
Jian Li | e2a04ce | 2020-07-01 19:07:02 +0900 | [diff] [blame] | 81 | * |
| 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 Li | 077b07e | 2020-09-01 16:55:25 +0900 | [diff] [blame] | 122 | |
| 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 Li | 019ce6a | 2020-09-09 10:23:21 +0900 | [diff] [blame^] | 130 | |
| 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 Li | e2a04ce | 2020-07-01 19:07:02 +0900 | [diff] [blame] | 138 | } |
| 139 | } |