Committed by
Gerrit Code Review
when a switch vapourizes so must its ports
Change-Id: Ibcbcc47f691c24897985978a39da9dba6411ba2a disable a port which is deleted Change-Id: Ic6e0cb0a9901a6589b587aeb89bfc1b302d17516
Showing
2 changed files
with
23 additions
and
1 deletions
... | @@ -25,6 +25,8 @@ import java.util.concurrent.Executors; | ... | @@ -25,6 +25,8 @@ import java.util.concurrent.Executors; |
25 | import java.util.concurrent.ScheduledExecutorService; | 25 | import java.util.concurrent.ScheduledExecutorService; |
26 | import java.util.concurrent.TimeUnit; | 26 | import java.util.concurrent.TimeUnit; |
27 | 27 | ||
28 | + | ||
29 | +import com.google.common.collect.Lists; | ||
28 | import org.apache.felix.scr.annotations.Activate; | 30 | import org.apache.felix.scr.annotations.Activate; |
29 | import org.apache.felix.scr.annotations.Component; | 31 | import org.apache.felix.scr.annotations.Component; |
30 | import org.apache.felix.scr.annotations.Deactivate; | 32 | import org.apache.felix.scr.annotations.Deactivate; |
... | @@ -46,6 +48,7 @@ import org.onlab.onos.net.MastershipRole; | ... | @@ -46,6 +48,7 @@ import org.onlab.onos.net.MastershipRole; |
46 | import org.onlab.onos.net.Port; | 48 | import org.onlab.onos.net.Port; |
47 | import org.onlab.onos.net.PortNumber; | 49 | import org.onlab.onos.net.PortNumber; |
48 | import org.onlab.onos.net.device.DefaultDeviceDescription; | 50 | import org.onlab.onos.net.device.DefaultDeviceDescription; |
51 | +import org.onlab.onos.net.device.DefaultPortDescription; | ||
49 | import org.onlab.onos.net.device.DeviceAdminService; | 52 | import org.onlab.onos.net.device.DeviceAdminService; |
50 | import org.onlab.onos.net.device.DeviceClockProviderService; | 53 | import org.onlab.onos.net.device.DeviceClockProviderService; |
51 | import org.onlab.onos.net.device.DeviceDescription; | 54 | import org.onlab.onos.net.device.DeviceDescription; |
... | @@ -330,6 +333,13 @@ public class DeviceManager | ... | @@ -330,6 +333,13 @@ public class DeviceManager |
330 | log.info("Device {} disconnected from this node", deviceId); | 333 | log.info("Device {} disconnected from this node", deviceId); |
331 | 334 | ||
332 | DeviceEvent event = null; | 335 | DeviceEvent event = null; |
336 | + List<Port> ports = store.getPorts(deviceId); | ||
337 | + List<PortDescription> descs = Lists.newArrayList(); | ||
338 | + ports.forEach(port -> | ||
339 | + descs.add(new DefaultPortDescription(port.number(), | ||
340 | + false, port.type(), | ||
341 | + port.portSpeed()))); | ||
342 | + store.updatePorts(this.provider().id(), deviceId, descs); | ||
333 | try { | 343 | try { |
334 | event = store.markOffline(deviceId); | 344 | event = store.markOffline(deviceId); |
335 | } catch (IllegalStateException e) { | 345 | } catch (IllegalStateException e) { | ... | ... |
... | @@ -46,6 +46,7 @@ import org.projectfloodlight.openflow.protocol.OFFactory; | ... | @@ -46,6 +46,7 @@ import org.projectfloodlight.openflow.protocol.OFFactory; |
46 | import org.projectfloodlight.openflow.protocol.OFPortConfig; | 46 | import org.projectfloodlight.openflow.protocol.OFPortConfig; |
47 | import org.projectfloodlight.openflow.protocol.OFPortDesc; | 47 | import org.projectfloodlight.openflow.protocol.OFPortDesc; |
48 | import org.projectfloodlight.openflow.protocol.OFPortFeatures; | 48 | import org.projectfloodlight.openflow.protocol.OFPortFeatures; |
49 | +import org.projectfloodlight.openflow.protocol.OFPortReason; | ||
49 | import org.projectfloodlight.openflow.protocol.OFPortState; | 50 | import org.projectfloodlight.openflow.protocol.OFPortState; |
50 | import org.projectfloodlight.openflow.protocol.OFPortStatus; | 51 | import org.projectfloodlight.openflow.protocol.OFPortStatus; |
51 | import org.projectfloodlight.openflow.protocol.OFVersion; | 52 | import org.projectfloodlight.openflow.protocol.OFVersion; |
... | @@ -242,7 +243,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -242,7 +243,7 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
242 | 243 | ||
243 | @Override | 244 | @Override |
244 | public void portChanged(Dpid dpid, OFPortStatus status) { | 245 | public void portChanged(Dpid dpid, OFPortStatus status) { |
245 | - PortDescription portDescription = buildPortDescription(status.getDesc()); | 246 | + PortDescription portDescription = buildPortDescription(status); |
246 | providerService.portStatusChanged(deviceId(uri(dpid)), portDescription); | 247 | providerService.portStatusChanged(deviceId(uri(dpid)), portDescription); |
247 | } | 248 | } |
248 | 249 | ||
... | @@ -303,6 +304,17 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr | ... | @@ -303,6 +304,17 @@ public class OpenFlowDeviceProvider extends AbstractProvider implements DevicePr |
303 | return new DefaultPortDescription(portNo, enabled, type, portSpeed(port)); | 304 | return new DefaultPortDescription(portNo, enabled, type, portSpeed(port)); |
304 | } | 305 | } |
305 | 306 | ||
307 | + private PortDescription buildPortDescription(OFPortStatus status) { | ||
308 | + OFPortDesc port = status.getDesc(); | ||
309 | + if (status.getReason() != OFPortReason.DELETE) { | ||
310 | + return buildPortDescription(port); | ||
311 | + } else { | ||
312 | + PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber()); | ||
313 | + Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER; | ||
314 | + return new DefaultPortDescription(portNo, false, type, portSpeed(port)); | ||
315 | + } | ||
316 | + } | ||
317 | + | ||
306 | private long portSpeed(OFPortDesc port) { | 318 | private long portSpeed(OFPortDesc port) { |
307 | if (port.getVersion() == OFVersion.OF_13) { | 319 | if (port.getVersion() == OFVersion.OF_13) { |
308 | return port.getCurrSpeed() / MBPS; | 320 | return port.getCurrSpeed() / MBPS; | ... | ... |
-
Please register or login to post a comment