Brian O'Connor

refactoring OpticalPathIntent

Change-Id: Ic6ab6237237b2a5019851182b2869110bc5b1b73
......@@ -6,46 +6,45 @@ import org.onlab.onos.ApplicationId;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.Link;
import org.onlab.onos.net.Path;
import org.onlab.onos.net.flow.TrafficSelector;
import org.onlab.onos.net.flow.TrafficTreatment;
import com.google.common.base.MoreObjects;
public class OpticalPathIntent extends OpticalConnectivityIntent {
public class OpticalPathIntent extends ConnectivityIntent {
private final ConnectPoint src;
private final ConnectPoint dst;
private final Path path;
// private final TrafficSelector opticalMatch;
// private final TrafficTreatment opticalAction;
public OpticalPathIntent(ApplicationId appId,
ConnectPoint src,
ConnectPoint dst,
TrafficSelector match,
TrafficTreatment action,
Path path) {
super(appId, src, dst);
// this.opticalMatch = match;
// this.opticalAction = action;
super(id(OpticalPathIntent.class, src, dst),
appId, resources(path.links()), null, null);
this.src = src;
this.dst = dst;
this.path = path;
}
protected OpticalPathIntent() {
// this.opticalMatch = null;
// this.opticalAction = null;
this.src = null;
this.dst = null;
this.path = null;
}
public Path path() {
return path;
public ConnectPoint src() {
return src;
}
/*
public TrafficSelector selector() {
// return opticalMatch;
public ConnectPoint dst() {
return dst;
}
public TrafficTreatment treatment() {
// return opticalAction;
public Path path() {
return path;
}
*/
@Override
public boolean isInstallable() {
return true;
......@@ -55,10 +54,8 @@ public class OpticalPathIntent extends OpticalConnectivityIntent {
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("id", id())
//.add("match", opticalMatch)
//.add("action", opticalAction)
.add("ingressPort", this.getSrcConnectPoint())
.add("egressPort", this.getDst())
.add("ingressPort", src)
.add("egressPort", dst)
.add("path", path)
.toString();
}
......
......@@ -14,16 +14,11 @@ import org.apache.felix.scr.annotations.Reference;
import org.apache.felix.scr.annotations.ReferenceCardinality;
import org.onlab.onos.CoreService;
import org.onlab.onos.net.ConnectPoint;
import org.onlab.onos.net.Link;
import org.onlab.onos.net.Path;
import org.onlab.onos.net.flow.TrafficSelector;
import org.onlab.onos.net.flow.TrafficTreatment;
import org.onlab.onos.net.intent.Intent;
import org.onlab.onos.net.intent.IntentCompiler;
import org.onlab.onos.net.intent.IntentExtensionService;
import org.onlab.onos.net.intent.OpticalConnectivityIntent;
import org.onlab.onos.net.intent.OpticalPathIntent;
import org.onlab.onos.net.provider.ProviderId;
......@@ -32,7 +27,6 @@ import org.onlab.onos.net.topology.LinkWeight;
import org.onlab.onos.net.topology.PathService;
import org.onlab.onos.net.topology.Topology;
import org.onlab.onos.net.topology.TopologyEdge;
import org.onlab.onos.net.topology.TopologyService;
import org.slf4j.Logger;
......@@ -88,15 +82,10 @@ public class OpticalConnectivityIntentCompiler implements IntentCompiler<Optical
links.addAll(path.links());
//links.add(DefaultEdgeLink.createEdgeLink(intent.getDst(), false));
TrafficSelector opticalSelector = null;
TrafficTreatment opticalTreatment = null;
// create a new opticalPathIntent
Intent newIntent = new OpticalPathIntent(intent.appId(),
path.src(),
path.dst(),
opticalSelector,
opticalTreatment,
path);
retList.add(newIntent);
......
......@@ -3,7 +3,6 @@ package org.onlab.onos.net.intent.impl;
import static org.onlab.onos.net.flow.DefaultTrafficTreatment.builder;
import static org.slf4j.LoggerFactory.getLogger;
import java.util.List;
import org.apache.felix.scr.annotations.Activate;
......@@ -20,11 +19,11 @@ import org.onlab.onos.net.flow.DefaultTrafficSelector;
import org.onlab.onos.net.flow.DefaultTrafficTreatment;
import org.onlab.onos.net.flow.FlowRule;
import org.onlab.onos.net.flow.FlowRuleBatchEntry;
import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation;
import org.onlab.onos.net.flow.FlowRuleBatchOperation;
import org.onlab.onos.net.flow.FlowRuleService;
import org.onlab.onos.net.flow.TrafficSelector;
import org.onlab.onos.net.flow.TrafficTreatment;
import org.onlab.onos.net.flow.FlowRuleBatchEntry.FlowRuleOperation;
import org.onlab.onos.net.intent.IntentExtensionService;
import org.onlab.onos.net.intent.IntentInstaller;
import org.onlab.onos.net.intent.OpticalPathIntent;
......@@ -86,12 +85,12 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn
LinkResourceAllocations allocations = assignWavelength(intent);
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchInport(intent.getSrcConnectPoint().port());
selectorBuilder.matchInport(intent.src().port());
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
ConnectPoint prev = intent.getSrcConnectPoint();
ConnectPoint prev = intent.src();
//TODO throw exception if the lambda was not assigned successfully
for (Link link : intent.path().links()) {
......@@ -127,8 +126,8 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn
// build the last T port rule
TrafficTreatment treatmentLast = builder()
.setOutput(intent.getDst().port()).build();
FlowRule rule = new DefaultFlowRule(intent.getDst().deviceId(),
.setOutput(intent.dst().port()).build();
FlowRule rule = new DefaultFlowRule(intent.dst().deviceId(),
selectorBuilder.build(),
treatmentLast,
100,
......@@ -190,12 +189,12 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn
LinkResourceAllocations allocations = resourceService.getAllocations(intent.id());
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchInport(intent.getSrcConnectPoint().port());
selectorBuilder.matchInport(intent.src().port());
TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder();
List<FlowRuleBatchEntry> rules = Lists.newLinkedList();
ConnectPoint prev = intent.getSrcConnectPoint();
ConnectPoint prev = intent.src();
//TODO throw exception if the lambda was not retrieved successfully
for (Link link : intent.path().links()) {
......@@ -231,8 +230,8 @@ public class OpticalPathIntentInstaller implements IntentInstaller<OpticalPathIn
// build the last T port rule
TrafficTreatment treatmentLast = builder()
.setOutput(intent.getDst().port()).build();
FlowRule rule = new DefaultFlowRule(intent.getDst().deviceId(),
.setOutput(intent.dst().port()).build();
FlowRule rule = new DefaultFlowRule(intent.dst().deviceId(),
selectorBuilder.build(),
treatmentLast,
100,
......