From 9feadc2c898a15809ee17aa933bebf87947905bc Mon Sep 17 00:00:00 2001 From: Thomas Vachuska Date: Tue, 18 Nov 2014 12:42:26 -0800 Subject: [PATCH] Fixing an issue with OpticalLinkProvider and reverting some topo changes. Change-Id: If57d529127323d0d2b0f8778ce68527de6284c77 --- .../onos/optical/OpticalLinkProvider.java | 29 ++++++++++-- tools/test/topos/oe-nonlinear-10.json | 9 +--- tools/test/topos/optical2.py | 9 +--- tools/test/topos/sys.config | 46 +++++++------------ 4 files changed, 44 insertions(+), 49 deletions(-) diff --git a/apps/optical/src/main/java/org/onlab/onos/optical/OpticalLinkProvider.java b/apps/optical/src/main/java/org/onlab/onos/optical/OpticalLinkProvider.java index 0f5236df2e..88e68b425e 100644 --- a/apps/optical/src/main/java/org/onlab/onos/optical/OpticalLinkProvider.java +++ b/apps/optical/src/main/java/org/onlab/onos/optical/OpticalLinkProvider.java @@ -20,8 +20,11 @@ import org.apache.felix.scr.annotations.Component; import org.apache.felix.scr.annotations.Deactivate; import org.apache.felix.scr.annotations.Reference; import org.apache.felix.scr.annotations.ReferenceCardinality; +import org.onlab.onos.net.ConnectPoint; import org.onlab.onos.net.Device; +import org.onlab.onos.net.DeviceId; import org.onlab.onos.net.Link; +import org.onlab.onos.net.Port; import org.onlab.onos.net.device.DeviceEvent; import org.onlab.onos.net.device.DeviceListener; import org.onlab.onos.net.device.DeviceService; @@ -91,7 +94,9 @@ public class OpticalLinkProvider extends AbstractProvider implements LinkProvide if (type == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED || type == DeviceEvent.Type.DEVICE_ADDED || type == DeviceEvent.Type.DEVICE_UPDATED) { - processLinks(device); + processDeviceLinks(device); + } else if (type == DeviceEvent.Type.PORT_UPDATED) { + processPortLinks(device, event.port()); } } } @@ -109,7 +114,7 @@ public class OpticalLinkProvider extends AbstractProvider implements LinkProvide } } - private void processLinks(Device device) { + private void processDeviceLinks(Device device) { for (Link link : linkService.getDeviceLinks(device.id())) { if (link.isDurable() && link.type() == OPTICAL) { processLink(link); @@ -117,9 +122,25 @@ public class OpticalLinkProvider extends AbstractProvider implements LinkProvide } } + private void processPortLinks(Device device, Port port) { + ConnectPoint connectPoint = new ConnectPoint(device.id(), port.number()); + for (Link link : linkService.getLinks(connectPoint)) { + if (link.isDurable() && link.type() == OPTICAL) { + processLink(link); + } + } + } + private void processLink(Link link) { - boolean active = deviceService.isAvailable(link.src().deviceId()) && - deviceService.isAvailable(link.dst().deviceId()); + DeviceId srcId = link.src().deviceId(); + DeviceId dstId = link.dst().deviceId(); + Port srcPort = deviceService.getPort(srcId, link.src().port()); + Port dstPort = deviceService.getPort(dstId, link.dst().port()); + + boolean active = deviceService.isAvailable(srcId) && + deviceService.isAvailable(dstId) && + srcPort.isEnabled() && dstPort.isEnabled(); + LinkDescription desc = new DefaultLinkDescription(link.src(), link.dst(), OPTICAL); if (active) { providerService.linkDetected(desc); diff --git a/tools/test/topos/oe-nonlinear-10.json b/tools/test/topos/oe-nonlinear-10.json index 474631d19a..9bf291e888 100644 --- a/tools/test/topos/oe-nonlinear-10.json +++ b/tools/test/topos/oe-nonlinear-10.json @@ -144,13 +144,6 @@ { "src": "of:0000ffffffff0003/2", "dst": "of:0000ffffffffff06/10", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, { "src": "of:0000ffffffff0004/2", "dst": "of:0000ffffffffff07/10", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, { "src": "of:0000ffffffff0005/2", "dst": "of:0000ffffffffff09/10", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, - { "src": "of:0000ffffffff0006/2", "dst": "of:0000ffffffffff0A/10", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, - - { "src": "of:0000ffffffff0001/3", "dst": "of:0000ffffffffff01/11", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, - { "src": "of:0000ffffffff0002/3", "dst": "of:0000ffffffffff04/11", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, - { "src": "of:0000ffffffff0003/3", "dst": "of:0000ffffffffff06/11", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, - { "src": "of:0000ffffffff0004/3", "dst": "of:0000ffffffffff07/11", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, - { "src": "of:0000ffffffff0005/3", "dst": "of:0000ffffffffff09/11", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } }, - { "src": "of:0000ffffffff0006/3", "dst": "of:0000ffffffffff0A/11", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } } + { "src": "of:0000ffffffff0006/2", "dst": "of:0000ffffffffff0A/10", "type": "OPTICAL", "annotations": { "bandwidth": 100000, "optical.type": "cross-connect", "durable": "true" } } ] } diff --git a/tools/test/topos/optical2.py b/tools/test/topos/optical2.py index b491ccad31..36cdbadd26 100644 --- a/tools/test/topos/optical2.py +++ b/tools/test/topos/optical2.py @@ -64,19 +64,12 @@ class OpticalTopo(Topo): self.addIntf(s5,'tap33') self.addIntf(s6,'tap34') - self.addIntf(s1,'tap35') - self.addIntf(s2,'tap36') - self.addIntf(s3,'tap37') - self.addIntf(s4,'tap38') - self.addIntf(s5,'tap39') - self.addIntf(s6,'tap40') - # if you use, sudo mn --custom custom/optical.py, then register the topo: topos = {'optical': ( lambda: OpticalTopo() )} def run(): - c = RemoteController('c','192.168.56.101',6633) + c = RemoteController('c','127.0.0.1',6633) net = Mininet( topo=OpticalTopo(),controller=None,autoSetMacs=True) net.addController(c) net.start() diff --git a/tools/test/topos/sys.config b/tools/test/topos/sys.config index 4ded6705d0..2b999d3964 100644 --- a/tools/test/topos/sys.config +++ b/tools/test/topos/sys.config @@ -35,13 +35,7 @@ {port,31,[{interface,"tap31"}]}, {port,32,[{interface,"tap32"}]}, {port,33,[{interface,"tap33"}]}, - {port,34,[{interface,"tap34"}]}, - {port,35,[{interface,"tap35"}]}, - {port,36,[{interface,"tap36"}]}, - {port,37,[{interface,"tap37"}]}, - {port,38,[{interface,"tap38"}]}, - {port,39,[{interface,"tap39"}]}, - {port,40,[{interface,"tap40"}]}]}, + {port,34,[{interface,"tap34"}]}]}, {capable_switch_queues,[]}, {optical_links, [{{1,50},{2,30}}, @@ -62,18 +56,17 @@ [{switch,1, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:01"}, - {controllers,[{"Switch0-Controller","192.168.56.101",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, [{port,1,[{queues,[]},{port_no,50}]}, {port,7,[{queues,[]},{port_no,20}]}, - {port,29,[{queues,[]},{port_no,10}]}, - {port,35,[{queues,[]},{port_no,11}]}]}]}, + {port,29,[{queues,[]},{port_no,10}]}]}]}, {switch,2, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:02"}, - {controllers,[{"Switch0-Controller","192.168.56.101",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -83,7 +76,7 @@ {switch,3, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:03"}, - {controllers,[{"Switch0-Controller","192.168.56.101",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -93,18 +86,17 @@ {switch,4, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:04"}, - {controllers,[{"Switch0-Controller","192.168.56.101",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, [{port,6,[{queues,[]},{port_no,50}]}, {port,13,[{queues,[]},{port_no,20}]}, - {port,30,[{queues,[]},{port_no,10}]}, - {port,36,[{queues,[]},{port_no,11}]}]}]}, + {port,30,[{queues,[]},{port_no,10}]}]}]}, {switch,5, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:05"}, - {controllers,[{"Switch0-Controller","192.168.56.101",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -115,19 +107,18 @@ {switch,7, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:07"}, - {controllers,[{"Switch0-Controller","192.168.56.101",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, [{port,18,[{queues,[]},{port_no,50}]}, {port,21,[{queues,[]},{port_no,20}]}, {port,23,[{queues,[]},{port_no,30}]}, - {port,32,[{queues,[]},{port_no,10}]}, - {port,38,[{queues,[]},{port_no,11}]}]}]}, + {port,32,[{queues,[]},{port_no,10}]}]}]}, {switch,8, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:08"}, - {controllers,[{"Switch0-Controller","192.168.56.101",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -137,29 +128,27 @@ {switch,9, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:09"}, - {controllers,[{"Switch0-Controller","192.168.56.101",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, [{port,24,[{queues,[]},{port_no,50}]}, {port,27,[{queues,[]},{port_no,20}]}, - {port,33,[{queues,[]},{port_no,10}]}, - {port,39,[{queues,[]},{port_no,11}]}]}]}, + {port,33,[{queues,[]},{port_no,10}]}]}]}, {switch,10, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:0A"}, - {controllers,[{"Switch0-Controller","192.168.56.101",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, [{port,26,[{queues,[]},{port_no,50}]}, {port,28,[{queues,[]},{port_no,20}]}, - {port,34,[{queues,[]},{port_no,10}]}, - {port,40,[{queues,[]},{port_no,11}]}]}]}, + {port,34,[{queues,[]},{port_no,10}]}]}]}, {switch,6, [{backend,linc_us4_oe}, {datapath_id,"00:00:ff:ff:ff:ff:ff:06"}, - {controllers,[{"Switch0-Controller","192.168.56.101",6633,tcp}]}, + {controllers,[{"Switch0-Controller","10.1.8.147",6633,tcp}]}, {controllers_listener,disabled}, {queues_status,disabled}, {ports, @@ -167,8 +156,7 @@ {port,14,[{queues,[]},{port_no,20}]}, {port,16,[{queues,[]},{port_no,40}]}, {port,19,[{queues,[]},{port_no,30}]}, - {port,31,[{queues,[]},{port_no,10}]}, - {port,37,[{queues,[]},{port_no,11}]}]}]}]}]}, + {port,31,[{queues,[]},{port_no,10}]}]}]}]}]}, {epcap,[{verbose,false},{stats_interval,10}]}, {enetconf, [{capabilities,