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