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 | |
| 7 | public class FloodlightToOnosMappers { |
| 8 | |
| 9 | public static Switch map(NetworkGraph graph, IOFSwitch sw) { |
Toshio Koide | 2f570c1 | 2014-02-06 16:55:32 -0800 | [diff] [blame] | 10 | SwitchImpl onosSwitch = new SwitchImpl(graph, sw.getId()); |
Yuta HIGUCHI | e1d9276 | 2014-02-06 12:05:52 -0800 | [diff] [blame] | 11 | |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 12 | for (OFPhysicalPort port : sw.getPorts()) { |
Toshio Koide | 2f570c1 | 2014-02-06 16:55:32 -0800 | [diff] [blame] | 13 | onosSwitch.addPort(map(graph, onosSwitch, port)); |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 14 | } |
Yuta HIGUCHI | e1d9276 | 2014-02-06 12:05:52 -0800 | [diff] [blame] | 15 | |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 16 | return onosSwitch; |
| 17 | } |
Yuta HIGUCHI | e1d9276 | 2014-02-06 12:05:52 -0800 | [diff] [blame] | 18 | |
Toshio Koide | 2f570c1 | 2014-02-06 16:55:32 -0800 | [diff] [blame] | 19 | public static Port map(NetworkGraph graph, SwitchImpl sw, OFPhysicalPort port) { |
| 20 | PortImpl onosPort = new PortImpl(graph, sw, new Long(port.getPortNumber())); |
Jonathan Hart | 891d050 | 2014-02-10 10:04:08 -0800 | [diff] [blame^] | 21 | onosPort.setDescription(port.getName()); |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 22 | return onosPort; |
| 23 | } |
Yuta HIGUCHI | e1d9276 | 2014-02-06 12:05:52 -0800 | [diff] [blame] | 24 | |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 25 | public static Link map(NetworkGraph graph, net.floodlightcontroller.routing.Link link) { |
Jonathan Hart | 891d050 | 2014-02-10 10:04:08 -0800 | [diff] [blame^] | 26 | //Port srcPort = graph.getSwitch(link.getSrc()).getPort(Long.valueOf(link.getSrcPort())); |
| 27 | //Port dstPort = graph.getSwitch(link.getDst()).getPort(Long.valueOf(link.getDstPort())); |
| 28 | //LinkImpl onosLink = new LinkImpl(graph, srcPort, dstPort); |
| 29 | LinkImpl onosLink = new LinkImpl(graph, link.getSrc(), (long)link.getSrcPort(), |
| 30 | link.getDst(), (long)link.getDstPort()); |
| 31 | |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 32 | return onosLink; |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 33 | } |
| 34 | } |