Brian O'Connor | 67c6e66 | 2014-02-17 15:20:44 -0800 | [diff] [blame^] | 1 | package net.onrc.onos.intent.runtime; |
| 2 | |
| 3 | import java.util.HashSet; |
| 4 | import java.util.List; |
| 5 | import java.util.Map; |
| 6 | import java.util.Set; |
| 7 | |
| 8 | import net.floodlightcontroller.core.IFloodlightProviderService; |
| 9 | import net.floodlightcontroller.core.IOFSwitch; |
| 10 | import net.onrc.onos.intent.FlowEntry; |
| 11 | import net.onrc.onos.ofcontroller.flowprogrammer.IFlowPusherService; |
| 12 | import net.onrc.onos.ofcontroller.networkgraph.NetworkGraph; |
| 13 | import net.onrc.onos.ofcontroller.util.Pair; |
| 14 | |
| 15 | /** |
| 16 | * |
| 17 | * @author Brian O'Connor <bocon@onlab.us> |
| 18 | * |
| 19 | */ |
| 20 | |
| 21 | public class PathInstallRuntime { |
| 22 | NetworkGraph graph; |
| 23 | IFlowPusherService pusher; |
| 24 | IFloodlightProviderService provider; |
| 25 | protected List<Set<FlowEntry>> plan; |
| 26 | |
| 27 | public PathInstallRuntime(NetworkGraph graph) { |
| 28 | this.graph = graph; |
| 29 | } |
| 30 | |
| 31 | public void installPlan(List<Set<FlowEntry>> plan) { |
| 32 | this.plan = plan; |
| 33 | Map<Long,IOFSwitch> switches = provider.getSwitches(); |
| 34 | for(Set<FlowEntry> phase : plan) { |
| 35 | Set<Pair<IOFSwitch, net.onrc.onos.ofcontroller.util.FlowEntry>> entries |
| 36 | = new HashSet<>(); |
| 37 | // convert flow entries and create pairs |
| 38 | for(FlowEntry entry : phase) { |
| 39 | entries.add(new Pair<>(switches.get(entry.getSwitch().getDpid()), |
| 40 | entry.getFlowEntry())); |
| 41 | } |
| 42 | // push flow entries to switches |
| 43 | pusher.pushFlowEntries(entries); |
| 44 | // TODO: wait for confirmation messages before proceeding |
| 45 | } |
| 46 | } |
| 47 | |
| 48 | } |