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) { |
| 10 | SwitchImpl onosSwitch = new SwitchImpl(graph); |
| 11 | onosSwitch.setDpid(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()) { |
| 14 | onosSwitch.addPort(map(graph, port)); |
| 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 | |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 20 | public static Port map(NetworkGraph graph, OFPhysicalPort port) { |
| 21 | PortImpl onosPort = new PortImpl(graph); |
| 22 | onosPort.setPortNumber(port.getPortNumber()); |
| 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) { |
| 27 | LinkImpl onosLink = new LinkImpl(graph); |
Yuta HIGUCHI | e1d9276 | 2014-02-06 12:05:52 -0800 | [diff] [blame^] | 28 | |
| 29 | Switch srcSw = graph.getSwitch(link.getSrc()); |
| 30 | onosLink.setSrcSwitch(srcSw); |
| 31 | onosLink.setSrcPort(srcSw.getPort(link.getSrcPort())); |
| 32 | |
| 33 | Switch dstSw = graph.getSwitch(link.getDst()); |
| 34 | onosLink.setDstSwitch(dstSw); |
| 35 | onosLink.setDstPort(dstSw.getPort(link.getDstPort())); |
| 36 | |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 37 | return onosLink; |
Yuta HIGUCHI | e1d9276 | 2014-02-06 12:05:52 -0800 | [diff] [blame^] | 38 | |
Jonathan Hart | 062a2e8 | 2014-02-03 09:41:57 -0800 | [diff] [blame] | 39 | } |
| 40 | } |