blob: 0b74cfc497d72d5eafd3e6a9a3ea95a8b6727b71 [file] [log] [blame]
Brian O'Connor67c6e662014-02-17 15:20:44 -08001package net.onrc.onos.intent.runtime;
2
3import java.util.HashSet;
4import java.util.List;
5import java.util.Map;
6import java.util.Set;
7
8import net.floodlightcontroller.core.IFloodlightProviderService;
9import net.floodlightcontroller.core.IOFSwitch;
10import net.onrc.onos.intent.FlowEntry;
11import net.onrc.onos.ofcontroller.flowprogrammer.IFlowPusherService;
12import net.onrc.onos.ofcontroller.networkgraph.NetworkGraph;
13import net.onrc.onos.ofcontroller.util.Pair;
14
15/**
16 *
17 * @author Brian O'Connor <bocon@onlab.us>
18 *
19 */
20
21public 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}