CORD-247 Add host management network interface to integration bridge
- Node can have management network connectivity by adding "hostManagementIface"
field to the network config "nodes" block, it's optional field
- Added Builder of CordVtnNode
- Improved cordvtn-node-check result
- Some renamings, intBrId -> integrationBridgeId, dpIp -> dataIp,
dpIntf -> dataIface, and dpPort -> dataPort
Change-Id: Iad16237e7f118886d5f3fa5a46f9e9f9649fe997
diff --git a/src/main/java/org/opencord/cordvtn/impl/CordVtnNodeManager.java b/src/main/java/org/opencord/cordvtn/impl/CordVtnNodeManager.java
index 8f30931..463c5d5 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.collect.Sets;
+import com.google.common.base.Strings;
import com.jcraft.jsch.Session;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
@@ -24,11 +24,15 @@
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.onosproject.net.behaviour.TunnelEndPoints;
+import org.onosproject.net.behaviour.TunnelKeys;
import org.opencord.cordvtn.api.ConnectionHandler;
import org.opencord.cordvtn.api.CordVtnConfig;
import org.opencord.cordvtn.api.CordVtnNode;
@@ -39,19 +43,15 @@
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;
@@ -73,10 +73,7 @@
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;
@@ -85,6 +82,7 @@
import static com.google.common.base.Preconditions.checkNotNull;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
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.*;
@@ -109,14 +107,7 @@
.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;
@@ -134,7 +125,7 @@
protected DeviceAdminService adminService;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
- protected OvsdbController controller;
+ protected OvsdbController ovsdbController;
@Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
protected ClusterService clusterService;
@@ -173,21 +164,27 @@
INIT {
@Override
public void process(CordVtnNodeManager nodeManager, CordVtnNode node) {
+ // make sure there is OVSDB connection
if (!nodeManager.isOvsdbConnected(node)) {
nodeManager.connectOvsdb(node);
- } else {
- nodeManager.createIntegrationBridge(node);
+ return;
}
+ 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);
- } else {
- nodeManager.createTunnelInterface(node);
- nodeManager.addDataPlaneInterface(node);
+ return;
+ }
+
+ nodeManager.createTunnelInterface(node);
+ nodeManager.addSystemInterface(node, node.dataIface());
+ if (node.hostMgmtIface().isPresent()) {
+ nodeManager.addSystemInterface(node, node.hostMgmtIface().get());
}
}
},
@@ -261,11 +258,10 @@
*/
public void deleteNode(CordVtnNode node) {
checkNotNull(node);
-
- if (isOvsdbConnected(node)) {
- disconnectOvsdb(node);
+ OvsdbClientService ovsdbClient = getOvsdbClient(node);
+ if (ovsdbClient != null && ovsdbClient.isConnected()) {
+ ovsdbClient.disconnect();
}
-
nodeStore.remove(node.hostname());
}
@@ -277,50 +273,7 @@
*/
public boolean isNodeInitComplete(CordVtnNode node) {
checkNotNull(node);
- 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;
+ return getNodeState(node).equals(NodeState.COMPLETE);
}
/**
@@ -347,7 +300,8 @@
* @return set of nodes
*/
public Set<CordVtnNode> completeNodes() {
- return getNodes().stream().filter(this::isNodeInitComplete).collect(Collectors.toSet());
+ return getNodes().stream().filter(this::isNodeStateComplete)
+ .collect(Collectors.toSet());
}
/**
@@ -356,14 +310,14 @@
* @param deviceId integration bridge device id
* @return port number; null otherwise
*/
- public PortNumber dpPort(DeviceId deviceId) {
+ public PortNumber dataPort(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.dpIntf()) &&
+ .filter(p -> portName(p).contains(node.dataIface()) &&
p.isEnabled())
.findFirst().orElse(null);
@@ -376,13 +330,13 @@
* @param deviceId integration bridge device id
* @return ip address; null otherwise
*/
- public IpAddress dpIp(DeviceId deviceId) {
+ public IpAddress dataIp(DeviceId deviceId) {
CordVtnNode node = nodeByBridgeId(deviceId);
if (node == null) {
log.warn("Failed to get node for {}", deviceId);
return null;
}
- return node.dpIp().ip();
+ return node.dataIp().ip();
}
/**
@@ -438,18 +392,29 @@
* @param node cordvtn node
*/
private void postInit(CordVtnNode node) {
- disconnectOvsdb(node);
- pipeline.initPipeline(node, dpPort(node.intBrId()), tunnelPort(node.intBrId()));
+ checkNotNull(node);
- deviceService.getPorts(node.intBrId()).stream()
+ // 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()
.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(connectPoint(host));
+ if (deviceService.getPort(
+ host.location().deviceId(),
+ host.location().port()) == null) {
+ instanceService.removeInstance(host.location());
}
});
@@ -464,7 +429,6 @@
*/
private void setNodeState(CordVtnNode node, NodeState newState) {
checkNotNull(node);
-
log.debug("Changed {} state: {}", node.hostname(), newState);
nodeStore.put(node.hostname(), CordVtnNode.getUpdatedNode(node, newState));
}
@@ -477,17 +441,18 @@
*/
private NodeState getNodeState(CordVtnNode node) {
checkNotNull(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 {
+ if (!isIntegrationBridgeCreated(node)) {
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;
}
/**
@@ -498,10 +463,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();
}
/**
@@ -511,150 +476,83 @@
*/
private void connectOvsdb(CordVtnNode node) {
checkNotNull(node);
-
- 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();
- }
+ ovsdbController.connect(node.hostMgmtIp().ip(), node.ovsdbPort());
}
/**
* Returns OVSDB client for a given node.
*
* @param node cordvtn node
- * @return OVSDB client, or null if it fails to get OVSDB client
+ * @return ovsdb client, or null if there's no ovsdb connection
*/
private OvsdbClientService getOvsdbClient(CordVtnNode node) {
checkNotNull(node);
-
- 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;
+ OvsdbNodeId ovsdb = new OvsdbNodeId(
+ node.hostMgmtIp().ip(), node.ovsdbPort().toInt());
+ return ovsdbController.getOvsdbClient(ovsdb);
}
- /**
- * Creates an integration bridge for a given node.
- *
- * @param node cordvtn node
- */
private void createIntegrationBridge(CordVtnNode node) {
- if (isBrIntCreated(node)) {
+ Device device = deviceService.getDevice(node.ovsdbId());
+ if (device == null || !device.is(BridgeConfig.class)) {
+ log.error("Failed to create integration bridge on {}", node.ovsdbId());
return;
}
- List<ControllerInfo> controllers = new ArrayList<>();
- Sets.newHashSet(clusterService.getNodes()).stream()
- .forEach(controller -> {
- ControllerInfo ctrlInfo = new ControllerInfo(controller.ip(), OFPORT, "tcp");
- controllers.add(ctrlInfo);
- });
+ List<ControllerInfo> controllers = clusterService.getNodes().stream()
+ .map(controller -> new ControllerInfo(controller.ip(), OF_PORT, "tcp"))
+ .collect(Collectors.toList());
- String dpid = node.intBrId().toString().substring(DPID_BEGIN);
+ 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();
- 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());
- }
+ BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
+ bridgeConfig.addBridge(bridgeDesc);
}
- /**
- * Creates tunnel interface to the integration bridge for a given node.
- *
- * @param node cordvtn node
- */
private void createTunnelInterface(CordVtnNode node) {
- if (isTunnelIntfCreated(node)) {
+ Device device = deviceService.getDevice(node.ovsdbId());
+ if (device == null || !device.is(InterfaceConfig.class)) {
+ log.error("Failed to create tunnel interface on {}", node.ovsdbId());
return;
}
- DefaultAnnotations.Builder optionBuilder = DefaultAnnotations.builder();
- for (String key : DEFAULT_TUNNEL_OPTIONS.keySet()) {
- optionBuilder.set(key, DEFAULT_TUNNEL_OPTIONS.get(key));
- }
+ TunnelDescription tunnelDesc = DefaultTunnelDescription.builder()
+ .deviceId(INTEGRATION_BRIDGE)
+ .ifaceName(DEFAULT_TUNNEL)
+ .type(VXLAN)
+ .remote(TunnelEndPoints.flowTunnelEndpoint())
+ .key(TunnelKeys.flowTunnelKey())
+ .build();
- 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());
- }
+ InterfaceConfig ifaceConfig = device.as(InterfaceConfig.class);
+ ifaceConfig.addTunnelMode(DEFAULT_TUNNEL, tunnelDesc);
}
- /**
- * Adds data plane interface to a given node.
- *
- * @param node cordvtn node
- */
- private void addDataPlaneInterface(CordVtnNode node) {
- if (isDataPlaneIntfAdded(node)) {
- return;
- }
-
+ private void addSystemInterface(CordVtnNode node, String ifaceName) {
Session session = connect(node.sshInfo());
- if (session == null) {
- log.debug("Failed to SSH to {}", node.hostname());
+ 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());
return;
}
- 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());
- }
+ BridgeConfig bridgeConfig = device.as(BridgeConfig.class);
+ bridgeConfig.addPort(BridgeName.bridgeName(INTEGRATION_BRIDGE), ifaceName);
}
/**
@@ -669,62 +567,37 @@
log.debug("Failed to SSH to {}", node.hostname());
return;
}
-
- getCurrentIps(session, DEFAULT_BRIDGE).stream()
+ getCurrentIps(session, INTEGRATION_BRIDGE).stream()
.filter(ip -> !ip.equals(node.localMgmtIp().ip()))
- .filter(ip -> !ip.equals(node.dpIp().ip()))
- .forEach(ip -> deleteIp(session, ip, DEFAULT_BRIDGE));
+ .filter(ip -> !ip.equals(node.dataIp().ip()))
+ .forEach(ip -> deleteIp(session, ip, INTEGRATION_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);
+ 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);
disconnect(session);
-
if (result) {
setNodeState(node, NodeState.COMPLETE);
}
}
- /**
- * 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 isIntegrationBridgeCreated(CordVtnNode node) {
+ return deviceService.getDevice(node.integrationBridgeId()) != null &&
+ deviceService.isAvailable(node.integrationBridgeId());
}
- /**
- * 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();
+ 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();
}
/**
@@ -740,12 +613,12 @@
return false;
}
- Set<IpAddress> intBrIps = getCurrentIps(session, DEFAULT_BRIDGE);
- boolean result = getCurrentIps(session, node.dpIntf()).isEmpty() &&
- isInterfaceUp(session, node.dpIntf()) &&
- intBrIps.contains(node.dpIp().ip()) &&
+ Set<IpAddress> intBrIps = getCurrentIps(session, INTEGRATION_BRIDGE);
+ boolean result = getCurrentIps(session, node.dataIface()).isEmpty() &&
+ isInterfaceUp(session, node.dataIface()) &&
+ intBrIps.contains(node.dataIp().ip()) &&
intBrIps.contains(node.localMgmtIp().ip()) &&
- isInterfaceUp(session, DEFAULT_BRIDGE);
+ isInterfaceUp(session, INTEGRATION_BRIDGE);
disconnect(session);
return result;
@@ -762,16 +635,6 @@
}
/**
- * 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
@@ -791,7 +654,7 @@
*/
private CordVtnNode nodeByBridgeId(DeviceId bridgeId) {
return getNodes().stream()
- .filter(node -> node.intBrId().equals(bridgeId))
+ .filter(node -> node.integrationBridgeId().equals(bridgeId))
.findFirst().orElse(null);
}
@@ -802,7 +665,7 @@
* @return port name
*/
private String portName(Port port) {
- return port.annotations().value("portName");
+ return port.annotations().value(PORT_NAME);
}
private class OvsdbHandler implements ConnectionHandler<Device> {
@@ -819,10 +682,8 @@
@Override
public void disconnected(Device device) {
- if (!deviceService.isAvailable(device.id())) {
- log.debug("Device {} is disconnected", device.id());
- adminService.removeDevice(device.id());
- }
+ log.debug("Device {} is disconnected", device.id());
+ adminService.removeDevice(device.id());
}
}
@@ -842,7 +703,7 @@
public void disconnected(Device device) {
CordVtnNode node = nodeByBridgeId(device.id());
if (node != null) {
- log.debug("Integration Bridge is disconnected from {}", node.hostname());
+ log.warn("Integration Bridge is disconnected from {}", node.hostname());
setNodeState(node, NodeState.INCOMPLETE);
}
}
@@ -869,9 +730,9 @@
if (isNodeStateComplete(node)) {
instanceService.addInstance(connectPoint(port));
} else {
- log.debug("VM is detected on incomplete node, ignore it.", portName);
+ log.warn("VM is detected on incomplete node, ignore it.", portName);
}
- } else if (portName.contains(DEFAULT_TUNNEL) || portName.equals(node.dpIntf())) {
+ } else if (node.systemIfaces().contains(portName)) {
setNodeState(node, getNodeState(node));
}
}
@@ -897,9 +758,9 @@
if (isNodeStateComplete(node)) {
instanceService.removeInstance(connectPoint(port));
} else {
- log.debug("VM is vanished from incomplete node, ignore it.", portName);
+ log.warn("VM is vanished from incomplete node, ignore it.", portName);
}
- } else if (portName.contains(DEFAULT_TUNNEL) || portName.equals(node.dpIntf())) {
+ } else if (node.systemIfaces().contains(portName)) {
setNodeState(node, NodeState.INCOMPLETE);
}
}