[ONOS-5911] Port removal after receiving OFPR_DELETE port status reason.
Change-Id: I1f3f6c752da5f989a2d727f378e9f04fbbb71341
diff --git a/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java b/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
index 6fbb21c..3b50882 100644
--- a/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
+++ b/core/net/src/main/java/org/onosproject/net/device/impl/DeviceManager.java
@@ -592,6 +592,41 @@
}
@Override
+ public void deletePort(DeviceId deviceId, PortDescription basePortDescription) {
+
+ checkNotNull(deviceId, DEVICE_ID_NULL);
+ checkNotNull(basePortDescription, PORT_DESCRIPTION_NULL);
+ checkValidity();
+
+ if (!mastershipService.isLocalMaster(deviceId)) {
+ // Never been a master for this device
+ // any update will be ignored.
+ log.trace("Ignoring {} port update on standby node. {}", deviceId,
+ basePortDescription);
+ return;
+ }
+
+ Device device = getDevice(deviceId);
+ if (device == null) {
+ log.trace("Device not found: {}", deviceId);
+ }
+
+ PortDescription newPortDescription = new DefaultPortDescription(basePortDescription.portNumber(),
+ basePortDescription.isEnabled(),
+ true,
+ basePortDescription.type(),
+ basePortDescription.portSpeed(),
+ basePortDescription.annotations());
+ final DeviceEvent event = store.updatePortStatus(this.provider().id(),
+ deviceId,
+ newPortDescription);
+ if (event != null) {
+ log.info("Device {} port {} status changed", deviceId, event.port().number());
+ post(event);
+ }
+ }
+
+ @Override
public void receivedRoleReply(DeviceId deviceId, MastershipRole requested,
MastershipRole response) {
// Several things can happen here: