blob: 3e4ff4add590ed7118e408e8714dd0d5a26703e2 [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
Brian O'Connor12861f72014-02-19 20:40:32 -080021public class PlanInstallRuntime {
Brian O'Connor67c6e662014-02-17 15:20:44 -080022 NetworkGraph graph;
23 IFlowPusherService pusher;
24 IFloodlightProviderService provider;
Brian O'Connor67c6e662014-02-17 15:20:44 -080025
Brian O'Connor12861f72014-02-19 20:40:32 -080026 public PlanInstallRuntime(NetworkGraph graph,
27 IFloodlightProviderService provider,
28 IFlowPusherService pusher) {
Brian O'Connor67c6e662014-02-17 15:20:44 -080029 this.graph = graph;
Brian O'Connor12861f72014-02-19 20:40:32 -080030 this.provider = provider;
31 this.pusher = pusher;
Brian O'Connor67c6e662014-02-17 15:20:44 -080032 }
33
34 public void installPlan(List<Set<FlowEntry>> plan) {
Brian O'Connor67c6e662014-02-17 15:20:44 -080035 Map<Long,IOFSwitch> switches = provider.getSwitches();
36 for(Set<FlowEntry> phase : plan) {
Brian O'Connor12861f72014-02-19 20:40:32 -080037 Set<Pair<IOFSwitch, net.onrc.onos.ofcontroller.util.FlowEntry>> entries = new HashSet<>();
Brian O'Connor67c6e662014-02-17 15:20:44 -080038 // convert flow entries and create pairs
39 for(FlowEntry entry : phase) {
40 entries.add(new Pair<>(switches.get(entry.getSwitch().getDpid()),
41 entry.getFlowEntry()));
42 }
43 // push flow entries to switches
44 pusher.pushFlowEntries(entries);
45 // TODO: wait for confirmation messages before proceeding
46 }
47 }
48
49}