Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 1 | package net.onrc.onos.ofcontroller.networkgraph; |
| 2 | |
| 3 | import org.openflow.protocol.OFPhysicalPort; |
| 4 | |
| 5 | import net.floodlightcontroller.core.IOFSwitch; |
| 6 | |
Yuta HIGUCHI | 66c1681 | 2014-02-12 14:35:50 -0800 | [diff] [blame^] | 7 | // XXX Either change the return value to Event Object or remove this class |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 8 | public class FloodlightToOnosMappers { |
| 9 | |
| 10 | public static Switch map(NetworkGraph graph, IOFSwitch sw) { |
Toshio Koide | 2f570c1 | 2014-02-06 16:55:32 -0800 | [diff] [blame] | 11 | SwitchImpl onosSwitch = new SwitchImpl(graph, sw.getId()); |
Yuta HIGUCHI | e1d9276 | 2014-02-06 12:05:52 -0800 | [diff] [blame] | 12 | |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 13 | for (OFPhysicalPort port : sw.getPorts()) { |
Toshio Koide | 2f570c1 | 2014-02-06 16:55:32 -0800 | [diff] [blame] | 14 | onosSwitch.addPort(map(graph, onosSwitch, port)); |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 15 | } |
Yuta HIGUCHI | e1d9276 | 2014-02-06 12:05:52 -0800 | [diff] [blame] | 16 | |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 17 | return onosSwitch; |
| 18 | } |
Yuta HIGUCHI | e1d9276 | 2014-02-06 12:05:52 -0800 | [diff] [blame] | 19 | |
Toshio Koide | 2f570c1 | 2014-02-06 16:55:32 -0800 | [diff] [blame] | 20 | public static Port map(NetworkGraph graph, SwitchImpl sw, OFPhysicalPort port) { |
Toshio Koide | 5799b60 | 2014-02-10 15:29:06 -0800 | [diff] [blame] | 21 | PortImpl onosPort = new PortImpl(graph, sw, Long.valueOf(port.getPortNumber())); |
Jonathan Hart | 891d050 | 2014-02-10 10:04:08 -0800 | [diff] [blame] | 22 | onosPort.setDescription(port.getName()); |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 23 | return onosPort; |
| 24 | } |
Yuta HIGUCHI | e1d9276 | 2014-02-06 12:05:52 -0800 | [diff] [blame] | 25 | |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 26 | public static Link map(NetworkGraph graph, net.floodlightcontroller.routing.Link link) { |
Yuta HIGUCHI | 66c1681 | 2014-02-12 14:35:50 -0800 | [diff] [blame^] | 27 | Port srcPort = graph.getSwitch(link.getSrc()).getPort(Long.valueOf(link.getSrcPort())); |
| 28 | Port dstPort = graph.getSwitch(link.getDst()).getPort(Long.valueOf(link.getDstPort())); |
| 29 | LinkImpl onosLink = new LinkImpl(graph, srcPort, dstPort); |
| 30 | |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 31 | return onosLink; |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 32 | } |
| 33 | } |