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()); |
| 12 | |
| 13 | for (OFPhysicalPort port : sw.getPorts()) { |
| 14 | onosSwitch.addPort(map(graph, port)); |
| 15 | } |
| 16 | |
| 17 | return onosSwitch; |
| 18 | } |
| 19 | |
| 20 | public static Port map(NetworkGraph graph, OFPhysicalPort port) { |
| 21 | PortImpl onosPort = new PortImpl(graph); |
| 22 | onosPort.setPortNumber(port.getPortNumber()); |
| 23 | return onosPort; |
| 24 | } |
| 25 | |
| 26 | public static Link map(NetworkGraph graph, net.floodlightcontroller.routing.Link link) { |
| 27 | LinkImpl onosLink = new LinkImpl(graph); |
| 28 | |
| 29 | onosLink.setSrcSwitch(link.getSrc()); |
| 30 | onosLink.setSrcPort(link.getSrcPort()); |
| 31 | onosLink.setDstSwitch(link.getDst()); |
| 32 | onosLink.setDstPort(link.getDstPort()); |
| 33 | |
| 34 | return onosLink; |
| 35 | |
| 36 | } |
| 37 | } |