Revert "CORD-247 Add host management network interface to integration bridge"
This reverts commit 3ef5249acd9f3ff82dd1c18ec0a09038709c7f3f.
Change-Id: I053e97d49bbef14e764a776cd37dd9d13ddea39e
diff --git a/src/main/java/org/opencord/cordvtn/api/Constants.java b/src/main/java/org/opencord/cordvtn/api/Constants.java
index bee5734..b4c7329 100644
--- a/src/main/java/org/opencord/cordvtn/api/Constants.java
+++ b/src/main/java/org/opencord/cordvtn/api/Constants.java
@@ -15,8 +15,6 @@
*/
package org.opencord.cordvtn.api;
-import org.onlab.packet.TpPort;
-
/**
* Provides constants used in CORD VTN services.
*/
@@ -32,10 +30,8 @@
public static final String MSG_OK = "OK";
public static final String MSG_NO = "NO";
+ public static final String PORT_NAME = "portName";
public static final String DEFAULT_TUNNEL = "vxlan";
- public static final String INTEGRATION_BRIDGE = "br-int";
+ public static final String DEFAULT_BRIDGE = "br-int";
public static final String VPORT_PREFIX = "tap";
-
- public static final int OF_PORT = 6653;
- public static final TpPort OVSDB_PORT = TpPort.tpPort(6640);
}
diff --git a/src/main/java/org/opencord/cordvtn/api/CordVtnConfig.java b/src/main/java/org/opencord/cordvtn/api/CordVtnConfig.java
index 29ffaea..10bc6a1 100644
--- a/src/main/java/org/opencord/cordvtn/api/CordVtnConfig.java
+++ b/src/main/java/org/opencord/cordvtn/api/CordVtnConfig.java
@@ -16,13 +16,14 @@
package org.opencord.cordvtn.api;
import com.fasterxml.jackson.databind.JsonNode;
-import com.google.common.base.Strings;
import com.google.common.collect.Maps;
import com.google.common.collect.Sets;
+import org.onlab.packet.Ip4Address;
import org.onlab.packet.IpAddress;
import org.onlab.packet.MacAddress;
import org.onlab.packet.TpPort;
import org.onosproject.core.ApplicationId;
+import org.onosproject.net.DeviceId;
import org.onosproject.net.config.Config;
import org.onosproject.xosclient.api.OpenStackAccess;
import org.onosproject.xosclient.api.XosAccess;
@@ -50,10 +51,9 @@
private static final String CORDVTN_NODES = "nodes";
private static final String HOSTNAME = "hostname";
private static final String HOST_MANAGEMENT_IP = "hostManagementIp";
- private static final String HOST_MANAGEMENT_IFACE = "hostManagementIface";
- private static final String DATA_IP = "dataPlaneIp";
- private static final String DATA_IFACE = "dataPlaneIntf";
- private static final String INTEGRATION_BRIDGE_ID = "bridgeId";
+ private static final String DATA_PLANE_IP = "dataPlaneIp";
+ private static final String DATA_PLANE_INTF = "dataPlaneIntf";
+ private static final String BRIDGE_ID = "bridgeId";
private static final String SSH = "ssh";
private static final String SSH_PORT = "sshPort";
@@ -68,8 +68,6 @@
private static final String USER = "user";
private static final String PASSWORD = "password";
- // TODO implement isValid
-
/**
* Returns the set of nodes read from network config.
*
@@ -79,7 +77,6 @@
Set<CordVtnNode> nodes = Sets.newHashSet();
- // TODO implement isValid and move these blocks to it
JsonNode cordvtnNodes = object.get(CORDVTN_NODES);
if (cordvtnNodes == null) {
log.debug("No CORD VTN nodes found");
@@ -93,42 +90,37 @@
}
for (JsonNode cordvtnNode : cordvtnNodes) {
- // TODO implement isValid and move this block to it
- NetworkAddress hostMgmt = NetworkAddress.valueOf(getConfig(cordvtnNode, HOST_MANAGEMENT_IP));
- NetworkAddress localMgmt = NetworkAddress.valueOf(getConfig(object, LOCAL_MANAGEMENT_IP));
- if (hostMgmt.prefix().contains(localMgmt.prefix()) ||
- localMgmt.prefix().contains(hostMgmt.prefix())) {
- log.error("hostMamt and localMgmt cannot be overlapped, skip this node");
- continue;
+ try {
+ NetworkAddress hostMgmt = NetworkAddress.valueOf(getConfig(cordvtnNode, HOST_MANAGEMENT_IP));
+ NetworkAddress localMgmt = NetworkAddress.valueOf(getConfig(object, LOCAL_MANAGEMENT_IP));
+ if (hostMgmt.prefix().contains(localMgmt.prefix()) ||
+ localMgmt.prefix().contains(hostMgmt.prefix())) {
+ log.error("hostMamt and localMgmt cannot be overlapped, skip this node");
+ continue;
+ }
+
+ Ip4Address hostMgmtIp = hostMgmt.ip().getIp4Address();
+ SshAccessInfo sshInfo = new SshAccessInfo(
+ hostMgmtIp,
+ TpPort.tpPort(Integer.parseInt(getConfig(sshNode, SSH_PORT))),
+ getConfig(sshNode, SSH_USER), getConfig(sshNode, SSH_KEY_FILE));
+
+ String hostname = getConfig(cordvtnNode, HOSTNAME);
+ CordVtnNode newNode = new CordVtnNode(
+ hostname, hostMgmt, localMgmt,
+ NetworkAddress.valueOf(getConfig(cordvtnNode, DATA_PLANE_IP)),
+ TpPort.tpPort(Integer.parseInt(getConfig(object, OVSDB_PORT))),
+ sshInfo,
+ DeviceId.deviceId(getConfig(cordvtnNode, BRIDGE_ID)),
+ getConfig(cordvtnNode, DATA_PLANE_INTF),
+ CordVtnNodeState.noState());
+
+ nodes.add(newNode);
+ } catch (IllegalArgumentException | NullPointerException e) {
+ log.error("{}", e);
}
-
- String hostname = getConfig(cordvtnNode, HOSTNAME);
- SshAccessInfo sshInfo = new SshAccessInfo(
- hostMgmt.ip().getIp4Address(),
- TpPort.tpPort(Integer.parseInt(getConfig(sshNode, SSH_PORT))),
- getConfig(sshNode, SSH_USER), getConfig(sshNode, SSH_KEY_FILE));
-
- CordVtnNode.Builder nodeBuilder = CordVtnNode.builder()
- .hostname(hostname)
- .hostMgmtIp(hostMgmt)
- .localMgmtIp(localMgmt)
- .dataIp(getConfig(cordvtnNode, DATA_IP))
- .sshInfo(sshInfo)
- .integrationBridgeId(getConfig(cordvtnNode, INTEGRATION_BRIDGE_ID))
- .dataIface(getConfig(cordvtnNode, DATA_IFACE));
-
- String ovsdbPort = getConfig(object, OVSDB_PORT);
- if (!Strings.isNullOrEmpty(ovsdbPort)) {
- nodeBuilder.ovsdbPort(Integer.parseInt(ovsdbPort));
- }
-
- String hostMgmtIface = getConfig(cordvtnNode, HOST_MANAGEMENT_IFACE);
- if (!Strings.isNullOrEmpty(hostMgmtIface)) {
- nodeBuilder.hostMgmtIface(hostMgmtIface);
- }
-
- nodes.add(nodeBuilder.build());
}
+
return nodes;
}
@@ -143,7 +135,7 @@
jsonNode = jsonNode.path(path);
if (jsonNode.isMissingNode()) {
- log.debug("{} is not configured", path);
+ log.error("{} is not configured", path);
return null;
} else {
return jsonNode.asText();
diff --git a/src/main/java/org/opencord/cordvtn/api/CordVtnNode.java b/src/main/java/org/opencord/cordvtn/api/CordVtnNode.java
index 206220f..b251b49 100644
--- a/src/main/java/org/opencord/cordvtn/api/CordVtnNode.java
+++ b/src/main/java/org/opencord/cordvtn/api/CordVtnNode.java
@@ -16,20 +16,13 @@
package org.opencord.cordvtn.api;
import com.google.common.base.MoreObjects;
-import com.google.common.base.Strings;
-import com.google.common.collect.Sets;
import org.onlab.packet.TpPort;
import org.onosproject.net.DeviceId;
import java.util.Comparator;
import java.util.Objects;
-import java.util.Optional;
-import java.util.Set;
-import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
-import static org.opencord.cordvtn.api.Constants.DEFAULT_TUNNEL;
-import static org.opencord.cordvtn.api.Constants.OVSDB_PORT;
/**
* Representation of a compute infrastructure node for CORD VTN service.
@@ -39,12 +32,11 @@
private final String hostname;
private final NetworkAddress hostMgmtIp;
private final NetworkAddress localMgmtIp;
- private final NetworkAddress dataIp;
- private final Optional<TpPort> ovsdbPort;
+ private final NetworkAddress dpIp;
+ private final TpPort ovsdbPort;
private final SshAccessInfo sshInfo;
- private final DeviceId integrationBridgeId;
- private final String dataIface;
- private final Optional<String> hostMgmtIface;
+ private final DeviceId bridgeId;
+ private final String dpIntf;
private final CordVtnNodeState state;
public static final Comparator<CordVtnNode> CORDVTN_NODE_COMPARATOR =
@@ -56,33 +48,24 @@
* @param hostname hostname
* @param hostMgmtIp host management network address
* @param localMgmtIp local management network address
- * @param dataIp data network address
- * @param ovsdbPort port number for ovsdb connection
- * @param sshInfo ssh access information
- * @param integrationBridgeId integration bridge identifier
- * @param dataIface data plane interface name
- * @param hostMgmtIface host management network interface
+ * @param dpIp data plane network address
+ * @param ovsdbPort port number for OVSDB connection
+ * @param sshInfo SSH access information
+ * @param bridgeId integration bridge identifier
+ * @param dpIntf data plane interface name
* @param state cordvtn node state
*/
- private CordVtnNode(String hostname,
- NetworkAddress hostMgmtIp,
- NetworkAddress localMgmtIp,
- NetworkAddress dataIp,
- Optional<TpPort> ovsdbPort,
- SshAccessInfo sshInfo,
- DeviceId integrationBridgeId,
- String dataIface,
- Optional<String> hostMgmtIface,
- CordVtnNodeState state) {
- this.hostname = hostname;
- this.hostMgmtIp = hostMgmtIp;
- this.localMgmtIp = localMgmtIp;
- this.dataIp = dataIp;
- this.ovsdbPort = ovsdbPort;
- this.sshInfo = sshInfo;
- this.integrationBridgeId = integrationBridgeId;
- this.dataIface = dataIface;
- this.hostMgmtIface = hostMgmtIface;
+ public CordVtnNode(String hostname, NetworkAddress hostMgmtIp, NetworkAddress localMgmtIp,
+ NetworkAddress dpIp, TpPort ovsdbPort, SshAccessInfo sshInfo,
+ DeviceId bridgeId, String dpIntf, CordVtnNodeState state) {
+ this.hostname = checkNotNull(hostname, "hostname cannot be null");
+ this.hostMgmtIp = checkNotNull(hostMgmtIp, "hostMgmtIp cannot be null");
+ this.localMgmtIp = checkNotNull(localMgmtIp, "localMgmtIp cannot be null");
+ this.dpIp = checkNotNull(dpIp, "dpIp cannot be null");
+ this.ovsdbPort = checkNotNull(ovsdbPort, "ovsdbPort cannot be null");
+ this.sshInfo = checkNotNull(sshInfo, "sshInfo cannot be null");
+ this.bridgeId = checkNotNull(bridgeId, "bridgeId cannot be null");
+ this.dpIntf = checkNotNull(dpIntf, "dpIntf cannot be null");
this.state = state;
}
@@ -95,12 +78,11 @@
*/
public static CordVtnNode getUpdatedNode(CordVtnNode node, CordVtnNodeState state) {
return new CordVtnNode(node.hostname,
- node.hostMgmtIp, node.localMgmtIp, node.dataIp,
+ node.hostMgmtIp, node.localMgmtIp, node.dpIp,
node.ovsdbPort,
node.sshInfo,
- node.integrationBridgeId,
- node.dataIface, node.hostMgmtIface,
- state);
+ node.bridgeId,
+ node.dpIntf, state);
}
/**
@@ -131,26 +113,21 @@
}
/**
- * Returns the data network address.
+ * Returns the data plane network address.
*
* @return network address
*/
- public NetworkAddress dataIp() {
- return this.dataIp;
+ public NetworkAddress dpIp() {
+ return this.dpIp;
}
/**
* Returns the port number used for OVSDB connection.
- * It returns default OVSDB port 6640, if it's not specified.
*
* @return port number
*/
public TpPort ovsdbPort() {
- if (this.ovsdbPort.isPresent()) {
- return this.ovsdbPort.get();
- } else {
- return OVSDB_PORT;
- }
+ return this.ovsdbPort;
}
/**
@@ -167,8 +144,8 @@
*
* @return device id
*/
- public DeviceId integrationBridgeId() {
- return this.integrationBridgeId;
+ public DeviceId intBrId() {
+ return this.bridgeId;
}
/**
@@ -181,34 +158,12 @@
}
/**
- * Returns data network interface name.
+ * Returns data plane interface name.
*
- * @return data network interface name
+ * @return data plane interface name
*/
- public String dataIface() {
- return this.dataIface;
- }
-
- /**
- * Returns host management network interface name.
- *
- * @return host management network interface name
- */
- public Optional<String> hostMgmtIface() {
- return this.hostMgmtIface;
- }
-
- /**
- * Returns a set of network interfaces for the VTN service to work properly.
- *
- * @return set of interface names
- */
- public Set<String> systemIfaces() {
- Set<String> ifaces = Sets.newHashSet(DEFAULT_TUNNEL, dataIface);
- if (hostMgmtIface.isPresent()) {
- ifaces.add(hostMgmtIface.get());
- }
- return ifaces;
+ public String dpIntf() {
+ return this.dpIntf;
}
/**
@@ -231,12 +186,11 @@
if (Objects.equals(hostname, that.hostname) &&
Objects.equals(hostMgmtIp, that.hostMgmtIp) &&
Objects.equals(localMgmtIp, that.localMgmtIp) &&
- Objects.equals(dataIp, that.dataIp) &&
+ Objects.equals(dpIp, that.dpIp) &&
Objects.equals(ovsdbPort, that.ovsdbPort) &&
Objects.equals(sshInfo, that.sshInfo) &&
- Objects.equals(integrationBridgeId, that.integrationBridgeId) &&
- Objects.equals(dataIface, that.dataIface) &&
- Objects.equals(hostMgmtIface, that.hostMgmtIface)) {
+ Objects.equals(bridgeId, that.bridgeId) &&
+ Objects.equals(dpIntf, that.dpIntf)) {
return true;
}
}
@@ -245,15 +199,8 @@
@Override
public int hashCode() {
- return Objects.hash(hostname,
- hostMgmtIp,
- localMgmtIp,
- dataIp,
- ovsdbPort,
- sshInfo,
- integrationBridgeId,
- dataIface,
- hostMgmtIface);
+ return Objects.hash(hostname, hostMgmtIp, localMgmtIp, dpIp,
+ ovsdbPort, sshInfo, bridgeId, dpIntf);
}
@Override
@@ -262,240 +209,12 @@
.add("hostname", hostname)
.add("hostMgmtIp", hostMgmtIp)
.add("localMgmtIp", localMgmtIp)
- .add("dataIp", dataIp)
+ .add("dpIp", dpIp)
.add("port", ovsdbPort)
.add("sshInfo", sshInfo)
- .add("integrationBridgeId", integrationBridgeId)
- .add("dataIface", dataIface)
- .add("hostMgmtIface", hostMgmtIface)
+ .add("bridgeId", bridgeId)
+ .add("dpIntf", dpIntf)
.add("state", state)
.toString();
}
-
- /**
- * Returns new node builder instance.
- *
- * @return cordvtn node builder
- */
- public static Builder builder() {
- return new Builder();
- }
-
- /**
- * Builder of node entities.
- */
- public static final class Builder {
- private String hostname;
- private NetworkAddress hostMgmtIp;
- private NetworkAddress localMgmtIp;
- private NetworkAddress dataIp;
- private Optional<TpPort> ovsdbPort = Optional.of(OVSDB_PORT);
- private SshAccessInfo sshInfo;
- private DeviceId integrationBridgeId;
- private String dataIface;
- private Optional<String> hostMgmtIface = Optional.empty();
- private CordVtnNodeState state = CordVtnNodeState.noState();
-
- private Builder() {
- }
-
- /**
- * Builds an immutable cordvtn node.
- *
- * @return cordvtn node
- */
- public CordVtnNode build() {
- // validate attributes
- checkArgument(!Strings.isNullOrEmpty(hostname));
- checkNotNull(hostMgmtIp);
- checkNotNull(localMgmtIp);
- checkNotNull(dataIp);
- checkNotNull(ovsdbPort);
- checkNotNull(sshInfo);
- checkNotNull(integrationBridgeId);
- checkNotNull(dataIface);
- checkNotNull(hostMgmtIface);
- return new CordVtnNode(hostname,
- hostMgmtIp, localMgmtIp, dataIp,
- ovsdbPort,
- sshInfo,
- integrationBridgeId,
- dataIface,
- hostMgmtIface,
- state);
- }
-
- /**
- * Returns cordvtn node builder with hostname.
- *
- * @param hostname hostname
- * @return cordvtn node builder
- */
- public Builder hostname(String hostname) {
- checkArgument(!Strings.isNullOrEmpty(hostname));
- this.hostname = hostname;
- return this;
- }
-
- /**
- * Returns cordvtn node builder with host management network IP address.
- *
- * @param hostMgmtIp host management netework ip address
- * @return cordvtn node builder
- */
- public Builder hostMgmtIp(NetworkAddress hostMgmtIp) {
- checkNotNull(hostMgmtIp);
- this.hostMgmtIp = hostMgmtIp;
- return this;
- }
-
- /**
- * Returns cordvtn node builder with host management network IP address.
- *
- * @param cidr string value of the host management network ip address
- * @return cordvtn node builder
- */
- public Builder hostMgmtIp(String cidr) {
- this.hostMgmtIp = NetworkAddress.valueOf(cidr);
- return this;
- }
-
- /**
- * Returns cordvtn node builder with local management network IP address.
- *
- * @param localMgmtIp local management network ip address
- * @return cordvtn node builder
- */
- public Builder localMgmtIp(NetworkAddress localMgmtIp) {
- checkNotNull(localMgmtIp);
- this.localMgmtIp = localMgmtIp;
- return this;
- }
-
- /**
- * Returns cordvtn node builder with local management netework IP address.
- *
- * @param cidr string value of the local management network ip address
- * @return cordvtn node builder
- */
- public Builder localMgmtIp(String cidr) {
- this.localMgmtIp = NetworkAddress.valueOf(cidr);
- return this;
- }
-
- /**
- * Returns cordvtn node builder with data network IP address.
- *
- * @param dataIp data network ip address
- * @return cordvtn node builder
- */
- public Builder dataIp(NetworkAddress dataIp) {
- checkNotNull(dataIp);
- this.dataIp = dataIp;
- return this;
- }
-
- /**
- * Returns cordvtn node builder with data network IP address.
- *
- * @param cidr string value of the data network ip address
- * @return cordvtn node builder
- */
- public Builder dataIp(String cidr) {
- this.dataIp = NetworkAddress.valueOf(cidr);
- return this;
- }
-
- /**
- * Returns cordvtn node builder with OVSDB server listen port number.
- *
- * @param port ovsdb server listen port number
- * @return cordvtn node builder
- */
- public Builder ovsdbPort(TpPort port) {
- checkNotNull(port);
- this.ovsdbPort = Optional.of(port);
- return this;
- }
-
- /**
- * Returns cordvtn node builder with OVSDB server listen port number.
- *
- * @param port int value of the ovsdb server listen port number
- * @return cordvtn node builder
- */
- public Builder ovsdbPort(int port) {
- this.ovsdbPort = Optional.of(TpPort.tpPort(port));
- return this;
- }
-
- /**
- * Returns cordvtn node builder with SSH access information.
- * @param sshInfo ssh access information
- * @return cordvtn node builder
- */
- public Builder sshInfo(SshAccessInfo sshInfo) {
- checkNotNull(sshInfo);
- this.sshInfo = sshInfo;
- return this;
- }
-
- /**
- * Returns cordvtn node builder with integration bridge ID.
- *
- * @param deviceId device id of the integration bridge
- * @return cordvtn node builder
- */
- public Builder integrationBridgeId(DeviceId deviceId) {
- checkNotNull(deviceId);
- this.integrationBridgeId = deviceId;
- return this;
- }
-
- /**
- * Returns cordvtn node builder with integration bridge ID.
- *
- * @param deviceId string value of the integration bridge device id
- * @return cordvtn node builder
- */
- public Builder integrationBridgeId(String deviceId) {
- this.integrationBridgeId = DeviceId.deviceId(deviceId);
- return this;
- }
-
- /**
- * Returns cordvtn node builder with data network interface name.
- *
- * @param dataIface data network interface name
- * @return cordvtn node builder
- */
- public Builder dataIface(String dataIface) {
- checkArgument(!Strings.isNullOrEmpty(dataIface));
- this.dataIface = dataIface;
- return this;
- }
-
- /**
- * Returns cordvtn node builder with host management network interface.
- *
- * @param hostMgmtIface host management network interface name
- * @return cordvtn node builder
- */
- public Builder hostMgmtIface(String hostMgmtIface) {
- this.hostMgmtIface = Optional.ofNullable(hostMgmtIface);
- return this;
- }
-
- /**
- * Returns cordvtn node builder with init state.
- *
- * @param state init state
- * @return cordvtn node builder
- */
- public Builder state(CordVtnNodeState state) {
- checkNotNull(state);
- this.state = state;
- return this;
- }
- }
}
diff --git a/src/main/java/org/opencord/cordvtn/cli/CordVtnNodeCheckCommand.java b/src/main/java/org/opencord/cordvtn/cli/CordVtnNodeCheckCommand.java
index d0189e4..6d591b0 100644
--- a/src/main/java/org/opencord/cordvtn/cli/CordVtnNodeCheckCommand.java
+++ b/src/main/java/org/opencord/cordvtn/cli/CordVtnNodeCheckCommand.java
@@ -16,23 +16,14 @@
package org.opencord.cordvtn.cli;
-import com.jcraft.jsch.Session;
import org.apache.karaf.shell.commands.Argument;
import org.apache.karaf.shell.commands.Command;
-import org.onlab.packet.IpAddress;
import org.onosproject.cli.AbstractShellCommand;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Port;
import org.opencord.cordvtn.api.CordVtnNode;
import org.opencord.cordvtn.impl.CordVtnNodeManager;
import org.onosproject.net.Device;
import org.onosproject.net.device.DeviceService;
-
-import java.util.Set;
-
-import static org.onosproject.net.AnnotationKeys.PORT_NAME;
-import static org.opencord.cordvtn.api.Constants.*;
-import static org.opencord.cordvtn.impl.RemoteIpCommandUtil.*;
+import org.onosproject.net.driver.DriverService;
/**
* Checks detailed node init state.
@@ -61,74 +52,23 @@
return;
}
- print("%n[Integration Bridge Status]");
- Device device = deviceService.getDevice(node.integrationBridgeId());
- if (device != null) {
- print("%s %s=%s available=%s %s",
- deviceService.isAvailable(device.id()) ? MSG_OK : MSG_NO,
- INTEGRATION_BRIDGE,
- device.id(),
- deviceService.isAvailable(device.id()),
- device.annotations());
+ print(nodeManager.checkNodeInitState(node));
- node.systemIfaces().stream().forEach(iface -> print(
- getPortState(deviceService, node.integrationBridgeId(), iface)));
- } else {
- print("%s %s=%s is not available",
- MSG_NO,
- INTEGRATION_BRIDGE,
- node.integrationBridgeId());
- }
+ print("%n[DEBUG]");
+ Device device = deviceService.getDevice(node.intBrId());
+ String driver = get(DriverService.class).getDriver(device.id()).name();
+ print("%s available=%s driver=%s %s",
+ device.id(),
+ deviceService.isAvailable(device.id()),
+ driver,
+ device.annotations());
- print("%n[Interfaces and IP setup]");
- Session session = connect(node.sshInfo());
- if (session != null) {
- Set<IpAddress> ips = getCurrentIps(session, INTEGRATION_BRIDGE);
- boolean isUp = isInterfaceUp(session, INTEGRATION_BRIDGE);
- boolean isIp = ips.contains(node.dataIp().ip()) && ips.contains(node.localMgmtIp().ip());
-
- print("%s %s up=%s Ips=%s",
- isUp && isIp ? MSG_OK : MSG_NO,
- INTEGRATION_BRIDGE,
- isUp ? Boolean.TRUE : Boolean.FALSE,
- getCurrentIps(session, INTEGRATION_BRIDGE));
-
- print(getSystemIfaceState(session, node.dataIface()));
- if (node.hostMgmtIface().isPresent()) {
- print(getSystemIfaceState(session, node.hostMgmtIface().get()));
- }
-
- disconnect(session);
- } else {
- print("%s Unable to SSH to %s", MSG_NO, node.hostname());
- }
- }
-
- private String getPortState(DeviceService deviceService, DeviceId deviceId, String portName) {
- Port port = deviceService.getPorts(deviceId).stream()
- .filter(p -> p.annotations().value(PORT_NAME).equals(portName) &&
- p.isEnabled())
- .findAny().orElse(null);
-
- if (port != null) {
- return String.format("%s %s portNum=%s enabled=%s %s",
- port.isEnabled() ? MSG_OK : MSG_NO,
- portName,
- port.number(),
- port.isEnabled() ? Boolean.TRUE : Boolean.FALSE,
- port.annotations());
- } else {
- return String.format("%s %s does not exist", MSG_NO, portName);
- }
- }
-
- private String getSystemIfaceState(Session session, String iface) {
- boolean isUp = isInterfaceUp(session, iface);
- boolean isIp = getCurrentIps(session, iface).isEmpty();
- return String.format("%s %s up=%s IpFlushed=%s",
- isUp && isIp ? MSG_OK : MSG_NO,
- iface,
- isUp ? Boolean.TRUE : Boolean.FALSE,
- isIp ? Boolean.TRUE : Boolean.FALSE);
+ deviceService.getPorts(node.intBrId()).forEach(port -> {
+ Object portIsEnabled = port.isEnabled() ? "enabled" : "disabled";
+ print("port=%s state=%s %s",
+ port.number(),
+ portIsEnabled,
+ port.annotations());
+ });
}
}
diff --git a/src/main/java/org/opencord/cordvtn/cli/CordVtnNodeListCommand.java b/src/main/java/org/opencord/cordvtn/cli/CordVtnNodeListCommand.java
index 0b25e7b..b8aa2cd 100644
--- a/src/main/java/org/opencord/cordvtn/cli/CordVtnNodeListCommand.java
+++ b/src/main/java/org/opencord/cordvtn/cli/CordVtnNodeListCommand.java
@@ -47,12 +47,12 @@
print("%s", json(nodeManager, nodes));
} else {
for (CordVtnNode node : nodes) {
- print("hostname=%s, hostMgmtIp=%s, dataIp=%s, br-int=%s, dataIface=%s, init=%s",
+ print("hostname=%s, hostMgmtIp=%s, dpIp=%s, br-int=%s, dpIntf=%s, init=%s",
node.hostname(),
node.hostMgmtIp().cidr(),
- node.dataIp().cidr(),
- node.integrationBridgeId().toString(),
- node.dataIface(),
+ node.dpIp().cidr(),
+ node.intBrId().toString(),
+ node.dpIntf(),
getState(nodeManager, node));
}
print("Total %s nodes", nodeManager.getNodeCount());
@@ -66,9 +66,9 @@
result.add(mapper.createObjectNode()
.put("hostname", node.hostname())
.put("hostManagementIp", node.hostMgmtIp().cidr())
- .put("dataPlaneIp", node.dataIp().cidr())
- .put("bridgeId", node.integrationBridgeId().toString())
- .put("dataPlaneInterface", node.dataIface())
+ .put("dataPlaneIp", node.dpIp().cidr())
+ .put("bridgeId", node.intBrId().toString())
+ .put("dataPlaneInterface", node.dpIntf())
.put("init", getState(nodeManager, node)));
}
return result;
diff --git a/src/main/java/org/opencord/cordvtn/impl/CordVtnNodeManager.java b/src/main/java/org/opencord/cordvtn/impl/CordVtnNodeManager.java
index df3d336..fbac581 100644
--- a/src/main/java/org/opencord/cordvtn/impl/CordVtnNodeManager.java
+++ b/src/main/java/org/opencord/cordvtn/impl/CordVtnNodeManager.java
@@ -15,7 +15,7 @@
*/
package org.opencord.cordvtn.impl;
-import com.google.common.base.Strings;
+import com.google.common.collect.Sets;
import com.jcraft.jsch.Session;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
@@ -24,13 +24,11 @@
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.apache.felix.scr.annotations.Service;
import org.onlab.packet.IpAddress;
+import org.onlab.util.ItemNotFoundException;
import org.onlab.util.KryoNamespace;
import org.onosproject.cluster.ClusterService;
import org.onosproject.cluster.LeadershipService;
import org.onosproject.cluster.NodeId;
-import org.onosproject.net.behaviour.BridgeDescription;
-import org.onosproject.net.behaviour.DefaultBridgeDescription;
-import org.onosproject.net.behaviour.InterfaceConfig;
import org.opencord.cordvtn.api.ConnectionHandler;
import org.opencord.cordvtn.api.CordVtnConfig;
import org.opencord.cordvtn.api.CordVtnNode;
@@ -41,15 +39,19 @@
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.Device;
import org.onosproject.net.DeviceId;
+import org.onosproject.net.Host;
import org.onosproject.net.Port;
import org.onosproject.net.PortNumber;
import org.onosproject.net.behaviour.BridgeConfig;
import org.onosproject.net.behaviour.BridgeName;
import org.onosproject.net.behaviour.ControllerInfo;
import org.onosproject.net.behaviour.DefaultTunnelDescription;
+import org.onosproject.net.behaviour.TunnelConfig;
import org.onosproject.net.behaviour.TunnelDescription;
+import org.onosproject.net.behaviour.TunnelName;
import org.onosproject.net.config.NetworkConfigEvent;
import org.onosproject.net.config.NetworkConfigListener;
import org.onosproject.net.config.NetworkConfigRegistry;
@@ -71,7 +73,10 @@
import org.onosproject.store.service.Versioned;
import org.slf4j.Logger;
+import java.util.ArrayList;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.ExecutorService;
@@ -80,7 +85,6 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
import static org.onlab.util.Tools.groupedThreads;
-import static org.onosproject.net.AnnotationKeys.PORT_NAME;
import static org.onosproject.net.Device.Type.SWITCH;
import static org.onosproject.net.behaviour.TunnelDescription.Type.VXLAN;
import static org.opencord.cordvtn.api.Constants.*;
@@ -105,7 +109,14 @@
.register(SshAccessInfo.class)
.register(NetworkAddress.class);
+ private static final Map<String, String> DEFAULT_TUNNEL_OPTIONS = new HashMap<String, String>() {
+ {
+ put("key", "flow");
+ put("remote_ip", "flow");
+ }
+ };
private static final int DPID_BEGIN = 3;
+ private static final int OFPORT = 6653;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected CoreService coreService;
@@ -123,7 +134,7 @@
protected DeviceAdminService adminService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected OvsdbController ovsdbController;
+ protected OvsdbController controller;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ClusterService clusterService;
@@ -162,27 +173,21 @@
INIT {
@Override
public void process(CordVtnNodeManager nodeManager, CordVtnNode node) {
- // make sure there is OVSDB connection
if (!nodeManager.isOvsdbConnected(node)) {
nodeManager.connectOvsdb(node);
- return;
+ } else {
+ nodeManager.createIntegrationBridge(node);
}
- nodeManager.createIntegrationBridge(node);
}
},
BRIDGE_CREATED {
@Override
public void process(CordVtnNodeManager nodeManager, CordVtnNode node) {
- // make sure there is OVSDB connection
if (!nodeManager.isOvsdbConnected(node)) {
nodeManager.connectOvsdb(node);
- return;
- }
-
- nodeManager.createTunnelInterface(node);
- nodeManager.addSystemInterface(node, node.dataIface());
- if (node.hostMgmtIface().isPresent()) {
- nodeManager.addSystemInterface(node, node.hostMgmtIface().get());
+ } else {
+ nodeManager.createTunnelInterface(node);
+ nodeManager.addDataPlaneInterface(node);
}
}
},
@@ -256,10 +261,11 @@
*/
public void deleteNode(CordVtnNode node) {
checkNotNull(node);
- OvsdbClientService ovsdbClient = getOvsdbClient(node);
- if (ovsdbClient != null && ovsdbClient.isConnected()) {
- ovsdbClient.disconnect();
+
+ if (isOvsdbConnected(node)) {
+ disconnectOvsdb(node);
}
+
nodeStore.remove(node.hostname());
}
@@ -271,7 +277,50 @@
*/
public boolean isNodeInitComplete(CordVtnNode node) {
checkNotNull(node);
- return getNodeState(node).equals(NodeState.COMPLETE);
+ return nodeStore.containsKey(node.hostname()) && getNodeState(node).equals(NodeState.COMPLETE);
+ }
+
+ /**
+ * Returns detailed node initialization state.
+ *
+ * @param node cordvtn node
+ * @return string including detailed node init state
+ */
+ public String checkNodeInitState(CordVtnNode node) {
+ checkNotNull(node);
+
+ if (!nodeStore.containsKey(node.hostname())) {
+ log.warn("Node {} does not exist, add node first", node.hostname());
+ return null;
+ }
+
+ Session session = connect(node.sshInfo());
+ if (session == null) {
+ log.debug("Failed to SSH to {}", node.hostname());
+ return null;
+ }
+
+ Set<IpAddress> intBrIps = getCurrentIps(session, DEFAULT_BRIDGE);
+ String result = String.format(
+ "Current state : %s%n" +
+ "br-int created and connected to ONOS : %s (%s)%n" +
+ "VXLAN interface added to br-int : %s%n" +
+ "Data plane interface is added to br-int and enabled : %s (%s)%n" +
+ "IP flushed from data plane interface : %s (%s)%n" +
+ "Data plane IP added to br-int : %s (%s)%n" +
+ "Local management IP added to br-int : %s (%s)",
+ node.state(),
+ isBrIntCreated(node) ? MSG_OK : MSG_NO, node.intBrId(),
+ isTunnelIntfCreated(node) ? MSG_OK : MSG_NO,
+ isDataPlaneIntfAdded(node) ? MSG_OK : MSG_NO, node.dpIntf(),
+ isInterfaceUp(session, node.dpIntf()) &&
+ getCurrentIps(session, node.dpIntf()).isEmpty() ? MSG_OK : MSG_NO, node.dpIntf(),
+ intBrIps.contains(node.dpIp().ip()) ? MSG_OK : MSG_NO, node.dpIp().cidr(),
+ intBrIps.contains(node.localMgmtIp().ip()) ? MSG_OK : MSG_NO, node.localMgmtIp().cidr());
+
+ disconnect(session);
+
+ return result;
}
/**
@@ -298,8 +347,7 @@
* @return set of nodes
*/
public Set<CordVtnNode> completeNodes() {
- return getNodes().stream().filter(this::isNodeStateComplete)
- .collect(Collectors.toSet());
+ return getNodes().stream().filter(this::isNodeInitComplete).collect(Collectors.toSet());
}
/**
@@ -308,14 +356,14 @@
* @param deviceId integration bridge device id
* @return port number; null otherwise
*/
- public PortNumber dataPort(DeviceId deviceId) {
+ public PortNumber dpPort(DeviceId deviceId) {
CordVtnNode node = nodeByBridgeId(deviceId);
if (node == null) {
log.warn("Failed to get node for {}", deviceId);
return null;
}
Port port = deviceService.getPorts(deviceId).stream()
- .filter(p -> portName(p).contains(node.dataIface()) &&
+ .filter(p -> portName(p).contains(node.dpIntf()) &&
p.isEnabled())
.findFirst().orElse(null);
@@ -328,13 +376,13 @@
* @param deviceId integration bridge device id
* @return ip address; null otherwise
*/
- public IpAddress dataIp(DeviceId deviceId) {
+ public IpAddress dpIp(DeviceId deviceId) {
CordVtnNode node = nodeByBridgeId(deviceId);
if (node == null) {
log.warn("Failed to get node for {}", deviceId);
return null;
}
- return node.dataIp().ip();
+ return node.dpIp().ip();
}
/**
@@ -390,29 +438,18 @@
* @param node cordvtn node
*/
private void postInit(CordVtnNode node) {
- checkNotNull(node);
+ disconnectOvsdb(node);
+ pipeline.initPipeline(node, dpPort(node.intBrId()), tunnelPort(node.intBrId()));
- // disconnect OVSDB session once the node bootstrap is done
- OvsdbClientService ovsdbClient = getOvsdbClient(node);
- if (ovsdbClient != null && ovsdbClient.isConnected()) {
- ovsdbClient.disconnect();
- }
-
- pipeline.initPipeline(node, dataPort(node.integrationBridgeId()),
- tunnelPort(node.integrationBridgeId()));
-
- // adds existing instances to the host list
- deviceService.getPorts(node.integrationBridgeId()).stream()
+ deviceService.getPorts(node.intBrId()).stream()
.filter(port -> portName(port).startsWith(VPORT_PREFIX) &&
port.isEnabled())
.forEach(port -> instanceService.addInstance(connectPoint(port)));
- // removes stale instances from the host list
hostService.getHosts().forEach(host -> {
- if (deviceService.getPort(
- host.location().deviceId(),
- host.location().port()) == null) {
- instanceService.removeInstance(host.location());
+ if (deviceService.getPort(host.location().deviceId(),
+ host.location().port()) == null) {
+ instanceService.removeInstance(connectPoint(host));
}
});
@@ -427,6 +464,7 @@
*/
private void setNodeState(CordVtnNode node, NodeState newState) {
checkNotNull(node);
+
log.debug("Changed {} state: {}", node.hostname(), newState);
nodeStore.put(node.hostname(), CordVtnNode.getUpdatedNode(node, newState));
}
@@ -439,18 +477,17 @@
*/
private NodeState getNodeState(CordVtnNode node) {
checkNotNull(node);
- if (!isIntegrationBridgeCreated(node)) {
+
+ if (isBrIntCreated(node) && isTunnelIntfCreated(node) &&
+ isDataPlaneIntfAdded(node) && isIpAddressSet(node)) {
+ return NodeState.COMPLETE;
+ } else if (isDataPlaneIntfAdded(node) && isTunnelIntfCreated(node)) {
+ return NodeState.PORTS_ADDED;
+ } else if (isBrIntCreated(node)) {
+ return NodeState.BRIDGE_CREATED;
+ } else {
return NodeState.INIT;
}
- for (String iface : node.systemIfaces()) {
- if (!isIfaceCreated(node, iface)) {
- return NodeState.BRIDGE_CREATED;
- }
- }
- if (!isIpAddressSet(node)) {
- return NodeState.PORTS_ADDED;
- }
- return NodeState.COMPLETE;
}
/**
@@ -461,10 +498,10 @@
*/
private boolean isOvsdbConnected(CordVtnNode node) {
checkNotNull(node);
+
OvsdbClientService ovsdbClient = getOvsdbClient(node);
return deviceService.isAvailable(node.ovsdbId()) &&
- ovsdbClient != null &&
- ovsdbClient.isConnected();
+ ovsdbClient != null && ovsdbClient.isConnected();
}
/**
@@ -474,82 +511,150 @@
*/
private void connectOvsdb(CordVtnNode node) {
checkNotNull(node);
- ovsdbController.connect(node.hostMgmtIp().ip(), node.ovsdbPort());
+
+ if (!nodeStore.containsKey(node.hostname())) {
+ log.warn("Node {} does not exist", node.hostname());
+ return;
+ }
+
+ if (!isOvsdbConnected(node)) {
+ controller.connect(node.hostMgmtIp().ip(), node.ovsdbPort());
+ }
+ }
+
+ /**
+ * Disconnects OVSDB server for a given node.
+ *
+ * @param node cordvtn node
+ */
+ private void disconnectOvsdb(CordVtnNode node) {
+ checkNotNull(node);
+
+ if (!nodeStore.containsKey(node.hostname())) {
+ log.warn("Node {} does not exist", node.hostname());
+ return;
+ }
+
+ if (isOvsdbConnected(node)) {
+ OvsdbClientService ovsdbClient = getOvsdbClient(node);
+ ovsdbClient.disconnect();
+ }
}
/**
* Returns OVSDB client for a given node.
*
* @param node cordvtn node
- * @return ovsdb client, or null if there's no ovsdb connection
+ * @return OVSDB client, or null if it fails to get OVSDB client
*/
private OvsdbClientService getOvsdbClient(CordVtnNode node) {
checkNotNull(node);
- OvsdbNodeId ovsdb = new OvsdbNodeId(
- node.hostMgmtIp().ip(), node.ovsdbPort().toInt());
- return ovsdbController.getOvsdbClient(ovsdb);
+
+ OvsdbClientService ovsdbClient = controller.getOvsdbClient(
+ new OvsdbNodeId(node.hostMgmtIp().ip(), node.ovsdbPort().toInt()));
+ if (ovsdbClient == null) {
+ log.trace("Couldn't find OVSDB client for {}", node.hostname());
+ }
+ return ovsdbClient;
}
+ /**
+ * Creates an integration bridge for a given node.
+ *
+ * @param node cordvtn node
+ */
private void createIntegrationBridge(CordVtnNode node) {
- Device device = deviceService.getDevice(node.ovsdbId());
- if (device == null || !device.is(BridgeConfig.class)) {
- log.error("Failed to create integration bridge on {}", node.ovsdbId());
+ if (isBrIntCreated(node)) {
return;
}
- List<ControllerInfo> controllers = clusterService.getNodes().stream()
- .map(controller -> new ControllerInfo(controller.ip(), OF_PORT, "tcp"))
- .collect(Collectors.toList());
+ List<ControllerInfo> controllers = new ArrayList<>();
+ Sets.newHashSet(clusterService.getNodes()).stream()
+ .forEach(controller -> {
+ ControllerInfo ctrlInfo = new ControllerInfo(controller.ip(), OFPORT, "tcp");
+ controllers.add(ctrlInfo);
+ });
- String dpid = node.integrationBridgeId().toString().substring(DPID_BEGIN);
- BridgeDescription bridgeDesc = DefaultBridgeDescription.builder()
- .name(INTEGRATION_BRIDGE)
- .failMode(BridgeDescription.FailMode.SECURE)
- .datapathId(dpid)
- .disableInBand()
- .controllers(controllers)
- .build();
+ String dpid = node.intBrId().toString().substring(DPID_BEGIN);
- BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
- bridgeConfig.addBridge(bridgeDesc);
+ try {
+ Device device = deviceService.getDevice(node.ovsdbId());
+ if (device.is(BridgeConfig.class)) {
+ BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
+ bridgeConfig.addBridge(BridgeName.bridgeName(DEFAULT_BRIDGE), dpid, controllers);
+ } else {
+ log.warn("The bridging behaviour is not supported in device {}", device.id());
+ }
+ } catch (ItemNotFoundException e) {
+ log.warn("Failed to create integration bridge on {}", node.hostname());
+ }
}
+ /**
+ * Creates tunnel interface to the integration bridge for a given node.
+ *
+ * @param node cordvtn node
+ */
private void createTunnelInterface(CordVtnNode node) {
- Device device = deviceService.getDevice(node.ovsdbId());
- if (device == null || !device.is(InterfaceConfig.class)) {
- log.error("Failed to create tunnel interface on {}", node.ovsdbId());
+ if (isTunnelIntfCreated(node)) {
return;
}
- TunnelDescription tunnelDesc = DefaultTunnelDescription.builder()
- .name(DEFAULT_TUNNEL)
- .type(VXLAN)
- .enableFlowDst()
- .enableFlowKey()
- .build();
+ DefaultAnnotations.Builder optionBuilder = DefaultAnnotations.builder();
+ for (String key : DEFAULT_TUNNEL_OPTIONS.keySet()) {
+ optionBuilder.set(key, DEFAULT_TUNNEL_OPTIONS.get(key));
+ }
- InterfaceConfig ifaceConfig = device.as(InterfaceConfig.class);
- ifaceConfig.addTunnelInterface(BridgeName.of(INTEGRATION_BRIDGE), tunnelDesc);
+ TunnelDescription description = new DefaultTunnelDescription(
+ null, null, VXLAN, TunnelName.tunnelName(DEFAULT_TUNNEL),
+ optionBuilder.build());
+
+ try {
+ Device device = deviceService.getDevice(node.ovsdbId());
+ if (device.is(TunnelConfig.class)) {
+ TunnelConfig tunnelConfig = device.as(TunnelConfig.class);
+ tunnelConfig.createTunnelInterface(BridgeName.bridgeName(DEFAULT_BRIDGE), description);
+ } else {
+ log.warn("The tunneling behaviour is not supported in device {}", device.id());
+ }
+ } catch (ItemNotFoundException e) {
+ log.warn("Failed to create tunnel interface on {}", node.hostname());
+ }
}
- private void addSystemInterface(CordVtnNode node, String ifaceName) {
+ /**
+ * Adds data plane interface to a given node.
+ *
+ * @param node cordvtn node
+ */
+ private void addDataPlaneInterface(CordVtnNode node) {
+ if (isDataPlaneIntfAdded(node)) {
+ return;
+ }
+
Session session = connect(node.sshInfo());
- if (session == null || !isInterfaceUp(session, ifaceName)) {
- log.warn("Interface {} is not available on {}", ifaceName, node.hostname());
- disconnect(session);
- return;
- } else {
- disconnect(session);
- }
-
- Device device = deviceService.getDevice(node.ovsdbId());
- if (!device.is(BridgeConfig.class)) {
- log.error("BridgeConfig is not supported for {}", node.ovsdbId());
+ if (session == null) {
+ log.debug("Failed to SSH to {}", node.hostname());
return;
}
- BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
- bridgeConfig.addPort(BridgeName.of(INTEGRATION_BRIDGE), ifaceName);
+ if (!isInterfaceUp(session, node.dpIntf())) {
+ log.warn("Interface {} is not available", node.dpIntf());
+ return;
+ }
+ disconnect(session);
+
+ try {
+ Device device = deviceService.getDevice(node.ovsdbId());
+ if (device.is(BridgeConfig.class)) {
+ BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
+ bridgeConfig.addPort(BridgeName.bridgeName(DEFAULT_BRIDGE), node.dpIntf());
+ } else {
+ log.warn("The bridging behaviour is not supported in device {}", device.id());
+ }
+ } catch (ItemNotFoundException e) {
+ log.warn("Failed to add {} on {}", node.dpIntf(), node.hostname());
+ }
}
/**
@@ -564,37 +669,62 @@
log.debug("Failed to SSH to {}", node.hostname());
return;
}
- getCurrentIps(session, INTEGRATION_BRIDGE).stream()
- .filter(ip -> !ip.equals(node.localMgmtIp().ip()))
- .filter(ip -> !ip.equals(node.dataIp().ip()))
- .forEach(ip -> deleteIp(session, ip, INTEGRATION_BRIDGE));
- boolean result = flushIp(session, node.dataIface()) &&
- setInterfaceUp(session, node.dataIface()) &&
- addIp(session, node.dataIp(), INTEGRATION_BRIDGE) &&
- addIp(session, node.localMgmtIp(), INTEGRATION_BRIDGE) &&
- setInterfaceUp(session, INTEGRATION_BRIDGE);
+ getCurrentIps(session, DEFAULT_BRIDGE).stream()
+ .filter(ip -> !ip.equals(node.localMgmtIp().ip()))
+ .filter(ip -> !ip.equals(node.dpIp().ip()))
+ .forEach(ip -> deleteIp(session, ip, DEFAULT_BRIDGE));
+
+ boolean result = flushIp(session, node.dpIntf()) &&
+ setInterfaceUp(session, node.dpIntf()) &&
+ addIp(session, node.dpIp(), DEFAULT_BRIDGE) &&
+ addIp(session, node.localMgmtIp(), DEFAULT_BRIDGE) &&
+ setInterfaceUp(session, DEFAULT_BRIDGE);
disconnect(session);
+
if (result) {
setNodeState(node, NodeState.COMPLETE);
}
}
- private boolean isIntegrationBridgeCreated(CordVtnNode node) {
- return deviceService.getDevice(node.integrationBridgeId()) != null &&
- deviceService.isAvailable(node.integrationBridgeId());
+ /**
+ * Checks if integration bridge exists and available.
+ *
+ * @param node cordvtn node
+ * @return true if the bridge is available, false otherwise
+ */
+ private boolean isBrIntCreated(CordVtnNode node) {
+ return (deviceService.getDevice(node.intBrId()) != null
+ && deviceService.isAvailable(node.intBrId()));
}
- private boolean isIfaceCreated(CordVtnNode node, String ifaceName) {
- if (Strings.isNullOrEmpty(ifaceName)) {
- return false;
- }
- return deviceService.getPorts(node.integrationBridgeId()).stream()
- .filter(p -> portName(p).contains(ifaceName) &&
- p.isEnabled())
- .findAny()
- .isPresent();
+ /**
+ * Checks if tunnel interface exists.
+ *
+ * @param node cordvtn node
+ * @return true if the interface exists, false otherwise
+ */
+ private boolean isTunnelIntfCreated(CordVtnNode node) {
+ return deviceService.getPorts(node.intBrId())
+ .stream()
+ .filter(p -> portName(p).contains(DEFAULT_TUNNEL) &&
+ p.isEnabled())
+ .findAny().isPresent();
+ }
+
+ /**
+ * Checks if data plane interface exists.
+ *
+ * @param node cordvtn node
+ * @return true if the interface exists, false otherwise
+ */
+ private boolean isDataPlaneIntfAdded(CordVtnNode node) {
+ return deviceService.getPorts(node.intBrId())
+ .stream()
+ .filter(p -> portName(p).contains(node.dpIntf()) &&
+ p.isEnabled())
+ .findAny().isPresent();
}
/**
@@ -610,12 +740,12 @@
return false;
}
- Set<IpAddress> intBrIps = getCurrentIps(session, INTEGRATION_BRIDGE);
- boolean result = getCurrentIps(session, node.dataIface()).isEmpty() &&
- isInterfaceUp(session, node.dataIface()) &&
- intBrIps.contains(node.dataIp().ip()) &&
+ Set<IpAddress> intBrIps = getCurrentIps(session, DEFAULT_BRIDGE);
+ boolean result = getCurrentIps(session, node.dpIntf()).isEmpty() &&
+ isInterfaceUp(session, node.dpIntf()) &&
+ intBrIps.contains(node.dpIp().ip()) &&
intBrIps.contains(node.localMgmtIp().ip()) &&
- isInterfaceUp(session, INTEGRATION_BRIDGE);
+ isInterfaceUp(session, DEFAULT_BRIDGE);
disconnect(session);
return result;
@@ -632,6 +762,16 @@
}
/**
+ * Returns connect point of a given host.
+ *
+ * @param host host
+ * @return connect point
+ */
+ private ConnectPoint connectPoint(Host host) {
+ return new ConnectPoint(host.location().deviceId(), host.location().port());
+ }
+
+ /**
* Returns cordvtn node associated with a given OVSDB device.
*
* @param ovsdbId OVSDB device id
@@ -651,7 +791,7 @@
*/
private CordVtnNode nodeByBridgeId(DeviceId bridgeId) {
return getNodes().stream()
- .filter(node -> node.integrationBridgeId().equals(bridgeId))
+ .filter(node -> node.intBrId().equals(bridgeId))
.findFirst().orElse(null);
}
@@ -662,7 +802,7 @@
* @return port name
*/
private String portName(Port port) {
- return port.annotations().value(PORT_NAME);
+ return port.annotations().value("portName");
}
private class OvsdbHandler implements ConnectionHandler<Device> {
@@ -679,8 +819,10 @@
@Override
public void disconnected(Device device) {
- log.debug("Device {} is disconnected", device.id());
- adminService.removeDevice(device.id());
+ if (!deviceService.isAvailable(device.id())) {
+ log.debug("Device {} is disconnected", device.id());
+ adminService.removeDevice(device.id());
+ }
}
}
@@ -700,7 +842,7 @@
public void disconnected(Device device) {
CordVtnNode node = nodeByBridgeId(device.id());
if (node != null) {
- log.warn("Integration Bridge is disconnected from {}", node.hostname());
+ log.debug("Integration Bridge is disconnected from {}", node.hostname());
setNodeState(node, NodeState.INCOMPLETE);
}
}
@@ -727,9 +869,9 @@
if (isNodeStateComplete(node)) {
instanceService.addInstance(connectPoint(port));
} else {
- log.warn("VM is detected on incomplete node, ignore it.", portName);
+ log.debug("VM is detected on incomplete node, ignore it.", portName);
}
- } else if (node.systemIfaces().contains(portName)) {
+ } else if (portName.contains(DEFAULT_TUNNEL) || portName.equals(node.dpIntf())) {
setNodeState(node, getNodeState(node));
}
}
@@ -755,9 +897,9 @@
if (isNodeStateComplete(node)) {
instanceService.removeInstance(connectPoint(port));
} else {
- log.warn("VM is vanished from incomplete node, ignore it.", portName);
+ log.debug("VM is vanished from incomplete node, ignore it.", portName);
}
- } else if (node.systemIfaces().contains(portName)) {
+ } else if (portName.contains(DEFAULT_TUNNEL) || portName.equals(node.dpIntf())) {
setNodeState(node, NodeState.INCOMPLETE);
}
}
diff --git a/src/main/java/org/opencord/cordvtn/impl/CordVtnPipeline.java b/src/main/java/org/opencord/cordvtn/impl/CordVtnPipeline.java
index 2aa9f1f..8aa0946 100644
--- a/src/main/java/org/opencord/cordvtn/impl/CordVtnPipeline.java
+++ b/src/main/java/org/opencord/cordvtn/impl/CordVtnPipeline.java
@@ -115,26 +115,26 @@
* Installs table miss rule to a give device.
*
* @param node cordvtn node
- * @param dataPort data plane port number
+ * @param dpPort data plane port number
* @param tunnelPort tunnel port number
*/
- public void initPipeline(CordVtnNode node, PortNumber dataPort, PortNumber tunnelPort) {
+ public void initPipeline(CordVtnNode node, PortNumber dpPort, PortNumber tunnelPort) {
checkNotNull(node);
- processTableZero(node.integrationBridgeId(), dataPort, node.dataIp().ip());
- processInPortTable(node.integrationBridgeId(), tunnelPort, dataPort);
- processAccessTypeTable(node.integrationBridgeId(), dataPort);
- processVlanTable(node.integrationBridgeId(), dataPort);
+ processTableZero(node.intBrId(), dpPort, node.dpIp().ip());
+ processInPortTable(node.intBrId(), tunnelPort, dpPort);
+ processAccessTypeTable(node.intBrId(), dpPort);
+ processVlanTable(node.intBrId(), dpPort);
}
- private void processTableZero(DeviceId deviceId, PortNumber dataPort, IpAddress dataIp) {
+ private void processTableZero(DeviceId deviceId, PortNumber dpPort, IpAddress dpIp) {
// take vxlan packet out onto the physical port
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchInPort(PortNumber.LOCAL)
.build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setOutput(dataPort)
+ .setOutput(dpPort)
.build();
FlowRule flowRule = DefaultFlowRule.builder()
@@ -151,7 +151,7 @@
// take a vxlan encap'd packet through the Linux stack
selector = DefaultTrafficSelector.builder()
- .matchInPort(dataPort)
+ .matchInPort(dpPort)
.matchEthType(Ethernet.TYPE_IPV4)
.matchIPProtocol(IPv4.PROTOCOL_UDP)
.matchUdpDst(TpPort.tpPort(VXLAN_UDP_PORT))
@@ -175,9 +175,9 @@
// take a packet to the data plane ip through Linux stack
selector = DefaultTrafficSelector.builder()
- .matchInPort(dataPort)
+ .matchInPort(dpPort)
.matchEthType(Ethernet.TYPE_IPV4)
- .matchIPDst(dataIp.toIpPrefix())
+ .matchIPDst(dpIp.toIpPrefix())
.build();
treatment = DefaultTrafficTreatment.builder()
@@ -198,9 +198,9 @@
// take an arp packet from physical through Linux stack
selector = DefaultTrafficSelector.builder()
- .matchInPort(dataPort)
+ .matchInPort(dpPort)
.matchEthType(Ethernet.TYPE_ARP)
- .matchArpTpa(dataIp.getIp4Address())
+ .matchArpTpa(dpIp.getIp4Address())
.build();
treatment = DefaultTrafficTreatment.builder()
@@ -261,7 +261,7 @@
processFlowRule(true, flowRule);
}
- private void processInPortTable(DeviceId deviceId, PortNumber tunnelPort, PortNumber dataPort) {
+ private void processInPortTable(DeviceId deviceId, PortNumber tunnelPort, PortNumber dpPort) {
checkNotNull(tunnelPort);
TrafficSelector selector = DefaultTrafficSelector.builder()
@@ -285,7 +285,7 @@
processFlowRule(true, flowRule);
selector = DefaultTrafficSelector.builder()
- .matchInPort(dataPort)
+ .matchInPort(dpPort)
.build();
treatment = DefaultTrafficTreatment.builder()
@@ -305,12 +305,12 @@
processFlowRule(true, flowRule);
}
- private void processAccessTypeTable(DeviceId deviceId, PortNumber dataPort) {
+ private void processAccessTypeTable(DeviceId deviceId, PortNumber dpPort) {
TrafficSelector selector = DefaultTrafficSelector.builder()
.build();
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
- .setOutput(dataPort)
+ .setOutput(dpPort)
.build();
FlowRule flowRule = DefaultFlowRule.builder()
@@ -326,7 +326,7 @@
processFlowRule(true, flowRule);
}
- private void processVlanTable(DeviceId deviceId, PortNumber dataPort) {
+ private void processVlanTable(DeviceId deviceId, PortNumber dpPort) {
// for traffic going out to WAN, strip vid 500 and take through data plane interface
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchVlanId(VLAN_WAN)
@@ -334,7 +334,7 @@
TrafficTreatment treatment = DefaultTrafficTreatment.builder()
.popVlan()
- .setOutput(dataPort)
+ .setOutput(dpPort)
.build();
FlowRule flowRule = DefaultFlowRule.builder()
diff --git a/src/main/java/org/opencord/cordvtn/impl/DependencyManager.java b/src/main/java/org/opencord/cordvtn/impl/DependencyManager.java
index eaebb69..2eb73db 100644
--- a/src/main/java/org/opencord/cordvtn/impl/DependencyManager.java
+++ b/src/main/java/org/opencord/cordvtn/impl/DependencyManager.java
@@ -157,7 +157,7 @@
GroupKey groupKey = getGroupKey(service.id());
Set<DeviceId> devices = nodeManager.completeNodes().stream()
- .map(CordVtnNode::integrationBridgeId)
+ .map(CordVtnNode::intBrId)
.collect(Collectors.toSet());
for (DeviceId deviceId : devices) {
@@ -217,7 +217,7 @@
Map<DeviceId, Set<PortNumber>> inPorts = Maps.newHashMap();
nodeManager.completeNodes().stream().forEach(node -> {
- DeviceId deviceId = node.integrationBridgeId();
+ DeviceId deviceId = node.intBrId();
GroupId groupId = createServiceGroup(deviceId, pService);
outGroups.put(deviceId, groupId);
@@ -279,7 +279,7 @@
.build();
nodeManager.completeNodes().stream().forEach(node -> {
- DeviceId deviceId = node.integrationBridgeId();
+ DeviceId deviceId = node.intBrId();
FlowRule flowRuleDirect = DefaultFlowRule.builder()
.fromApp(appId)
.withSelector(selector)
@@ -365,7 +365,7 @@
Set<Instance> instances) {
List<GroupBucket> buckets = Lists.newArrayList();
instances.stream().forEach(instance -> {
- Ip4Address tunnelIp = nodeManager.dataIp(instance.deviceId()).getIp4Address();
+ Ip4Address tunnelIp = nodeManager.dpIp(instance.deviceId()).getIp4Address();
TrafficTreatment.Builder tBuilder = DefaultTrafficTreatment.builder();
if (deviceId.equals(instance.deviceId())) {
diff --git a/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java b/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java
index 6269e98..3041bbf 100644
--- a/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java
+++ b/src/main/java/org/opencord/cordvtn/impl/InstanceManager.java
@@ -69,7 +69,6 @@
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
import static org.onlab.util.Tools.groupedThreads;
import static org.onosproject.dhcp.IpAssignment.AssignmentStatus.Option_RangeNotEnforced;
-import static org.onosproject.net.AnnotationKeys.PORT_NAME;
import static org.onosproject.xosclient.api.VtnServiceApi.NetworkType.MANAGEMENT;
import static org.opencord.cordvtn.api.Constants.*;
import static org.slf4j.LoggerFactory.getLogger;
diff --git a/src/main/java/org/opencord/cordvtn/impl/RemoteIpCommandUtil.java b/src/main/java/org/opencord/cordvtn/impl/RemoteIpCommandUtil.java
index 0be4fc4..bd2d922 100644
--- a/src/main/java/org/opencord/cordvtn/impl/RemoteIpCommandUtil.java
+++ b/src/main/java/org/opencord/cordvtn/impl/RemoteIpCommandUtil.java
@@ -204,7 +204,7 @@
* @param session session
*/
public static void disconnect(Session session) {
- if (session != null && session.isConnected()) {
+ if (session.isConnected()) {
session.disconnect();
}
}
diff --git a/src/main/java/org/opencord/cordvtn/impl/handler/DefaultInstanceHandler.java b/src/main/java/org/opencord/cordvtn/impl/handler/DefaultInstanceHandler.java
index a4ca067..98673cf 100644
--- a/src/main/java/org/opencord/cordvtn/impl/handler/DefaultInstanceHandler.java
+++ b/src/main/java/org/opencord/cordvtn/impl/handler/DefaultInstanceHandler.java
@@ -152,7 +152,7 @@
}
private void dstIpRule(Instance instance, long vni, boolean install) {
- Ip4Address tunnelIp = nodeManager.dataIp(instance.deviceId()).getIp4Address();
+ Ip4Address tunnelIp = nodeManager.dpIp(instance.deviceId()).getIp4Address();
TrafficSelector selector = DefaultTrafficSelector.builder()
.matchEthType(Ethernet.TYPE_IPV4)
@@ -177,12 +177,11 @@
pipeline.processFlowRule(install, flowRule);
for (CordVtnNode node : nodeManager.completeNodes()) {
- if (node.integrationBridgeId().equals(instance.deviceId())) {
+ if (node.intBrId().equals(instance.deviceId())) {
continue;
}
- ExtensionTreatment tunnelDst =
- pipeline.tunnelDstTreatment(node.integrationBridgeId(), tunnelIp);
+ ExtensionTreatment tunnelDst = pipeline.tunnelDstTreatment(node.intBrId(), tunnelIp);
if (tunnelDst == null) {
continue;
}
@@ -190,8 +189,8 @@
treatment = DefaultTrafficTreatment.builder()
.setEthDst(instance.mac())
.setTunnelId(vni)
- .extension(tunnelDst, node.integrationBridgeId())
- .setOutput(nodeManager.tunnelPort(node.integrationBridgeId()))
+ .extension(tunnelDst, node.intBrId())
+ .setOutput(nodeManager.tunnelPort(node.intBrId()))
.build();
flowRule = DefaultFlowRule.builder()
@@ -199,7 +198,7 @@
.withSelector(selector)
.withTreatment(treatment)
.withPriority(CordVtnPipeline.PRIORITY_DEFAULT)
- .forDevice(node.integrationBridgeId())
+ .forDevice(node.intBrId())
.forTable(CordVtnPipeline.TABLE_DST_IP)
.makePermanent()
.build();
@@ -249,7 +248,7 @@
.withSelector(selector)
.withTreatment(treatment)
.withPriority(CordVtnPipeline.PRIORITY_DEFAULT)
- .forDevice(node.integrationBridgeId())
+ .forDevice(node.intBrId())
.forTable(CordVtnPipeline.TABLE_ACCESS_TYPE)
.makePermanent()
.build();
@@ -274,7 +273,7 @@
.withSelector(selector)
.withTreatment(treatment)
.withPriority(CordVtnPipeline.PRIORITY_LOW)
- .forDevice(node.integrationBridgeId())
+ .forDevice(node.intBrId())
.forTable(CordVtnPipeline.TABLE_ACCESS_TYPE)
.makePermanent()
.build();
diff --git a/src/main/java/org/opencord/cordvtn/impl/handler/VsgInstanceHandler.java b/src/main/java/org/opencord/cordvtn/impl/handler/VsgInstanceHandler.java
index 648c341..1f96023 100644
--- a/src/main/java/org/opencord/cordvtn/impl/handler/VsgInstanceHandler.java
+++ b/src/main/java/org/opencord/cordvtn/impl/handler/VsgInstanceHandler.java
@@ -114,7 +114,7 @@
return;
}
populateVsgRules(vsgVm, getStag(vtnPort),
- nodeManager.dataPort(vsgVm.deviceId()),
+ nodeManager.dpPort(vsgVm.deviceId()),
vtnPort.addressPairs().keySet(),
true);
@@ -159,7 +159,7 @@
}
populateVsgRules(vsgVm, getStag(vtnPort),
- nodeManager.dataPort(vsgVm.deviceId()),
+ nodeManager.dpPort(vsgVm.deviceId()),
vtnPort.addressPairs().keySet(),
false);
}
@@ -229,11 +229,11 @@
instanceService.addNestedInstance(hostId, hostDesc);
}
- private void populateVsgRules(Instance vsgVm, VlanId stag, PortNumber dataPort,
+ private void populateVsgRules(Instance vsgVm, VlanId stag, PortNumber dpPort,
Set<IpAddress> vsgWanIps, boolean install) {
// for traffics with s-tag, strip the tag and take through the vSG VM
TrafficSelector selector = DefaultTrafficSelector.builder()
- .matchInPort(dataPort)
+ .matchInPort(dpPort)
.matchVlanId(stag)
.build();
@@ -261,7 +261,7 @@
.build();
treatment = DefaultTrafficTreatment.builder()
- .setOutput(dataPort)
+ .setOutput(dpPort)
.build();
flowRule = DefaultFlowRule.builder()