Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 8e57fd5 | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 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 | */ |
Hyunsun Moon | fd5a24e | 2016-10-19 19:15:48 -0700 | [diff] [blame] | 16 | package org.opencord.cordvtn.api.node; |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 17 | |
| 18 | import com.google.common.base.MoreObjects; |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 19 | import com.google.common.base.Strings; |
| 20 | import com.google.common.collect.Sets; |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 21 | import org.onlab.packet.TpPort; |
| 22 | import org.onosproject.net.DeviceId; |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame^] | 23 | import org.opencord.cordvtn.api.net.CidrAddr; |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 24 | |
| 25 | import java.util.Comparator; |
| 26 | import java.util.Objects; |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 27 | import java.util.Optional; |
| 28 | import java.util.Set; |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 29 | |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 30 | import static com.google.common.base.Preconditions.checkArgument; |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 31 | import static com.google.common.base.Preconditions.checkNotNull; |
Hyunsun Moon | 3fc0cbc | 2016-11-22 18:29:12 -0800 | [diff] [blame] | 32 | import static org.opencord.cordvtn.api.Constants.DEFAULT_OVSDB_PORT; |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 33 | import static org.opencord.cordvtn.api.Constants.DEFAULT_TUNNEL; |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 34 | |
| 35 | /** |
| 36 | * Representation of a compute infrastructure node for CORD VTN service. |
| 37 | */ |
| 38 | public final class CordVtnNode { |
| 39 | |
| 40 | private final String hostname; |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame^] | 41 | private final CidrAddr hostMgmtIp; |
| 42 | private final CidrAddr localMgmtIp; |
| 43 | private final CidrAddr dataIp; |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 44 | private final Optional<TpPort> ovsdbPort; |
Hyunsun Moon | 126171d | 2016-02-09 01:55:48 -0800 | [diff] [blame] | 45 | private final SshAccessInfo sshInfo; |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 46 | private final DeviceId integrationBridgeId; |
| 47 | private final String dataIface; |
| 48 | private final Optional<String> hostMgmtIface; |
Hyunsun Moon | 58ddbdc | 2016-03-07 16:37:17 -0800 | [diff] [blame] | 49 | private final CordVtnNodeState state; |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 50 | |
| 51 | public static final Comparator<CordVtnNode> CORDVTN_NODE_COMPARATOR = |
| 52 | (node1, node2) -> node1.hostname().compareTo(node2.hostname()); |
| 53 | |
| 54 | /** |
| 55 | * Creates a new node. |
| 56 | * |
| 57 | * @param hostname hostname |
Hyunsun Moon | 126171d | 2016-02-09 01:55:48 -0800 | [diff] [blame] | 58 | * @param hostMgmtIp host management network address |
| 59 | * @param localMgmtIp local management network address |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 60 | * @param dataIp data network address |
| 61 | * @param ovsdbPort port number for ovsdb connection |
| 62 | * @param sshInfo ssh access information |
| 63 | * @param integrationBridgeId integration bridge identifier |
| 64 | * @param dataIface data plane interface name |
| 65 | * @param hostMgmtIface host management network interface |
Hyunsun Moon | 58ddbdc | 2016-03-07 16:37:17 -0800 | [diff] [blame] | 66 | * @param state cordvtn node state |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 67 | */ |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 68 | private CordVtnNode(String hostname, |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame^] | 69 | CidrAddr hostMgmtIp, |
| 70 | CidrAddr localMgmtIp, |
| 71 | CidrAddr dataIp, |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 72 | Optional<TpPort> ovsdbPort, |
| 73 | SshAccessInfo sshInfo, |
| 74 | DeviceId integrationBridgeId, |
| 75 | String dataIface, |
| 76 | Optional<String> hostMgmtIface, |
| 77 | CordVtnNodeState state) { |
| 78 | this.hostname = hostname; |
| 79 | this.hostMgmtIp = hostMgmtIp; |
| 80 | this.localMgmtIp = localMgmtIp; |
| 81 | this.dataIp = dataIp; |
| 82 | this.ovsdbPort = ovsdbPort; |
| 83 | this.sshInfo = sshInfo; |
| 84 | this.integrationBridgeId = integrationBridgeId; |
| 85 | this.dataIface = dataIface; |
| 86 | this.hostMgmtIface = hostMgmtIface; |
Hyunsun Moon | 58ddbdc | 2016-03-07 16:37:17 -0800 | [diff] [blame] | 87 | this.state = state; |
| 88 | } |
| 89 | |
| 90 | /** |
| 91 | * Returns cordvtn node with new state. |
| 92 | * |
| 93 | * @param node cordvtn node |
| 94 | * @param state cordvtn node init state |
| 95 | * @return cordvtn node |
| 96 | */ |
| 97 | public static CordVtnNode getUpdatedNode(CordVtnNode node, CordVtnNodeState state) { |
| 98 | return new CordVtnNode(node.hostname, |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 99 | node.hostMgmtIp, node.localMgmtIp, node.dataIp, |
Hyunsun Moon | 58ddbdc | 2016-03-07 16:37:17 -0800 | [diff] [blame] | 100 | node.ovsdbPort, |
| 101 | node.sshInfo, |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 102 | node.integrationBridgeId, |
| 103 | node.dataIface, node.hostMgmtIface, |
| 104 | state); |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | /** |
| 108 | * Returns the hostname. |
| 109 | * |
| 110 | * @return hostname |
| 111 | */ |
| 112 | public String hostname() { |
| 113 | return this.hostname; |
| 114 | } |
| 115 | |
| 116 | /** |
Hyunsun Moon | 126171d | 2016-02-09 01:55:48 -0800 | [diff] [blame] | 117 | * Returns the host management network address. |
| 118 | * |
| 119 | * @return network address |
| 120 | */ |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame^] | 121 | public CidrAddr hostMgmtIp() { |
Hyunsun Moon | 126171d | 2016-02-09 01:55:48 -0800 | [diff] [blame] | 122 | return this.hostMgmtIp; |
| 123 | } |
| 124 | |
| 125 | /** |
| 126 | * Returns the local management network address. |
| 127 | * |
| 128 | * @return network address |
| 129 | */ |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame^] | 130 | public CidrAddr localMgmtIp() { |
Hyunsun Moon | 126171d | 2016-02-09 01:55:48 -0800 | [diff] [blame] | 131 | return this.localMgmtIp; |
| 132 | } |
| 133 | |
| 134 | /** |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 135 | * Returns the data network address. |
Hyunsun Moon | 126171d | 2016-02-09 01:55:48 -0800 | [diff] [blame] | 136 | * |
| 137 | * @return network address |
| 138 | */ |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame^] | 139 | public CidrAddr dataIp() { |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 140 | return this.dataIp; |
Hyunsun Moon | 126171d | 2016-02-09 01:55:48 -0800 | [diff] [blame] | 141 | } |
| 142 | |
| 143 | /** |
| 144 | * Returns the port number used for OVSDB connection. |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 145 | * It returns default OVSDB port 6640, if it's not specified. |
Hyunsun Moon | 126171d | 2016-02-09 01:55:48 -0800 | [diff] [blame] | 146 | * |
| 147 | * @return port number |
| 148 | */ |
| 149 | public TpPort ovsdbPort() { |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 150 | if (this.ovsdbPort.isPresent()) { |
| 151 | return this.ovsdbPort.get(); |
| 152 | } else { |
Hyunsun Moon | 3fc0cbc | 2016-11-22 18:29:12 -0800 | [diff] [blame] | 153 | return TpPort.tpPort(DEFAULT_OVSDB_PORT); |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 154 | } |
Hyunsun Moon | 126171d | 2016-02-09 01:55:48 -0800 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | /** |
| 158 | * Returns the SSH access information. |
| 159 | * |
| 160 | * @return ssh access information |
| 161 | */ |
| 162 | public SshAccessInfo sshInfo() { |
| 163 | return this.sshInfo; |
| 164 | } |
| 165 | |
| 166 | /** |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 167 | * Returns the identifier of the integration bridge. |
| 168 | * |
| 169 | * @return device id |
| 170 | */ |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 171 | public DeviceId integrationBridgeId() { |
| 172 | return this.integrationBridgeId; |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | /** |
| 176 | * Returns the identifier of the OVSDB device. |
| 177 | * |
| 178 | * @return device id |
| 179 | */ |
| 180 | public DeviceId ovsdbId() { |
Hyunsun Moon | 126171d | 2016-02-09 01:55:48 -0800 | [diff] [blame] | 181 | return DeviceId.deviceId("ovsdb:" + this.hostMgmtIp.ip().toString()); |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 182 | } |
| 183 | |
Hyunsun Moon | de37257 | 2016-01-14 03:42:47 -0800 | [diff] [blame] | 184 | /** |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 185 | * Returns data network interface name. |
Hyunsun Moon | de37257 | 2016-01-14 03:42:47 -0800 | [diff] [blame] | 186 | * |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 187 | * @return data network interface name |
Hyunsun Moon | de37257 | 2016-01-14 03:42:47 -0800 | [diff] [blame] | 188 | */ |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 189 | public String dataIface() { |
| 190 | return this.dataIface; |
| 191 | } |
| 192 | |
| 193 | /** |
| 194 | * Returns host management network interface name. |
| 195 | * |
| 196 | * @return host management network interface name |
| 197 | */ |
| 198 | public Optional<String> hostMgmtIface() { |
| 199 | return this.hostMgmtIface; |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * Returns a set of network interfaces for the VTN service to work properly. |
| 204 | * |
| 205 | * @return set of interface names |
| 206 | */ |
| 207 | public Set<String> systemIfaces() { |
| 208 | Set<String> ifaces = Sets.newHashSet(DEFAULT_TUNNEL, dataIface); |
| 209 | if (hostMgmtIface.isPresent()) { |
| 210 | ifaces.add(hostMgmtIface.get()); |
| 211 | } |
| 212 | return ifaces; |
Hyunsun Moon | de37257 | 2016-01-14 03:42:47 -0800 | [diff] [blame] | 213 | } |
| 214 | |
Hyunsun Moon | 58ddbdc | 2016-03-07 16:37:17 -0800 | [diff] [blame] | 215 | /** |
| 216 | * Returns the state of the node. |
| 217 | * |
| 218 | * @return state |
| 219 | */ |
| 220 | public CordVtnNodeState state() { |
| 221 | return this.state; |
| 222 | } |
| 223 | |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 224 | @Override |
| 225 | public boolean equals(Object obj) { |
| 226 | if (this == obj) { |
| 227 | return true; |
| 228 | } |
| 229 | |
| 230 | if (obj instanceof CordVtnNode) { |
| 231 | CordVtnNode that = (CordVtnNode) obj; |
Hyunsun Moon | ff55e81 | 2016-03-10 12:40:16 -0800 | [diff] [blame] | 232 | if (Objects.equals(hostname, that.hostname) && |
| 233 | Objects.equals(hostMgmtIp, that.hostMgmtIp) && |
| 234 | Objects.equals(localMgmtIp, that.localMgmtIp) && |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 235 | Objects.equals(dataIp, that.dataIp) && |
Hyunsun Moon | ff55e81 | 2016-03-10 12:40:16 -0800 | [diff] [blame] | 236 | Objects.equals(ovsdbPort, that.ovsdbPort) && |
| 237 | Objects.equals(sshInfo, that.sshInfo) && |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 238 | Objects.equals(integrationBridgeId, that.integrationBridgeId) && |
| 239 | Objects.equals(dataIface, that.dataIface) && |
| 240 | Objects.equals(hostMgmtIface, that.hostMgmtIface)) { |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 241 | return true; |
| 242 | } |
| 243 | } |
| 244 | return false; |
| 245 | } |
| 246 | |
| 247 | @Override |
| 248 | public int hashCode() { |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 249 | return Objects.hash(hostname, |
| 250 | hostMgmtIp, |
| 251 | localMgmtIp, |
| 252 | dataIp, |
| 253 | ovsdbPort, |
| 254 | sshInfo, |
| 255 | integrationBridgeId, |
| 256 | dataIface, |
| 257 | hostMgmtIface); |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 258 | } |
| 259 | |
| 260 | @Override |
| 261 | public String toString() { |
| 262 | return MoreObjects.toStringHelper(getClass()) |
Hyunsun Moon | 126171d | 2016-02-09 01:55:48 -0800 | [diff] [blame] | 263 | .add("hostname", hostname) |
| 264 | .add("hostMgmtIp", hostMgmtIp) |
| 265 | .add("localMgmtIp", localMgmtIp) |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 266 | .add("dataIp", dataIp) |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 267 | .add("port", ovsdbPort) |
Hyunsun Moon | 126171d | 2016-02-09 01:55:48 -0800 | [diff] [blame] | 268 | .add("sshInfo", sshInfo) |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 269 | .add("integrationBridgeId", integrationBridgeId) |
| 270 | .add("dataIface", dataIface) |
| 271 | .add("hostMgmtIface", hostMgmtIface) |
Hyunsun Moon | 58ddbdc | 2016-03-07 16:37:17 -0800 | [diff] [blame] | 272 | .add("state", state) |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 273 | .toString(); |
| 274 | } |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 275 | |
| 276 | /** |
| 277 | * Returns new node builder instance. |
| 278 | * |
| 279 | * @return cordvtn node builder |
| 280 | */ |
| 281 | public static Builder builder() { |
| 282 | return new Builder(); |
| 283 | } |
| 284 | |
| 285 | /** |
| 286 | * Builder of node entities. |
| 287 | */ |
| 288 | public static final class Builder { |
| 289 | private String hostname; |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame^] | 290 | private CidrAddr hostMgmtIp; |
| 291 | private CidrAddr localMgmtIp; |
| 292 | private CidrAddr dataIp; |
Hyunsun Moon | 3fc0cbc | 2016-11-22 18:29:12 -0800 | [diff] [blame] | 293 | private Optional<TpPort> ovsdbPort = |
| 294 | Optional.of(TpPort.tpPort(DEFAULT_OVSDB_PORT)); |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 295 | private SshAccessInfo sshInfo; |
| 296 | private DeviceId integrationBridgeId; |
| 297 | private String dataIface; |
| 298 | private Optional<String> hostMgmtIface = Optional.empty(); |
| 299 | private CordVtnNodeState state = CordVtnNodeState.noState(); |
| 300 | |
| 301 | private Builder() { |
| 302 | } |
| 303 | |
| 304 | /** |
| 305 | * Builds an immutable cordvtn node. |
| 306 | * |
| 307 | * @return cordvtn node |
| 308 | */ |
| 309 | public CordVtnNode build() { |
| 310 | // validate attributes |
| 311 | checkArgument(!Strings.isNullOrEmpty(hostname)); |
| 312 | checkNotNull(hostMgmtIp); |
| 313 | checkNotNull(localMgmtIp); |
| 314 | checkNotNull(dataIp); |
| 315 | checkNotNull(ovsdbPort); |
| 316 | checkNotNull(sshInfo); |
| 317 | checkNotNull(integrationBridgeId); |
| 318 | checkNotNull(dataIface); |
| 319 | checkNotNull(hostMgmtIface); |
| 320 | return new CordVtnNode(hostname, |
| 321 | hostMgmtIp, localMgmtIp, dataIp, |
| 322 | ovsdbPort, |
| 323 | sshInfo, |
| 324 | integrationBridgeId, |
| 325 | dataIface, |
| 326 | hostMgmtIface, |
| 327 | state); |
| 328 | } |
| 329 | |
| 330 | /** |
| 331 | * Returns cordvtn node builder with hostname. |
| 332 | * |
| 333 | * @param hostname hostname |
| 334 | * @return cordvtn node builder |
| 335 | */ |
| 336 | public Builder hostname(String hostname) { |
| 337 | checkArgument(!Strings.isNullOrEmpty(hostname)); |
| 338 | this.hostname = hostname; |
| 339 | return this; |
| 340 | } |
| 341 | |
| 342 | /** |
| 343 | * Returns cordvtn node builder with host management network IP address. |
| 344 | * |
| 345 | * @param hostMgmtIp host management netework ip address |
| 346 | * @return cordvtn node builder |
| 347 | */ |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame^] | 348 | public Builder hostMgmtIp(CidrAddr hostMgmtIp) { |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 349 | checkNotNull(hostMgmtIp); |
| 350 | this.hostMgmtIp = hostMgmtIp; |
| 351 | return this; |
| 352 | } |
| 353 | |
| 354 | /** |
| 355 | * Returns cordvtn node builder with host management network IP address. |
| 356 | * |
| 357 | * @param cidr string value of the host management network ip address |
| 358 | * @return cordvtn node builder |
| 359 | */ |
| 360 | public Builder hostMgmtIp(String cidr) { |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame^] | 361 | this.hostMgmtIp = CidrAddr.valueOf(cidr); |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 362 | return this; |
| 363 | } |
| 364 | |
| 365 | /** |
| 366 | * Returns cordvtn node builder with local management network IP address. |
| 367 | * |
| 368 | * @param localMgmtIp local management network ip address |
| 369 | * @return cordvtn node builder |
| 370 | */ |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame^] | 371 | public Builder localMgmtIp(CidrAddr localMgmtIp) { |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 372 | checkNotNull(localMgmtIp); |
| 373 | this.localMgmtIp = localMgmtIp; |
| 374 | return this; |
| 375 | } |
| 376 | |
| 377 | /** |
| 378 | * Returns cordvtn node builder with local management netework IP address. |
| 379 | * |
| 380 | * @param cidr string value of the local management network ip address |
| 381 | * @return cordvtn node builder |
| 382 | */ |
| 383 | public Builder localMgmtIp(String cidr) { |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame^] | 384 | this.localMgmtIp = CidrAddr.valueOf(cidr); |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 385 | return this; |
| 386 | } |
| 387 | |
| 388 | /** |
| 389 | * Returns cordvtn node builder with data network IP address. |
| 390 | * |
| 391 | * @param dataIp data network ip address |
| 392 | * @return cordvtn node builder |
| 393 | */ |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame^] | 394 | public Builder dataIp(CidrAddr dataIp) { |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 395 | checkNotNull(dataIp); |
| 396 | this.dataIp = dataIp; |
| 397 | return this; |
| 398 | } |
| 399 | |
| 400 | /** |
| 401 | * Returns cordvtn node builder with data network IP address. |
| 402 | * |
| 403 | * @param cidr string value of the data network ip address |
| 404 | * @return cordvtn node builder |
| 405 | */ |
| 406 | public Builder dataIp(String cidr) { |
Hyunsun Moon | 187bf53 | 2017-01-19 10:57:40 +0900 | [diff] [blame^] | 407 | this.dataIp = CidrAddr.valueOf(cidr); |
Hyunsun Moon | 81a1356 | 2016-08-04 13:48:08 -0700 | [diff] [blame] | 408 | return this; |
| 409 | } |
| 410 | |
| 411 | /** |
| 412 | * Returns cordvtn node builder with OVSDB server listen port number. |
| 413 | * |
| 414 | * @param port ovsdb server listen port number |
| 415 | * @return cordvtn node builder |
| 416 | */ |
| 417 | public Builder ovsdbPort(TpPort port) { |
| 418 | checkNotNull(port); |
| 419 | this.ovsdbPort = Optional.of(port); |
| 420 | return this; |
| 421 | } |
| 422 | |
| 423 | /** |
| 424 | * Returns cordvtn node builder with OVSDB server listen port number. |
| 425 | * |
| 426 | * @param port int value of the ovsdb server listen port number |
| 427 | * @return cordvtn node builder |
| 428 | */ |
| 429 | public Builder ovsdbPort(int port) { |
| 430 | this.ovsdbPort = Optional.of(TpPort.tpPort(port)); |
| 431 | return this; |
| 432 | } |
| 433 | |
| 434 | /** |
| 435 | * Returns cordvtn node builder with SSH access information. |
| 436 | * @param sshInfo ssh access information |
| 437 | * @return cordvtn node builder |
| 438 | */ |
| 439 | public Builder sshInfo(SshAccessInfo sshInfo) { |
| 440 | checkNotNull(sshInfo); |
| 441 | this.sshInfo = sshInfo; |
| 442 | return this; |
| 443 | } |
| 444 | |
| 445 | /** |
| 446 | * Returns cordvtn node builder with integration bridge ID. |
| 447 | * |
| 448 | * @param deviceId device id of the integration bridge |
| 449 | * @return cordvtn node builder |
| 450 | */ |
| 451 | public Builder integrationBridgeId(DeviceId deviceId) { |
| 452 | checkNotNull(deviceId); |
| 453 | this.integrationBridgeId = deviceId; |
| 454 | return this; |
| 455 | } |
| 456 | |
| 457 | /** |
| 458 | * Returns cordvtn node builder with integration bridge ID. |
| 459 | * |
| 460 | * @param deviceId string value of the integration bridge device id |
| 461 | * @return cordvtn node builder |
| 462 | */ |
| 463 | public Builder integrationBridgeId(String deviceId) { |
| 464 | this.integrationBridgeId = DeviceId.deviceId(deviceId); |
| 465 | return this; |
| 466 | } |
| 467 | |
| 468 | /** |
| 469 | * Returns cordvtn node builder with data network interface name. |
| 470 | * |
| 471 | * @param dataIface data network interface name |
| 472 | * @return cordvtn node builder |
| 473 | */ |
| 474 | public Builder dataIface(String dataIface) { |
| 475 | checkArgument(!Strings.isNullOrEmpty(dataIface)); |
| 476 | this.dataIface = dataIface; |
| 477 | return this; |
| 478 | } |
| 479 | |
| 480 | /** |
| 481 | * Returns cordvtn node builder with host management network interface. |
| 482 | * |
| 483 | * @param hostMgmtIface host management network interface name |
| 484 | * @return cordvtn node builder |
| 485 | */ |
| 486 | public Builder hostMgmtIface(String hostMgmtIface) { |
| 487 | this.hostMgmtIface = Optional.ofNullable(hostMgmtIface); |
| 488 | return this; |
| 489 | } |
| 490 | |
| 491 | /** |
| 492 | * Returns cordvtn node builder with init state. |
| 493 | * |
| 494 | * @param state init state |
| 495 | * @return cordvtn node builder |
| 496 | */ |
| 497 | public Builder state(CordVtnNodeState state) { |
| 498 | checkNotNull(state); |
| 499 | this.state = state; |
| 500 | return this; |
| 501 | } |
| 502 | } |
Hyunsun Moon | 4edb017 | 2015-11-07 22:08:43 -0800 | [diff] [blame] | 503 | } |