when a switch vapourizes so must its ports
Change-Id: Ibcbcc47f691c24897985978a39da9dba6411ba2a
disable a port which is deleted
Change-Id: Ic6e0cb0a9901a6589b587aeb89bfc1b302d17516
diff --git a/core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java b/core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
index b00b993..6c117b8 100644
--- a/core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
+++ b/core/net/src/main/java/org/onlab/onos/net/device/impl/DeviceManager.java
@@ -25,6 +25,8 @@
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+
+import com.google.common.collect.Lists;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
@@ -46,6 +48,7 @@
import org.onlab.onos.net.Port;
import org.onlab.onos.net.PortNumber;
import org.onlab.onos.net.device.DefaultDeviceDescription;
+import org.onlab.onos.net.device.DefaultPortDescription;
import org.onlab.onos.net.device.DeviceAdminService;
import org.onlab.onos.net.device.DeviceClockProviderService;
import org.onlab.onos.net.device.DeviceDescription;
@@ -330,6 +333,13 @@
log.info("Device {} disconnected from this node", deviceId);
DeviceEvent event = null;
+ List<Port> ports = store.getPorts(deviceId);
+ List<PortDescription> descs = Lists.newArrayList();
+ ports.forEach(port ->
+ descs.add(new DefaultPortDescription(port.number(),
+ false, port.type(),
+ port.portSpeed())));
+ store.updatePorts(this.provider().id(), deviceId, descs);
try {
event = store.markOffline(deviceId);
} catch (IllegalStateException e) {
diff --git a/providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java b/providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
index 617b0ba..c44a4d4 100644
--- a/providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/providers/openflow/device/src/main/java/org/onlab/onos/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -46,6 +46,7 @@
import org.projectfloodlight.openflow.protocol.OFPortConfig;
import org.projectfloodlight.openflow.protocol.OFPortDesc;
import org.projectfloodlight.openflow.protocol.OFPortFeatures;
+import org.projectfloodlight.openflow.protocol.OFPortReason;
import org.projectfloodlight.openflow.protocol.OFPortState;
import org.projectfloodlight.openflow.protocol.OFPortStatus;
import org.projectfloodlight.openflow.protocol.OFVersion;
@@ -242,7 +243,7 @@
@Override
public void portChanged(Dpid dpid, OFPortStatus status) {
- PortDescription portDescription = buildPortDescription(status.getDesc());
+ PortDescription portDescription = buildPortDescription(status);
providerService.portStatusChanged(deviceId(uri(dpid)), portDescription);
}
@@ -303,6 +304,17 @@
return new DefaultPortDescription(portNo, enabled, type, portSpeed(port));
}
+ private PortDescription buildPortDescription(OFPortStatus status) {
+ OFPortDesc port = status.getDesc();
+ if (status.getReason() != OFPortReason.DELETE) {
+ return buildPortDescription(port);
+ } else {
+ PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
+ Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
+ return new DefaultPortDescription(portNo, false, type, portSpeed(port));
+ }
+ }
+
private long portSpeed(OFPortDesc port) {
if (port.getVersion() == OFVersion.OF_13) {
return port.getCurrSpeed() / MBPS;