Merge branch 'optical-integration' of ssh://gerrit.onlab.us:29418/onos-next into optical-integration
diff --git a/cli/src/main/java/org/onlab/onos/cli/net/AddOpticalIntentCommand.java b/cli/src/main/java/org/onlab/onos/cli/net/AddOpticalIntentCommand.java
new file mode 100644
index 0000000..dc73c81
--- /dev/null
+++ b/cli/src/main/java/org/onlab/onos/cli/net/AddOpticalIntentCommand.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.onlab.onos.cli.net;
+
+import static org.onlab.onos.net.DeviceId.deviceId;
+import static org.onlab.onos.net.PortNumber.portNumber;
+
+import org.apache.karaf.shell.commands.Argument;
+import org.apache.karaf.shell.commands.Command;
+import org.onlab.onos.net.ConnectPoint;
+import org.onlab.onos.net.DeviceId;
+import org.onlab.onos.net.PortNumber;
+import org.onlab.onos.net.intent.Intent;
+import org.onlab.onos.net.intent.IntentService;
+import org.onlab.onos.net.intent.OpticalConnectivityIntent;
+
+/**
+ * Installs optical connectivity intents.
+ */
+@Command(scope = "onos", name = "add-optical-intent",
+ description = "Installs optical connectivity intent")
+public class AddOpticalIntentCommand extends ConnectivityIntentCommand {
+
+ @Argument(index = 0, name = "ingressDevice",
+ description = "Ingress Device/Port Description",
+ required = true, multiValued = false)
+ String ingressDeviceString = null;
+
+ @Argument(index = 1, name = "egressDevice",
+ description = "Egress Device/Port Description",
+ required = true, multiValued = false)
+ String egressDeviceString = null;
+
+ @Override
+ protected void execute() {
+ IntentService service = get(IntentService.class);
+
+ DeviceId ingressDeviceId = deviceId(getDeviceId(ingressDeviceString));
+ PortNumber ingressPortNumber = portNumber(getPortNumber(ingressDeviceString));
+ ConnectPoint ingress = new ConnectPoint(ingressDeviceId, ingressPortNumber);
+
+ DeviceId egressDeviceId = deviceId(getDeviceId(egressDeviceString));
+ PortNumber egressPortNumber = portNumber(getPortNumber(egressDeviceString));
+ ConnectPoint egress = new ConnectPoint(egressDeviceId, egressPortNumber);
+
+ Intent intent = new OpticalConnectivityIntent(appId(), ingress, egress);
+ service.submit(intent);
+ }
+
+ /**
+ * Extracts the port number portion of the ConnectPoint.
+ *
+ * @param deviceString string representing the device/port
+ * @return port number as a string, empty string if the port is not found
+ */
+ private String getPortNumber(String deviceString) {
+ int slash = deviceString.indexOf('/');
+ if (slash <= 0) {
+ return "";
+ }
+ return deviceString.substring(slash + 1, deviceString.length());
+ }
+
+ /**
+ * Extracts the device ID portion of the ConnectPoint.
+ *
+ * @param deviceString string representing the device/port
+ * @return device ID string
+ */
+ private String getDeviceId(String deviceString) {
+ int slash = deviceString.indexOf('/');
+ if (slash <= 0) {
+ return "";
+ }
+ return deviceString.substring(0, slash);
+ }
+}
diff --git a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
index b01d412..610646b 100644
--- a/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
+++ b/cli/src/main/resources/OSGI-INF/blueprint/shell-config.xml
@@ -119,6 +119,14 @@
</optional-completers>
</command>
<command>
+ <action class="org.onlab.onos.cli.net.AddOpticalIntentCommand"/>
+ <completers>
+ <ref component-id="connectPointCompleter"/>
+ <ref component-id="connectPointCompleter"/>
+ <null/>
+ </completers>
+ </command>
+ <command>
<action class="org.onlab.onos.cli.net.GetStatistics"/>
<completers>
<ref component-id="connectPointCompleter"/>
diff --git a/core/api/src/main/java/org/onlab/onos/net/intent/OpticalPathIntent.java b/core/api/src/main/java/org/onlab/onos/net/intent/OpticalPathIntent.java
index afa0004..372da91 100644
--- a/core/api/src/main/java/org/onlab/onos/net/intent/OpticalPathIntent.java
+++ b/core/api/src/main/java/org/onlab/onos/net/intent/OpticalPathIntent.java
@@ -6,46 +6,45 @@
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 ConnectPoint src() {
+ return src;
+ }
+
+ public ConnectPoint dst() {
+ return dst;
+ }
+
public Path path() {
return path;
}
-/*
- public TrafficSelector selector() {
- // return opticalMatch;
- }
- public TrafficTreatment treatment() {
- // return opticalAction;
- }
-*/
@Override
public boolean isInstallable() {
return true;
@@ -55,10 +54,8 @@
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();
}
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceService.java b/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceService.java
index e7988df..5ae5187 100644
--- a/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceService.java
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/LinkResourceService.java
@@ -36,7 +36,7 @@
* @param intentId the target Intent's id
* @return allocated resources for Intent
*/
- LinkResourceAllocations getAllocation(IntentId intentId);
+ LinkResourceAllocations getAllocations(IntentId intentId);
/**
* Returns all allocated resources to given link.
diff --git a/core/api/src/main/java/org/onlab/onos/net/resource/ResourceAllocation.java b/core/api/src/main/java/org/onlab/onos/net/resource/ResourceAllocation.java
index 3ddadbc..5cc1414 100644
--- a/core/api/src/main/java/org/onlab/onos/net/resource/ResourceAllocation.java
+++ b/core/api/src/main/java/org/onlab/onos/net/resource/ResourceAllocation.java
@@ -5,10 +5,4 @@
*/
public interface ResourceAllocation extends ResourceRequest {
- /**
- * Returns the type of the allocated resource.
- *
- * @return the type of the allocated resource
- */
- ResourceType type();
}
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java
index 9b98cec..f5272f2 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalConnectivityIntentCompiler.java
@@ -14,16 +14,11 @@
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.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 @@
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);
diff --git a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java
index f24916f..5cfee19 100644
--- a/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java
+++ b/core/net/src/main/java/org/onlab/onos/net/intent/impl/OpticalPathIntentInstaller.java
@@ -3,7 +3,6 @@
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.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 @@
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()) {
@@ -109,7 +108,7 @@
}
treatmentBuilder.setOutput(link.src().port());
- //treatmentBuilder.setLambda(la.toInt());
+ treatmentBuilder.setLambda((short) la.toInt());
FlowRule rule = new DefaultFlowRule(prev.deviceId(),
selectorBuilder.build(),
@@ -122,13 +121,13 @@
prev = link.dst();
selectorBuilder.matchInport(link.dst().port());
- //selectorBuilder.setLambda(la.toInt());
+ selectorBuilder.matchLambda((short) la.toInt());
}
// 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,
@@ -187,15 +186,15 @@
@Override
public List<FlowRuleBatchOperation> uninstall(OpticalPathIntent intent) {
- LinkResourceAllocations allocations = resourceService.getAllocation(intent.id());
+ 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()) {
@@ -213,7 +212,7 @@
}
treatmentBuilder.setOutput(link.src().port());
- //treatmentBuilder.setLambda(la.toInt());
+ treatmentBuilder.setLambda((short) la.toInt());
FlowRule rule = new DefaultFlowRule(prev.deviceId(),
selectorBuilder.build(),
@@ -226,13 +225,13 @@
prev = link.dst();
selectorBuilder.matchInport(link.dst().port());
- //selectorBuilder.setLambda(la.toInt());
+ selectorBuilder.matchLambda((short) la.toInt());
}
// 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,
diff --git a/core/net/src/main/java/org/onlab/onos/net/resource/DefaultLinkResourceAllocations.java b/core/net/src/main/java/org/onlab/onos/net/resource/impl/DefaultLinkResourceAllocations.java
similarity index 81%
rename from core/net/src/main/java/org/onlab/onos/net/resource/DefaultLinkResourceAllocations.java
rename to core/net/src/main/java/org/onlab/onos/net/resource/impl/DefaultLinkResourceAllocations.java
index 76dae01..0330821 100644
--- a/core/net/src/main/java/org/onlab/onos/net/resource/DefaultLinkResourceAllocations.java
+++ b/core/net/src/main/java/org/onlab/onos/net/resource/impl/DefaultLinkResourceAllocations.java
@@ -1,4 +1,4 @@
-package org.onlab.onos.net.resource;
+package org.onlab.onos.net.resource.impl;
import java.util.Collection;
import java.util.Collections;
@@ -7,6 +7,11 @@
import org.onlab.onos.net.Link;
import org.onlab.onos.net.intent.IntentId;
+import org.onlab.onos.net.resource.LinkResourceAllocations;
+import org.onlab.onos.net.resource.LinkResourceRequest;
+import org.onlab.onos.net.resource.ResourceAllocation;
+import org.onlab.onos.net.resource.ResourceRequest;
+import org.onlab.onos.net.resource.ResourceType;
/**
* Implementation of {@link LinkResourceAllocations}.
diff --git a/core/net/src/main/java/org/onlab/onos/net/resource/LinkResourceManager.java b/core/net/src/main/java/org/onlab/onos/net/resource/impl/LinkResourceManager.java
similarity index 81%
rename from core/net/src/main/java/org/onlab/onos/net/resource/LinkResourceManager.java
rename to core/net/src/main/java/org/onlab/onos/net/resource/impl/LinkResourceManager.java
index a207dbc..ad15f56 100644
--- a/core/net/src/main/java/org/onlab/onos/net/resource/LinkResourceManager.java
+++ b/core/net/src/main/java/org/onlab/onos/net/resource/impl/LinkResourceManager.java
@@ -1,4 +1,4 @@
-package org.onlab.onos.net.resource;
+package org.onlab.onos.net.resource.impl;
import static org.slf4j.LoggerFactory.getLogger;
@@ -12,6 +12,15 @@
import org.apache.felix.scr.annotations.Service;
import org.onlab.onos.net.Link;
import org.onlab.onos.net.intent.IntentId;
+import org.onlab.onos.net.resource.BandwidthResourceAllocation;
+import org.onlab.onos.net.resource.BandwidthResourceRequest;
+import org.onlab.onos.net.resource.Lambda;
+import org.onlab.onos.net.resource.LambdaResourceAllocation;
+import org.onlab.onos.net.resource.LinkResourceAllocations;
+import org.onlab.onos.net.resource.LinkResourceRequest;
+import org.onlab.onos.net.resource.LinkResourceService;
+import org.onlab.onos.net.resource.ResourceAllocation;
+import org.onlab.onos.net.resource.ResourceRequest;
import org.slf4j.Logger;
import com.google.common.collect.Sets;
@@ -76,7 +85,7 @@
}
@Override
- public LinkResourceAllocations getAllocation(IntentId intentId) {
+ public LinkResourceAllocations getAllocations(IntentId intentId) {
// TODO Auto-generated method stub
return null;
}
diff --git a/core/net/src/main/java/org/onlab/onos/net/resource/package-info.java b/core/net/src/main/java/org/onlab/onos/net/resource/impl/package-info.java
similarity index 66%
rename from core/net/src/main/java/org/onlab/onos/net/resource/package-info.java
rename to core/net/src/main/java/org/onlab/onos/net/resource/impl/package-info.java
index 6b402a7..a398a80 100644
--- a/core/net/src/main/java/org/onlab/onos/net/resource/package-info.java
+++ b/core/net/src/main/java/org/onlab/onos/net/resource/impl/package-info.java
@@ -1,4 +1,4 @@
/**
* Services for reserving network resources, e.g. bandwidth, lambdas.
*/
-package org.onlab.onos.net.resource;
+package org.onlab.onos.net.resource.impl;