aboutsummaryrefslogtreecommitdiffstats
path: root/framework/src/onos/apps/optical
diff options
context:
space:
mode:
authorAshlee Young <ashlee@onosfw.com>2015-09-09 22:15:21 -0700
committerAshlee Young <ashlee@onosfw.com>2015-09-09 22:15:21 -0700
commit13d05bc8458758ee39cb829098241e89616717ee (patch)
tree22a4d1ce65f15952f07a3df5af4b462b4697cb3a /framework/src/onos/apps/optical
parent6139282e1e93c2322076de4b91b1c85d0bc4a8b3 (diff)
ONOS checkin based on commit tag e796610b1f721d02f9b0e213cf6f7790c10ecd60
Change-Id: Ife8810491034fe7becdba75dda20de4267bd15cd
Diffstat (limited to 'framework/src/onos/apps/optical')
-rw-r--r--framework/src/onos/apps/optical/pom.xml69
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/OpticalLinkProvider.java157
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/OpticalPathProvisioner.java411
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalConfigProvider.java374
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalLinkDescription.java107
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalNetworkConfig.java58
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalSwitchDescription.java118
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/PktOptLink.java127
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/Roadm.java124
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/WdmLink.java138
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/package-info.java21
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/package-info.java20
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/LambdaForwarding.java187
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/MPLSForwarding.java180
-rw-r--r--framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/package-info.java20
-rw-r--r--framework/src/onos/apps/optical/src/main/resources/demo-10-roadm-6-ps.json391
-rw-r--r--framework/src/onos/apps/optical/src/main/resources/demo-3-roadm-2-ps.json100
17 files changed, 2602 insertions, 0 deletions
diff --git a/framework/src/onos/apps/optical/pom.xml b/framework/src/onos/apps/optical/pom.xml
new file mode 100644
index 00000000..ac298e0b
--- /dev/null
+++ b/framework/src/onos/apps/optical/pom.xml
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2014 Open Networking Laboratory
+ ~
+ ~ Licensed 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-apps</artifactId>
+ <version>1.3.0-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>onos-app-optical</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>Packet/Optical use-case application</description>
+
+ <properties>
+ <onos.app.name>org.onosproject.optical</onos.app.name>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-cli</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.karaf.shell</groupId>
+ <artifactId>org.apache.karaf.shell.console</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-core-serializers</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ </dependencies>
+
+</project>
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/OpticalLinkProvider.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/OpticalLinkProvider.java
new file mode 100644
index 00000000..98479bfe
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/OpticalLinkProvider.java
@@ -0,0 +1,157 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed 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.onosproject.optical;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Link;
+import org.onosproject.net.Port;
+import org.onosproject.net.device.DeviceEvent;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.link.DefaultLinkDescription;
+import org.onosproject.net.link.LinkDescription;
+import org.onosproject.net.link.LinkEvent;
+import org.onosproject.net.link.LinkListener;
+import org.onosproject.net.link.LinkProvider;
+import org.onosproject.net.link.LinkProviderRegistry;
+import org.onosproject.net.link.LinkProviderService;
+import org.onosproject.net.link.LinkService;
+import org.onosproject.net.provider.AbstractProvider;
+import org.onosproject.net.provider.ProviderId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.onosproject.net.Link.Type.OPTICAL;
+
+/**
+ * Ancillary provider to activate/deactivate optical links as their respective
+ * devices go online or offline.
+ */
+@Component(immediate = true)
+public class OpticalLinkProvider extends AbstractProvider implements LinkProvider {
+
+ private static final Logger log = LoggerFactory.getLogger(OpticalLinkProvider.class);
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected LinkProviderRegistry registry;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DeviceService deviceService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected LinkService linkService;
+
+ private LinkProviderService providerService;
+ private DeviceListener deviceListener = new InternalDeviceListener();
+ private LinkListener linkListener = new InternalLinkListener();
+
+ public OpticalLinkProvider() {
+ super(new ProviderId("optical", "org.onosproject.optical"));
+ }
+
+ @Activate
+ protected void activate() {
+ deviceService.addListener(deviceListener);
+ linkService.addListener(linkListener);
+ providerService = registry.register(this);
+ log.info("Started");
+ }
+
+ @Deactivate
+ protected void deactivate() {
+ deviceService.removeListener(deviceListener);
+ linkService.removeListener(linkListener);
+ registry.unregister(this);
+ log.info("Stopped");
+ }
+
+ //Listens to device events and processes their links.
+ private class InternalDeviceListener implements DeviceListener {
+ @Override
+ public void event(DeviceEvent event) {
+ DeviceEvent.Type type = event.type();
+ Device device = event.subject();
+ if (type == DeviceEvent.Type.DEVICE_AVAILABILITY_CHANGED ||
+ type == DeviceEvent.Type.DEVICE_ADDED ||
+ type == DeviceEvent.Type.DEVICE_UPDATED) {
+ processDeviceLinks(device);
+ } else if (type == DeviceEvent.Type.PORT_UPDATED) {
+ processPortLinks(device, event.port());
+ }
+ }
+ }
+
+ //Listens to link events and processes the link additions.
+ private class InternalLinkListener implements LinkListener {
+ @Override
+ public void event(LinkEvent event) {
+ if (event.type() == LinkEvent.Type.LINK_ADDED) {
+ Link link = event.subject();
+ if (link.providerId().scheme().equals("cfg")) {
+ processLink(event.subject());
+ }
+ }
+ }
+ }
+
+ private void processDeviceLinks(Device device) {
+ for (Link link : linkService.getDeviceLinks(device.id())) {
+ if (link.isDurable() && link.type() == OPTICAL) {
+ processLink(link);
+ }
+ }
+ }
+
+ private void processPortLinks(Device device, Port port) {
+ ConnectPoint connectPoint = new ConnectPoint(device.id(), port.number());
+ for (Link link : linkService.getLinks(connectPoint)) {
+ if (link.isDurable() && link.type() == OPTICAL) {
+ processLink(link);
+ }
+ }
+ }
+
+ private void processLink(Link link) {
+ DeviceId srcId = link.src().deviceId();
+ DeviceId dstId = link.dst().deviceId();
+ Port srcPort = deviceService.getPort(srcId, link.src().port());
+ Port dstPort = deviceService.getPort(dstId, link.dst().port());
+
+ if (srcPort == null || dstPort == null) {
+ return; //FIXME remove this in favor of below TODO
+ }
+
+ boolean active = deviceService.isAvailable(srcId) &&
+ deviceService.isAvailable(dstId) &&
+ // TODO: should update be queued if src or dstPort is null?
+ //srcPort != null && dstPort != null &&
+ srcPort.isEnabled() && dstPort.isEnabled();
+
+ LinkDescription desc = new DefaultLinkDescription(link.src(), link.dst(), OPTICAL);
+ if (active) {
+ providerService.linkDetected(desc);
+ } else {
+ providerService.linkVanished(desc);
+ }
+ }
+}
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/OpticalPathProvisioner.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/OpticalPathProvisioner.java
new file mode 100644
index 00000000..85b5de27
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/OpticalPathProvisioner.java
@@ -0,0 +1,411 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed 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.onosproject.optical;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.cluster.ClusterService;
+import org.onosproject.cluster.NodeId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.mastership.MastershipService;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.Device;
+import org.onosproject.net.Host;
+import org.onosproject.net.Link;
+import org.onosproject.net.OchPort;
+import org.onosproject.net.OduCltPort;
+import org.onosproject.net.OduSignalType;
+import org.onosproject.net.Path;
+import org.onosproject.net.Port;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.host.HostService;
+import org.onosproject.net.intent.HostToHostIntent;
+import org.onosproject.net.intent.Intent;
+import org.onosproject.net.intent.IntentEvent;
+import org.onosproject.net.intent.IntentListener;
+import org.onosproject.net.intent.IntentService;
+import org.onosproject.net.intent.IntentState;
+import org.onosproject.net.intent.OpticalCircuitIntent;
+import org.onosproject.net.intent.OpticalConnectivityIntent;
+import org.onosproject.net.intent.PointToPointIntent;
+import org.onosproject.net.resource.device.DeviceResourceService;
+import org.onosproject.net.resource.link.LinkResourceAllocations;
+import org.onosproject.net.resource.link.LinkResourceService;
+import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.PathService;
+import org.onosproject.net.topology.TopologyEdge;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * OpticalPathProvisioner listens for event notifications from the Intent F/W.
+ * It generates one or more opticalConnectivityIntent(s) and submits (or withdraws) to Intent F/W
+ * for adding/releasing capacity at the packet layer.
+ */
+
+@Component(immediate = true)
+public class OpticalPathProvisioner {
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(OpticalPathProvisioner.class);
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ private IntentService intentService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected PathService pathService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected HostService hostService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected MastershipService mastershipService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected ClusterService clusterService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DeviceService deviceService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DeviceResourceService deviceResourceService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected LinkResourceService linkResourceService;
+
+ private ApplicationId appId;
+
+ private final InternalOpticalPathProvisioner pathProvisioner = new InternalOpticalPathProvisioner();
+
+ @Activate
+ protected void activate() {
+ intentService.addListener(pathProvisioner);
+ appId = coreService.registerApplication("org.onosproject.optical");
+ initOpticalPorts();
+ log.info("Started");
+ }
+
+ @Deactivate
+ protected void deactivate() {
+ intentService.removeListener(pathProvisioner);
+ log.info("Stopped");
+ }
+
+ /**
+ * Initialize availability of optical ports.
+ */
+ private void initOpticalPorts() {
+ // TODO: check for existing optical intents
+ return;
+ }
+
+ public class InternalOpticalPathProvisioner implements IntentListener {
+ @Override
+ public void event(IntentEvent event) {
+ switch (event.type()) {
+ case INSTALL_REQ:
+ break;
+ case INSTALLED:
+ break;
+ case FAILED:
+ log.info("Intent {} failed, calling optical path provisioning app.", event.subject());
+ setupLightpath(event.subject());
+ break;
+ case WITHDRAWN:
+ log.info("Intent {} withdrawn.", event.subject());
+ releaseResources(event.subject());
+ break;
+ default:
+ break;
+ }
+ }
+
+ private void setupLightpath(Intent intent) {
+ checkNotNull(intent);
+
+ // TODO change the coordination approach between packet intents and optical intents
+ // Low speed LLDP may cause multiple calls which are not expected
+
+ if (intentService.getIntentState(intent.key()) != IntentState.FAILED) {
+ return;
+ }
+
+ // Get source and destination based on intent type
+ ConnectPoint src;
+ ConnectPoint dst;
+ if (intent instanceof HostToHostIntent) {
+ HostToHostIntent hostToHostIntent = (HostToHostIntent) intent;
+
+ Host one = hostService.getHost(hostToHostIntent.one());
+ Host two = hostService.getHost(hostToHostIntent.two());
+
+ checkNotNull(one);
+ checkNotNull(two);
+
+ src = one.location();
+ dst = two.location();
+ } else if (intent instanceof PointToPointIntent) {
+ PointToPointIntent p2pIntent = (PointToPointIntent) intent;
+
+ src = p2pIntent.ingressPoint();
+ dst = p2pIntent.egressPoint();
+ } else {
+ return;
+ }
+
+ if (src == null || dst == null) {
+ return;
+ }
+
+ // Ignore if we're not the master for the intent's origin device
+ NodeId localNode = clusterService.getLocalNode().id();
+ NodeId sourceMaster = mastershipService.getMasterFor(src.deviceId());
+ if (!localNode.equals(sourceMaster)) {
+ return;
+ }
+
+ // Generate optical connectivity intents
+ List<Intent> intents = getOpticalIntents(src, dst);
+
+ // Submit the intents
+ for (Intent i : intents) {
+ intentService.submit(i);
+ log.debug("Submitted an intent: {}", i);
+ }
+ }
+
+ /**
+ * Returns list of cross connection points of missing optical path sections.
+ *
+ * Scans the given multi-layer path and looks for sections that use cross connect links.
+ * The ingress and egress points in the optical layer are returned in a list.
+ *
+ * @param path the multi-layer path
+ * @return list of cross connection points on the optical layer
+ */
+ private List<ConnectPoint> getCrossConnectPoints(Path path) {
+ boolean scanning = false;
+ List<ConnectPoint> connectPoints = new LinkedList<>();
+
+ for (Link link : path.links()) {
+ if (!isCrossConnectLink(link)) {
+ continue;
+ }
+
+ if (scanning) {
+ connectPoints.add(checkNotNull(link.src()));
+ scanning = false;
+ } else {
+ connectPoints.add(checkNotNull(link.dst()));
+ scanning = true;
+ }
+ }
+
+ return connectPoints;
+ }
+
+ /**
+ * Checks if cross connect points are of same type.
+ *
+ * @param crossConnectPoints list of cross connection points
+ * @return true if cross connect point pairs are of same type, false otherwise
+ */
+ private boolean checkCrossConnectPoints(List<ConnectPoint> crossConnectPoints) {
+ checkArgument(crossConnectPoints.size() % 2 == 0);
+
+ Iterator<ConnectPoint> itr = crossConnectPoints.iterator();
+
+ while (itr.hasNext()) {
+ // checkArgument at start ensures we'll always have pairs of connect points
+ ConnectPoint src = itr.next();
+ ConnectPoint dst = itr.next();
+
+ Device.Type srcType = deviceService.getDevice(src.deviceId()).type();
+ Device.Type dstType = deviceService.getDevice(dst.deviceId()).type();
+
+ // Only support connections between identical port types
+ if (srcType != dstType) {
+ log.warn("Unsupported mix of cross connect points");
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ /**
+ * Scans the list of cross connection points and returns a list of optical connectivity intents.
+ *
+ * @param crossConnectPoints list of cross connection points
+ * @return list of optical connectivity intents
+ */
+ private List<Intent> getIntents(List<ConnectPoint> crossConnectPoints) {
+ checkArgument(crossConnectPoints.size() % 2 == 0);
+
+ List<Intent> intents = new LinkedList<>();
+ Iterator<ConnectPoint> itr = crossConnectPoints.iterator();
+
+ while (itr.hasNext()) {
+ // checkArgument at start ensures we'll always have pairs of connect points
+ ConnectPoint src = itr.next();
+ ConnectPoint dst = itr.next();
+
+ Port srcPort = deviceService.getPort(src.deviceId(), src.port());
+ Port dstPort = deviceService.getPort(dst.deviceId(), dst.port());
+
+ if (srcPort instanceof OduCltPort && dstPort instanceof OduCltPort) {
+ // Create OTN circuit
+ Intent circuitIntent = OpticalCircuitIntent.builder()
+ .appId(appId)
+ .src(src)
+ .dst(dst)
+ .signalType(OduCltPort.SignalType.CLT_10GBE)
+ .bidirectional(true)
+ .build();
+ intents.add(circuitIntent);
+ continue;
+ } else if (srcPort instanceof OchPort && dstPort instanceof OchPort) {
+ // Create lightpath
+ // FIXME: hardcoded ODU signal type
+ Intent opticalIntent = OpticalConnectivityIntent.builder()
+ .appId(appId)
+ .src(src)
+ .dst(dst)
+ .signalType(OduSignalType.ODU4)
+ .bidirectional(true)
+ .build();
+ intents.add(opticalIntent);
+ continue;
+ } else {
+ log.warn("Unsupported cross connect point types {} {}", srcPort.type(), dstPort.type());
+ return Collections.emptyList();
+ }
+ }
+
+ return intents;
+ }
+
+ /**
+ * Returns list of optical connectivity intents needed to create connectivity
+ * between ingress and egress.
+ *
+ * @param ingress the ingress connect point
+ * @param egress the egress connect point
+ * @return list of optical connectivity intents, empty list if no path was found
+ */
+ private List<Intent> getOpticalIntents(ConnectPoint ingress, ConnectPoint egress) {
+ Set<Path> paths = pathService.getPaths(ingress.deviceId(),
+ egress.deviceId(),
+ new OpticalLinkWeight());
+
+ if (paths.isEmpty()) {
+ return Collections.emptyList();
+ }
+
+ // Search path with available cross connect points
+ for (Path path : paths) {
+ List<ConnectPoint> crossConnectPoints = getCrossConnectPoints(path);
+
+ // Skip to next path if cross connect points are mismatched
+ if (!checkCrossConnectPoints(crossConnectPoints)) {
+ continue;
+ }
+
+ return getIntents(crossConnectPoints);
+ }
+
+ return Collections.emptyList();
+ }
+
+ /**
+ * Link weight function that emphasizes re-use of packet links.
+ */
+ private class OpticalLinkWeight implements LinkWeight {
+ @Override
+ public double weight(TopologyEdge edge) {
+ // Ignore inactive links
+ if (edge.link().state() == Link.State.INACTIVE) {
+ return -1;
+ }
+
+ // TODO: Ignore cross connect links with used ports
+
+ // Transport links have highest weight
+ if (edge.link().type() == Link.Type.OPTICAL) {
+ return 1000;
+ }
+
+ // Packet links
+ return 1;
+ }
+ }
+
+ /**
+ * Release resources associated to the given intent.
+ *
+ * @param intent the intent
+ */
+ private void releaseResources(Intent intent) {
+ LinkResourceAllocations lra = linkResourceService.getAllocations(intent.id());
+ if (intent instanceof OpticalConnectivityIntent) {
+ deviceResourceService.releasePorts(intent.id());
+ if (lra != null) {
+ linkResourceService.releaseResources(lra);
+ }
+ } else if (intent instanceof OpticalCircuitIntent) {
+ deviceResourceService.releasePorts(intent.id());
+ deviceResourceService.releaseMapping(intent.id());
+ if (lra != null) {
+ linkResourceService.releaseResources(lra);
+ }
+ }
+ }
+ }
+
+ /**
+ * Verifies if given link is cross-connect between packet and optical layer.
+ *
+ * @param link the link
+ * @return true if the link is a cross-connect link
+ */
+ public static boolean isCrossConnectLink(Link link) {
+ if (link.type() != Link.Type.OPTICAL) {
+ return false;
+ }
+
+ checkNotNull(link.annotations());
+ checkNotNull(link.annotations().value("optical.type"));
+
+ return link.annotations().value("optical.type").equals("cross-connect");
+ }
+
+}
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalConfigProvider.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalConfigProvider.java
new file mode 100644
index 00000000..dbe0b543
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalConfigProvider.java
@@ -0,0 +1,374 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed 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.onosproject.optical.cfg;
+
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.JsonParseException;
+import org.codehaus.jackson.annotate.JsonIgnoreProperties;
+import org.codehaus.jackson.map.JsonMappingException;
+import org.codehaus.jackson.map.ObjectMapper;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Link;
+import org.onosproject.net.MastershipRole;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.device.DefaultDeviceDescription;
+import org.onosproject.net.device.DeviceDescription;
+import org.onosproject.net.device.DeviceProvider;
+import org.onosproject.net.device.DeviceProviderRegistry;
+import org.onosproject.net.device.DeviceProviderService;
+import org.onosproject.net.link.DefaultLinkDescription;
+import org.onosproject.net.link.LinkProvider;
+import org.onosproject.net.link.LinkProviderRegistry;
+import org.onosproject.net.link.LinkProviderService;
+import org.onosproject.net.provider.AbstractProvider;
+import org.onosproject.net.provider.ProviderId;
+import org.onlab.packet.ChassisId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import static org.onosproject.net.DeviceId.deviceId;
+
+/**
+ * OpticalConfigProvider emulates the SB network provider for optical switches,
+ * optical links and any other state that needs to be configured for correct network
+ * operations.
+ *
+ * @deprecated in Cardinal Release
+ */
+@Deprecated
+@JsonIgnoreProperties(ignoreUnknown = true)
+//@Component(immediate = true)
+public class OpticalConfigProvider extends AbstractProvider implements DeviceProvider, LinkProvider {
+
+ protected static final Logger log = LoggerFactory
+ .getLogger(OpticalConfigProvider.class);
+
+ // TODO: fix hard coded file path later.
+ private static final String DEFAULT_CONFIG_FILE =
+ "config/demo-3-roadm-2-ps.json";
+ private String configFileName = DEFAULT_CONFIG_FILE;
+
+// @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected LinkProviderRegistry linkProviderRegistry;
+
+// @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DeviceProviderRegistry deviceProviderRegistry;
+
+ private static final String OPTICAL_ANNOTATION = "optical.";
+
+ private LinkProviderService linkProviderService;
+ private DeviceProviderService deviceProviderService;
+
+ private static final List<Roadm> RAW_ROADMS = new ArrayList<>();
+ private static final List<WdmLink> RAW_WDMLINKS = new ArrayList<>();
+ private static final List<PktOptLink> RAW_PKTOPTLINKS = new ArrayList<>();
+
+ private static final String ROADM = "Roadm";
+ private static final String WDM_LINK = "wdmLink";
+ private static final String PKT_OPT_LINK = "pktOptLink";
+
+ protected OpticalNetworkConfig opticalNetworkConfig;
+
+ public OpticalConfigProvider() {
+ super(new ProviderId("optical", "org.onosproject.provider" +
+ ".opticalConfig"));
+ }
+
+// @Activate
+ protected void activate() {
+ linkProviderService = linkProviderRegistry.register(this);
+ deviceProviderService = deviceProviderRegistry.register(this);
+ log.info("Starting optical network configuration process...");
+ log.info("Optical config file set to {}", configFileName);
+
+ loadOpticalConfig();
+ parseOpticalConfig();
+ publishOpticalConfig();
+ }
+
+// @Deactivate
+ protected void deactivate() {
+ linkProviderRegistry.unregister(this);
+ linkProviderService = null;
+ deviceProviderRegistry.unregister(this);
+ deviceProviderService = null;
+ RAW_ROADMS.clear();
+ RAW_WDMLINKS.clear();
+ RAW_PKTOPTLINKS.clear();
+ log.info("Stopped");
+ }
+
+ private void loadOpticalConfig() {
+ ObjectMapper mapper = new ObjectMapper();
+ opticalNetworkConfig = new OpticalNetworkConfig();
+ try {
+ opticalNetworkConfig = mapper.readValue(new File(configFileName), OpticalNetworkConfig.class);
+ } catch (JsonParseException e) {
+ String err = String.format("JsonParseException while loading network "
+ + "config from file: %s: %s", configFileName, e.getMessage());
+ log.error(err, e);
+ } catch (JsonMappingException e) {
+ String err = String.format(
+ "JsonMappingException while loading network config "
+ + "from file: %s: %s", configFileName, e.getMessage());
+ log.error(err, e);
+ } catch (IOException e) {
+ String err = String.format("IOException while loading network config "
+ + "from file: %s %s", configFileName, e.getMessage());
+ log.error(err, e);
+ }
+ }
+
+ private void parseOpticalConfig() {
+ List<OpticalSwitchDescription> swList = opticalNetworkConfig.getOpticalSwitches();
+ List<OpticalLinkDescription> lkList = opticalNetworkConfig.getOpticalLinks();
+
+ for (OpticalSwitchDescription sw : swList) {
+ String swtype = sw.getType();
+ boolean allow = sw.isAllowed();
+ if (swtype.equals(ROADM) && allow) {
+ int regNum = 0;
+ Set<Map.Entry<String, JsonNode>> m = sw.params.entrySet();
+ for (Map.Entry<String, JsonNode> e : m) {
+ String key = e.getKey();
+ JsonNode j = e.getValue();
+ if (key.equals("numRegen")) {
+ regNum = j.asInt();
+ }
+ }
+
+ Roadm newRoadm = new Roadm();
+ newRoadm.setName(sw.name);
+ newRoadm.setNodeId(sw.nodeDpid);
+ newRoadm.setLongtitude(sw.longitude);
+ newRoadm.setLatitude(sw.latitude);
+ newRoadm.setRegenNum(regNum);
+
+ RAW_ROADMS.add(newRoadm);
+ log.info(newRoadm.toString());
+ }
+ }
+
+ for (OpticalLinkDescription lk : lkList) {
+ String lktype = lk.getType();
+ switch (lktype) {
+ case WDM_LINK:
+ WdmLink newWdmLink = new WdmLink();
+ newWdmLink.setSrcNodeId(lk.getNodeDpid1());
+ newWdmLink.setSnkNodeId(lk.getNodeDpid2());
+ newWdmLink.setAdminWeight(1000); // default weight for each WDM link.
+ Set<Map.Entry<String, JsonNode>> m = lk.params.entrySet();
+ for (Map.Entry<String, JsonNode> e : m) {
+ String key = e.getKey();
+ JsonNode j = e.getValue();
+ if (key.equals("nodeName1")) {
+ newWdmLink.setSrcNodeName(j.asText());
+ } else if (key.equals("nodeName2")) {
+ newWdmLink.setSnkNodeName(j.asText());
+ } else if (key.equals("port1")) {
+ newWdmLink.setSrcPort(j.asInt());
+ } else if (key.equals("port2")) {
+ newWdmLink.setSnkPort(j.asInt());
+ } else if (key.equals("distKms")) {
+ newWdmLink.setDistance(j.asDouble());
+ } else if (key.equals("numWaves")) {
+ newWdmLink.setWavelengthNumber(j.asInt());
+ } else {
+ log.error("error found");
+ // TODO add exception processing;
+ }
+ }
+ RAW_WDMLINKS.add(newWdmLink);
+ log.info(newWdmLink.toString());
+
+ break;
+
+ case PKT_OPT_LINK:
+ PktOptLink newPktOptLink = new PktOptLink();
+ newPktOptLink.setSrcNodeId(lk.getNodeDpid1());
+ newPktOptLink.setSnkNodeId(lk.getNodeDpid2());
+ newPktOptLink.setAdminWeight(10); // default weight for each packet-optical link.
+ Set<Map.Entry<String, JsonNode>> ptm = lk.params.entrySet();
+ for (Map.Entry<String, JsonNode> e : ptm) {
+ String key = e.getKey();
+ JsonNode j = e.getValue();
+ if (key.equals("nodeName1")) {
+ newPktOptLink.setSrcNodeName(j.asText());
+ } else if (key.equals("nodeName2")) {
+ newPktOptLink.setSnkNodeName(j.asText());
+ } else if (key.equals("port1")) {
+ newPktOptLink.setSrcPort(j.asInt());
+ } else if (key.equals("port2")) {
+ newPktOptLink.setSnkPort(j.asInt());
+ } else if (key.equals("bandWidth")) {
+ newPktOptLink.setBandwdith(j.asDouble());
+ } else {
+ log.error("error found");
+ // TODO add exception processing;
+ }
+ }
+
+ RAW_PKTOPTLINKS.add(newPktOptLink);
+ log.info(newPktOptLink.toString());
+ break;
+ default:
+ }
+ }
+ }
+
+ private void publishOpticalConfig() {
+ if (deviceProviderService == null || linkProviderService == null) {
+ return;
+ }
+
+ // Discover the optical ROADM objects
+ Iterator<Roadm> iterWdmNode = RAW_ROADMS.iterator();
+ while (iterWdmNode.hasNext()) {
+ Roadm value = iterWdmNode.next();
+ DeviceId did = deviceId("of:" + value.getNodeId().replace(":", ""));
+ ChassisId cid = new ChassisId();
+ DefaultAnnotations extendedAttributes = DefaultAnnotations.builder()
+ .set(OPTICAL_ANNOTATION + "switchType", "ROADM")
+ .set(OPTICAL_ANNOTATION + "switchName", value.getName())
+ .set(OPTICAL_ANNOTATION + "latitude", Double.toString(value.getLatitude()))
+ .set(OPTICAL_ANNOTATION + "longtitude", Double.toString(value.getLongtitude()))
+ .set(OPTICAL_ANNOTATION + "regNum", Integer.toString(value.getRegenNum()))
+ .build();
+
+ DeviceDescription description =
+ new DefaultDeviceDescription(did.uri(),
+ Device.Type.SWITCH,
+ "",
+ "",
+ "",
+ "",
+ cid,
+ extendedAttributes);
+ deviceProviderService.deviceConnected(did, description);
+ }
+
+ // Discover the optical WDM link objects
+ Iterator<WdmLink> iterWdmlink = RAW_WDMLINKS.iterator();
+ while (iterWdmlink.hasNext()) {
+ WdmLink value = iterWdmlink.next();
+
+ DeviceId srcNodeId = deviceId("of:" + value.getSrcNodeId().replace(":", ""));
+ DeviceId snkNodeId = deviceId("of:" + value.getSnkNodeId().replace(":", ""));
+
+ PortNumber srcPort = PortNumber.portNumber(value.getSrcPort());
+ PortNumber snkPort = PortNumber.portNumber(value.getSnkPort());
+
+ ConnectPoint srcPoint = new ConnectPoint(srcNodeId, srcPort);
+ ConnectPoint snkPoint = new ConnectPoint(snkNodeId, snkPort);
+
+ DefaultAnnotations extendedAttributes = DefaultAnnotations.builder()
+ .set(OPTICAL_ANNOTATION + "linkType", "WDM")
+ .set(OPTICAL_ANNOTATION + "distance", Double.toString(value.getDistance()))
+ .set(OPTICAL_ANNOTATION + "cost", Double.toString(value.getDistance()))
+ .set(OPTICAL_ANNOTATION + "adminWeight", Double.toString(value.getAdminWeight()))
+ .set(OPTICAL_ANNOTATION + "wavelengthNum", Integer.toString(value.getWavelengthNumber()))
+ .build();
+
+ DefaultLinkDescription linkDescription =
+ new DefaultLinkDescription(srcPoint,
+ snkPoint,
+ Link.Type.OPTICAL,
+ extendedAttributes);
+
+ linkProviderService.linkDetected(linkDescription);
+ log.info(String.format("WDM link: %s : %s",
+ linkDescription.src().toString(), linkDescription.dst().toString()));
+
+
+ DefaultLinkDescription linkDescriptionReverse =
+ new DefaultLinkDescription(snkPoint,
+ srcPoint,
+ Link.Type.OPTICAL,
+ extendedAttributes);
+
+ linkProviderService.linkDetected(linkDescriptionReverse);
+ log.info(String.format("WDM link: %s : %s",
+ linkDescriptionReverse.src().toString(), linkDescriptionReverse.dst().toString()));
+ }
+
+ // Discover the packet optical link objects
+ Iterator<PktOptLink> iterPktOptlink = RAW_PKTOPTLINKS.iterator();
+ while (iterPktOptlink.hasNext()) {
+ PktOptLink value = iterPktOptlink.next();
+ DeviceId srcNodeId = deviceId("of:" + value.getSrcNodeId().replace(":", ""));
+ DeviceId snkNodeId = deviceId("of:" + value.getSnkNodeId().replace(":", ""));
+
+ PortNumber srcPort = PortNumber.portNumber(value.getSrcPort());
+ PortNumber snkPort = PortNumber.portNumber(value.getSnkPort());
+
+ ConnectPoint srcPoint = new ConnectPoint(srcNodeId, srcPort);
+ ConnectPoint snkPoint = new ConnectPoint(snkNodeId, snkPort);
+
+ DefaultAnnotations extendedAttributes = DefaultAnnotations.builder()
+ .set(OPTICAL_ANNOTATION + "linkType", "PktOptLink")
+ .set(OPTICAL_ANNOTATION + "bandwidth", Double.toString(value.getBandwidth()))
+ .set(OPTICAL_ANNOTATION + "cost", Double.toString(value.getBandwidth()))
+ .set(OPTICAL_ANNOTATION + "adminWeight", Double.toString(value.getAdminWeight()))
+ .build();
+
+ DefaultLinkDescription linkDescription =
+ new DefaultLinkDescription(srcPoint,
+ snkPoint,
+ Link.Type.OPTICAL,
+ extendedAttributes);
+
+ linkProviderService.linkDetected(linkDescription);
+ log.info(String.format("Packet-optical link: %s : %s",
+ linkDescription.src().toString(), linkDescription.dst().toString()));
+
+ DefaultLinkDescription linkDescriptionReverse =
+ new DefaultLinkDescription(snkPoint,
+ srcPoint,
+ Link.Type.OPTICAL,
+ extendedAttributes);
+
+ linkProviderService.linkDetected(linkDescriptionReverse);
+ log.info(String.format("Packet-optical link: %s : %s",
+ linkDescriptionReverse.src().toString(), linkDescriptionReverse.dst().toString()));
+ }
+
+ }
+
+ @Override
+ public void triggerProbe(DeviceId deviceId) {
+ // TODO We may want to consider re-reading config files and publishing them based on this event.
+ }
+
+ @Override
+ public void roleChanged(DeviceId device, MastershipRole newRole) {
+ }
+
+ @Override
+ public boolean isReachable(DeviceId device) {
+ return false;
+ }
+}
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalLinkDescription.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalLinkDescription.java
new file mode 100644
index 00000000..1673335a
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalLinkDescription.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed 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.onosproject.optical.cfg;
+
+import java.util.Map;
+import org.codehaus.jackson.JsonNode;
+import org.onlab.util.HexString;
+
+/**
+ * Public class corresponding to JSON described data model.
+ *
+ * @deprecated in Cardinal Release
+ */
+@Deprecated
+public class OpticalLinkDescription {
+ protected String type;
+ protected Boolean allowed;
+ protected long dpid1;
+ protected long dpid2;
+ protected String nodeDpid1;
+ protected String nodeDpid2;
+ protected Map<String, JsonNode> params;
+ protected Map<String, String> publishAttributes;
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public Boolean isAllowed() {
+ return allowed;
+ }
+
+ public void setAllowed(Boolean allowed) {
+ this.allowed = allowed;
+ }
+
+ public String getNodeDpid1() {
+ return nodeDpid1;
+ }
+
+ public void setNodeDpid1(String nodeDpid1) {
+ this.nodeDpid1 = nodeDpid1;
+ this.dpid1 = HexString.toLong(nodeDpid1);
+ }
+
+ public String getNodeDpid2() {
+ return nodeDpid2;
+ }
+
+ public void setNodeDpid2(String nodeDpid2) {
+ this.nodeDpid2 = nodeDpid2;
+ this.dpid2 = HexString.toLong(nodeDpid2);
+ }
+
+ public long getDpid1() {
+ return dpid1;
+ }
+
+ public void setDpid1(long dpid1) {
+ this.dpid1 = dpid1;
+ this.nodeDpid1 = HexString.toHexString(dpid1);
+ }
+
+ public long getDpid2() {
+ return dpid2;
+ }
+
+ public void setDpid2(long dpid2) {
+ this.dpid2 = dpid2;
+ this.nodeDpid2 = HexString.toHexString(dpid2);
+ }
+
+ public Map<String, JsonNode> getParams() {
+ return params;
+ }
+
+ public void setParams(Map<String, JsonNode> params) {
+ this.params = params;
+ }
+
+ public Map<String, String> getPublishAttributes() {
+ return publishAttributes;
+ }
+
+ public void setPublishAttributes(Map<String, String> publishAttributes) {
+ this.publishAttributes = publishAttributes;
+ }
+
+}
+
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalNetworkConfig.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalNetworkConfig.java
new file mode 100644
index 00000000..f3f8d174
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalNetworkConfig.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed 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.onosproject.optical.cfg;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Public class corresponding to JSON described data model.
+ *
+ * @deprecated in Cardinal Release
+ */
+@Deprecated
+public class OpticalNetworkConfig {
+ protected static final Logger log = LoggerFactory.getLogger(OpticalNetworkConfig.class);
+
+ private List<OpticalSwitchDescription> opticalSwitches;
+ private List<OpticalLinkDescription> opticalLinks;
+
+ public OpticalNetworkConfig() {
+ opticalSwitches = new ArrayList<OpticalSwitchDescription>();
+ opticalLinks = new ArrayList<OpticalLinkDescription>();
+ }
+
+ public List<OpticalSwitchDescription> getOpticalSwitches() {
+ return opticalSwitches;
+ }
+
+ public void setOpticalSwitches(List<OpticalSwitchDescription> switches) {
+ this.opticalSwitches = switches;
+ }
+
+ public List<OpticalLinkDescription> getOpticalLinks() {
+ return opticalLinks;
+ }
+
+ public void setOpticalLinks(List<OpticalLinkDescription> links) {
+ this.opticalLinks = links;
+ }
+
+}
+
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalSwitchDescription.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalSwitchDescription.java
new file mode 100644
index 00000000..346088fc
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/OpticalSwitchDescription.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed 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.onosproject.optical.cfg;
+
+import java.util.Map;
+import org.codehaus.jackson.JsonNode;
+import org.codehaus.jackson.annotate.JsonProperty;
+import org.onlab.util.HexString;
+
+/**
+ * Public class corresponding to JSON described data model.
+ *
+ * @deprecated in Cardinal Release
+ */
+@Deprecated
+public class OpticalSwitchDescription {
+ protected String name;
+ protected long dpid;
+ protected String nodeDpid;
+ protected String type;
+ protected double latitude;
+ protected double longitude;
+ protected boolean allowed;
+ protected Map<String, JsonNode> params;
+ protected Map<String, String> publishAttributes;
+
+ public String getName() {
+ return name;
+ }
+ @JsonProperty("name")
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public long getDpid() {
+ return dpid;
+ }
+ @JsonProperty("dpid")
+ public void setDpid(long dpid) {
+ this.dpid = dpid;
+ this.nodeDpid = HexString.toHexString(dpid);
+ }
+
+ public String getNodeDpid() {
+ return nodeDpid;
+ }
+
+ public String getHexDpid() {
+ return nodeDpid;
+ }
+
+ public void setNodeDpid(String nodeDpid) {
+ this.nodeDpid = nodeDpid;
+ this.dpid = HexString.toLong(nodeDpid);
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public double getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(double latitude) {
+ this.latitude = latitude;
+ }
+
+ public double getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(double longitude) {
+ this.longitude = longitude;
+ }
+
+ public boolean isAllowed() {
+ return allowed;
+ }
+
+ public void setAllowed(boolean allowed) {
+ this.allowed = allowed;
+ }
+
+ public Map<String, JsonNode> getParams() {
+ return params;
+ }
+
+ public void setParams(Map<String, JsonNode> params) {
+ this.params = params;
+ }
+
+ public Map<String, String> getPublishAttributes() {
+ return publishAttributes;
+ }
+
+ public void setPublishAttributes(Map<String, String> publishAttributes) {
+ this.publishAttributes = publishAttributes;
+ }
+
+}
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/PktOptLink.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/PktOptLink.java
new file mode 100644
index 00000000..0621cb06
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/PktOptLink.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed 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.onosproject.optical.cfg;
+
+/**
+ * Packet-optical link Java data object.
+ *
+ * @deprecated in Cardinal Release
+ */
+@Deprecated
+class PktOptLink {
+ private String srcNodeName;
+ private String snkNodeName;
+ private String srcNodeId;
+ private String snkNodeId;
+ private int srcPort;
+ private int snkPort;
+ private double bandwidth;
+ private double cost;
+ private long adminWeight;
+
+ public PktOptLink(String srcName, String snkName) {
+ this.srcNodeName = srcName;
+ this.snkNodeName = snkName;
+ }
+
+ public PktOptLink() {
+ }
+
+ public void setSrcNodeName(String name) {
+ this.srcNodeName = name;
+ }
+
+ public String getSrcNodeName() {
+ return this.srcNodeName;
+ }
+
+ public void setSnkNodeName(String name) {
+ this.snkNodeName = name;
+ }
+
+ public String getSnkNodeName() {
+ return this.snkNodeName;
+ }
+
+ public void setSrcNodeId(String nodeId) {
+ this.srcNodeId = nodeId;
+ }
+
+ public String getSrcNodeId() {
+ return this.srcNodeId;
+ }
+
+ public void setSnkNodeId(String nodeId) {
+ this.snkNodeId = nodeId;
+ }
+
+ public String getSnkNodeId() {
+ return this.snkNodeId;
+ }
+
+ public void setSrcPort(int port) {
+ this.srcPort = port;
+ }
+
+ public int getSrcPort() {
+ return this.srcPort;
+ }
+
+ public void setSnkPort(int port) {
+ this.snkPort = port;
+ }
+
+ public int getSnkPort() {
+ return this.snkPort;
+ }
+
+ public void setBandwdith(double x) {
+ this.bandwidth = x;
+ }
+
+ public double getBandwidth() {
+ return this.bandwidth;
+ }
+
+ public void setCost(double x) {
+ this.cost = x;
+ }
+
+ public double getCost() {
+ return this.cost;
+ }
+
+ public void setAdminWeight(long x) {
+ this.adminWeight = x;
+ }
+
+ public long getAdminWeight() {
+ return this.adminWeight;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder(" srcNodeName: ").append(this.srcNodeName)
+ .append(" snkNodeName: ").append(this.snkNodeName)
+ .append(" srcNodeId: ").append(this.srcNodeId)
+ .append(" snkNodeId: ").append(this.snkNodeId)
+ .append(" srcPort: ").append(this.srcPort)
+ .append(" snkPort: ").append(this.snkPort)
+ .append(" bandwidth: ").append(this.bandwidth)
+ .append(" cost: ").append(this.cost)
+ .append(" adminWeight: ").append(this.adminWeight).toString();
+ }
+}
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/Roadm.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/Roadm.java
new file mode 100644
index 00000000..677555ea
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/Roadm.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed 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.onosproject.optical.cfg;
+
+/**
+ * ROADM java data object converted from a JSON file.
+ *
+ * @deprecated in Cardinal Release
+ */
+@Deprecated
+class Roadm {
+ private String name;
+ private String nodeID;
+ private double longtitude;
+ private double latitude;
+ private int regenNum;
+
+ //TODO use the following attributes when needed for configurations
+ private int tPort10G;
+ private int tPort40G;
+ private int tPort100G;
+ private int wPort;
+
+ public Roadm() {
+ }
+
+ public Roadm(String name) {
+ this.name = name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public String getName() {
+ return this.name;
+ }
+
+ public void setNodeId(String nameId) {
+ this.nodeID = nameId;
+ }
+
+ public String getNodeId() {
+ return this.nodeID;
+ }
+
+ public void setLongtitude(double x) {
+ this.longtitude = x;
+ }
+
+ public double getLongtitude() {
+ return this.longtitude;
+ }
+
+ public void setLatitude(double y) {
+ this.latitude = y;
+ }
+
+ public double getLatitude() {
+ return this.latitude;
+ }
+
+ public void setRegenNum(int num) {
+ this.regenNum = num;
+ }
+ public int getRegenNum() {
+ return this.regenNum;
+ }
+
+ public void setTport10GNum(int num) {
+ this.tPort10G = num;
+ }
+ public int getTport10GNum() {
+ return this.tPort10G;
+ }
+
+ public void setTport40GNum(int num) {
+ this.tPort40G = num;
+ }
+ public int getTport40GNum() {
+ return this.tPort40G;
+ }
+
+ public void setTport100GNum(int num) {
+ this.tPort100G = num;
+ }
+ public int getTport100GNum() {
+ return this.tPort100G;
+ }
+
+ public void setWportNum(int num) {
+ this.wPort = num;
+ }
+ public int getWportNum() {
+ return this.wPort;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder(" ROADM Name: ").append(this.name)
+ .append(" nodeID: ").append(this.nodeID)
+ .append(" longtitude: ").append(this.longtitude)
+ .append(" latitude: ").append(this.latitude)
+ .append(" regenNum: ").append(this.regenNum)
+ .append(" 10GTportNum: ").append(this.tPort10G)
+ .append(" 40GTportNum: ").append(this.tPort40G)
+ .append(" 100GTportNum: ").append(this.tPort100G)
+ .append(" WportNum: ").append(this.wPort).toString();
+ }
+}
+
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/WdmLink.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/WdmLink.java
new file mode 100644
index 00000000..63cd775c
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/WdmLink.java
@@ -0,0 +1,138 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed 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.onosproject.optical.cfg;
+
+/**
+ * WDM Link Java data object converted from a JSON file.
+ *
+ * @deprecated in Cardinal Release
+ */
+@Deprecated
+class WdmLink {
+ private String srcNodeName;
+ private String snkNodeName;
+ private String srcNodeId;
+ private String snkNodeId;
+ private int srcPort;
+ private int snkPort;
+ private double distance;
+ private double cost;
+ private int wavelengthNumber;
+ private long adminWeight;
+
+ public WdmLink(String name1, String name2) {
+ this.srcNodeName = name1;
+ this.snkNodeName = name2;
+ }
+
+ public WdmLink() {
+ }
+
+ public void setSrcNodeName(String name) {
+ this.srcNodeName = name;
+ }
+
+ public String getSrcNodeName() {
+ return this.srcNodeName;
+ }
+
+ public void setSnkNodeName(String name) {
+ this.snkNodeName = name;
+ }
+
+ public String getSnkNodeName() {
+ return this.snkNodeName;
+ }
+
+ public void setSrcNodeId(String nodeId) {
+ this.srcNodeId = nodeId;
+ }
+
+ public String getSrcNodeId() {
+ return this.srcNodeId;
+ }
+
+ public void setSnkNodeId(String nodeId) {
+ this.snkNodeId = nodeId;
+ }
+
+ public String getSnkNodeId() {
+ return this.snkNodeId;
+ }
+
+ public void setSrcPort(int port) {
+ this.srcPort = port;
+ }
+
+ public int getSrcPort() {
+ return this.srcPort;
+ }
+
+ public void setSnkPort(int port) {
+ this.snkPort = port;
+ }
+
+ public int getSnkPort() {
+ return this.snkPort;
+ }
+
+ public void setDistance(double x) {
+ this.distance = x;
+ }
+
+ public double getDistance() {
+ return this.distance;
+ }
+
+ public void setCost(double x) {
+ this.cost = x;
+ }
+
+ public double getCost() {
+ return this.cost;
+ }
+
+ public void setWavelengthNumber(int x) {
+ this.wavelengthNumber = x;
+ }
+
+ public int getWavelengthNumber() {
+ return this.wavelengthNumber;
+ }
+
+ public void setAdminWeight(long x) {
+ this.adminWeight = x;
+ }
+
+ public long getAdminWeight() {
+ return this.adminWeight;
+ }
+
+ @Override
+ public String toString() {
+ return new StringBuilder(" srcNodeName: ").append(this.srcNodeName)
+ .append(" snkNodeName: ").append(this.snkNodeName)
+ .append(" srcNodeId: ").append(this.srcNodeId)
+ .append(" snkNodeId: ").append(this.snkNodeId)
+ .append(" srcPort: ").append(this.srcPort)
+ .append(" snkPort: ").append(this.snkPort)
+ .append(" distance: ").append(this.distance)
+ .append(" cost: ").append(this.cost)
+ .append(" wavelengthNumber: ").append(this.wavelengthNumber)
+ .append(" adminWeight: ").append(this.adminWeight).toString();
+ }
+}
+
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/package-info.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/package-info.java
new file mode 100644
index 00000000..4dd6eca2
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/cfg/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Packet/Optical configuration.
+ */
+@Deprecated
+package org.onosproject.optical.cfg;
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/package-info.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/package-info.java
new file mode 100644
index 00000000..fc73b2c8
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Packet/Optical application.
+ */
+package org.onosproject.optical;
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/LambdaForwarding.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/LambdaForwarding.java
new file mode 100644
index 00000000..05d6f12b
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/LambdaForwarding.java
@@ -0,0 +1,187 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed 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.onosproject.optical.testapp;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.IndexedLambda;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.device.DeviceEvent;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.flow.DefaultFlowRule;
+import org.onosproject.net.flow.DefaultTrafficSelector;
+import org.onosproject.net.flow.DefaultTrafficTreatment;
+import org.onosproject.net.flow.FlowRule;
+import org.onosproject.net.flow.FlowRuleService;
+import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.flow.criteria.Criteria;
+import org.onosproject.net.flow.instructions.Instructions;
+import org.slf4j.Logger;
+
+/**
+ * Sample reactive forwarding application.
+ */
+//@Component(immediate = true)
+public class LambdaForwarding {
+
+ private final Logger log = getLogger(getClass());
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected FlowRuleService flowRuleService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DeviceService deviceService;
+
+ private ApplicationId appId;
+
+ private final InternalDeviceListener listener = new InternalDeviceListener();
+
+ private final Map<DeviceId, Integer> uglyMap = new HashMap<>();
+
+ @Activate
+ public void activate() {
+ appId = coreService.registerApplication("org.onosproject.fwd");
+
+ uglyMap.put(DeviceId.deviceId("of:0000ffffffffff01"), 1);
+ uglyMap.put(DeviceId.deviceId("of:0000ffffffffff02"), 2);
+ uglyMap.put(DeviceId.deviceId("of:0000ffffffffff03"), 3);
+
+ deviceService.addListener(listener);
+
+ for (Device d : deviceService.getDevices()) {
+ pushRules(d);
+ }
+
+
+ log.info("Started with Application ID {}", appId.id());
+ }
+
+ @Deactivate
+ public void deactivate() {
+ flowRuleService.removeFlowRulesById(appId);
+
+ log.info("Stopped");
+ }
+
+
+ private void pushRules(Device device) {
+
+ TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
+ TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder();
+ int inport;
+ int outport;
+ short lambda = 10;
+ byte sigType = 1;
+ Integer switchNumber = uglyMap.get(device.id());
+ if (switchNumber == null) {
+ return;
+ }
+
+ switch (switchNumber) {
+ case 1:
+ inport = 10;
+ outport = 20;
+ sbuilder.matchInPort(PortNumber.portNumber(inport));
+ tbuilder.setOutput(PortNumber.portNumber(outport))
+ .add(Instructions.modL0Lambda(new IndexedLambda(lambda)));
+ break;
+ case 2:
+ inport = 21;
+ outport = 11;
+ sbuilder.add(Criteria.matchLambda(new IndexedLambda(lambda))).
+ matchInPort(PortNumber.portNumber(inport)); // match sigtype
+ tbuilder.setOutput(PortNumber.portNumber(outport));
+ break;
+ case 3:
+ inport = 30;
+ outport = 31;
+ sbuilder.add(Criteria.matchLambda(new IndexedLambda(lambda))).
+ matchInPort(PortNumber.portNumber(inport));
+ tbuilder.setOutput(PortNumber.portNumber(outport))
+ .add(Instructions.modL0Lambda(new IndexedLambda(lambda)));
+ break;
+ default:
+ }
+
+ TrafficTreatment treatment = tbuilder.build();
+ TrafficSelector selector = sbuilder.build();
+
+ FlowRule f = DefaultFlowRule.builder()
+ .forDevice(device.id())
+ .withSelector(selector)
+ .withTreatment(treatment)
+ .withPriority(100)
+ .fromApp(appId)
+ .makeTemporary(600)
+ .build();
+
+ flowRuleService.applyFlowRules(f);
+
+
+
+ }
+
+ public class InternalDeviceListener implements DeviceListener {
+
+ @Override
+ public void event(DeviceEvent event) {
+ switch (event.type()) {
+ case DEVICE_ADDED:
+ pushRules(event.subject());
+ break;
+ case DEVICE_AVAILABILITY_CHANGED:
+ break;
+ case DEVICE_REMOVED:
+ break;
+ case DEVICE_SUSPENDED:
+ break;
+ case DEVICE_UPDATED:
+ break;
+ case PORT_ADDED:
+ break;
+ case PORT_REMOVED:
+ break;
+ case PORT_UPDATED:
+ break;
+ default:
+ break;
+
+ }
+
+ }
+
+ }
+
+
+}
+
+
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/MPLSForwarding.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/MPLSForwarding.java
new file mode 100644
index 00000000..c784c82f
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/MPLSForwarding.java
@@ -0,0 +1,180 @@
+/*
+ * Copyright 2014-2015 Open Networking Laboratory
+ *
+ * Licensed 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.onosproject.optical.testapp;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.felix.scr.annotations.Activate;
+import org.apache.felix.scr.annotations.Deactivate;
+import org.apache.felix.scr.annotations.Reference;
+import org.apache.felix.scr.annotations.ReferenceCardinality;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.device.DeviceEvent;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.flow.DefaultFlowRule;
+import org.onosproject.net.flow.DefaultTrafficSelector;
+import org.onosproject.net.flow.DefaultTrafficTreatment;
+import org.onosproject.net.flow.FlowRule;
+import org.onosproject.net.flow.FlowRuleService;
+import org.onosproject.net.flow.TrafficSelector;
+import org.onosproject.net.flow.TrafficTreatment;
+import org.onlab.packet.Ethernet;
+import org.onlab.packet.MplsLabel;
+import org.slf4j.Logger;
+
+/**
+ * Sample reactive forwarding application.
+ */
+//@Component(immediate = true)
+public class MPLSForwarding {
+
+ private final Logger log = getLogger(getClass());
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected FlowRuleService flowRuleService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected CoreService coreService;
+
+ @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+ protected DeviceService deviceService;
+
+ private ApplicationId appId;
+
+ private final InternalDeviceListener listener = new InternalDeviceListener();
+
+ private final Map<DeviceId, Integer> uglyMap = new HashMap<>();
+
+ @Activate
+ public void activate() {
+ appId = coreService.registerApplication("org.onosproject.testapp" +
+ ".mplsfwd");
+
+ uglyMap.put(DeviceId.deviceId("of:0000000000000001"), 1);
+ uglyMap.put(DeviceId.deviceId("of:0000000000000002"), 2);
+ uglyMap.put(DeviceId.deviceId("of:0000000000000003"), 3);
+
+ deviceService.addListener(listener);
+
+ for (Device d : deviceService.getDevices()) {
+ pushRules(d);
+ }
+
+
+ log.info("Started with Application ID {}", appId.id());
+ }
+
+ @Deactivate
+ public void deactivate() {
+ flowRuleService.removeFlowRulesById(appId);
+
+ log.info("Stopped");
+ }
+
+
+ private void pushRules(Device device) {
+
+ TrafficSelector.Builder sbuilder = DefaultTrafficSelector.builder();
+ TrafficTreatment.Builder tbuilder = DefaultTrafficTreatment.builder();
+ int inport = 1;
+ int outport = 2;
+ MplsLabel mplsLabel = MplsLabel.mplsLabel(101);
+ Integer switchNumber = uglyMap.get(device.id());
+ if (switchNumber == null) {
+ return;
+ }
+
+ switch (switchNumber) {
+ case 1:
+ sbuilder.matchInPort(PortNumber.portNumber(inport));
+ tbuilder.setOutput(PortNumber.portNumber(outport))
+ .pushMpls()
+ .setMpls(mplsLabel);
+ break;
+ case 2:
+ sbuilder.matchMplsLabel(mplsLabel)
+ .matchEthType(Ethernet.MPLS_UNICAST)
+ .matchInPort(PortNumber.portNumber(inport));
+ tbuilder.setOutput(PortNumber.portNumber(outport));
+ break;
+ case 3:
+ sbuilder.matchMplsLabel(mplsLabel)
+ .matchEthType(Ethernet.MPLS_UNICAST)
+ .matchInPort(PortNumber.portNumber(inport));
+ tbuilder.popMpls().setOutput(PortNumber.portNumber(outport));
+ break;
+ default:
+ }
+
+ TrafficTreatment treatement = tbuilder.build();
+ TrafficSelector selector = sbuilder.build();
+
+ FlowRule f = DefaultFlowRule.builder()
+ .forDevice(device.id())
+ .withSelector(selector)
+ .withTreatment(treatement)
+ .withPriority(100)
+ .fromApp(appId)
+ .makeTemporary(600)
+ .build();
+
+ flowRuleService.applyFlowRules(f);
+ }
+
+
+ public class InternalDeviceListener implements DeviceListener {
+
+ @Override
+ public void event(DeviceEvent event) {
+ switch (event.type()) {
+ case DEVICE_ADDED:
+ pushRules(event.subject());
+ break;
+ case DEVICE_AVAILABILITY_CHANGED:
+ break;
+ case DEVICE_REMOVED:
+ break;
+ case DEVICE_SUSPENDED:
+ break;
+ case DEVICE_UPDATED:
+ break;
+ case PORT_ADDED:
+ break;
+ case PORT_REMOVED:
+ break;
+ case PORT_UPDATED:
+ break;
+ default:
+ break;
+
+ }
+
+ }
+
+ }
+
+
+}
+
+
diff --git a/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/package-info.java b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/package-info.java
new file mode 100644
index 00000000..f3d142b2
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/java/org/onosproject/optical/testapp/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2014 Open Networking Laboratory
+ *
+ * Licensed 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.
+ */
+
+/**
+ * Packet/Optical sample forwarding applications.
+ */
+package org.onosproject.optical.testapp;
diff --git a/framework/src/onos/apps/optical/src/main/resources/demo-10-roadm-6-ps.json b/framework/src/onos/apps/optical/src/main/resources/demo-10-roadm-6-ps.json
new file mode 100644
index 00000000..e4e11228
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/resources/demo-10-roadm-6-ps.json
@@ -0,0 +1,391 @@
+{
+ "opticalSwitches": [
+ {
+ "allowed": true,
+ "latitude": 37.6,
+ "longitude": 122.3,
+ "name": "SFO-W10",
+ "nodeDpid": "00:00:ff:ff:ff:ff:ff:01",
+ "params": {
+ "numRegen": 0
+ },
+ "type": "Roadm"
+ },
+
+ {
+ "allowed": true,
+ "latitude": 37.3,
+ "longitude": 121.9,
+ "name": "SJC-W10",
+ "nodeDpid": "00:00:ff:ff:ff:ff:ff:02",
+ "params": {
+ "numRegen": 0
+ },
+ "type": "Roadm"
+ },
+
+ {
+ "allowed": true,
+ "latitude": 33.9,
+ "longitude": 118.4
+ "name": "LAX-W10",
+ "nodeDpid": "00:00:ff:ff:ff:ff:ff:03",
+ "params": {
+ "numRegen": 0
+ },
+ "type": "Roadm"
+ },
+
+ {
+ "allowed": true,
+ "latitude": 32.8,
+ "longitude": 117.1,
+ "name": "SDG-W10",
+ "nodeDpid": "00:00:ff:ff:ff:ff:ff:04",
+ "params": {
+ "numRegen": 3
+ },
+ "type": "Roadm"
+ },
+
+ {
+ "allowed": true,
+ "latitude": 44.8,
+ "longitude": 93.1,
+ "name": "MSP-M10",
+ "nodeDpid": "00:00:ff:ff:ff:ff:ff:05",
+ "params": {
+ "numRegen": 3
+ },
+ "type": "Roadm"
+ },
+
+ {
+ "allowed": true,
+ "latitude": 32.8,
+ "longitude": 97.1,
+ "name": "DFW-M10",
+ "nodeDpid": "00:00:ff:ff:ff:ff:ff:06",
+ "params": {
+ "numRegen": 3
+ },
+ "type": "Roadm"
+ },
+
+ {
+ "allowed": true,
+ "latitude": 41.8,
+ "longitude": 120.1,
+ "name": "CHG-N10",
+ "nodeDpid": "00:00:ff:ff:ff:ff:ff:07",
+ "params": {
+ "numRegen": 3
+ },
+ "type": "Roadm"
+ },
+
+ {
+ "allowed": true,
+ "latitude": 38.8,
+ "longitude": 77.1,
+ "name": "IAD-M10",
+ "nodeDpid": "00:00:ff:ff:ff:ff:ff:08",
+ "params": {
+ "numRegen": 3
+ },
+ "type": "Roadm"
+ },
+
+ {
+ "allowed": true,
+ "latitude": 40.8,
+ "longitude": 73.1,
+ "name": "JFK-E10",
+ "nodeDpid": "00:00:ff:ff:ff:ff:ff:09",
+ "params": {
+ "numRegen": 0
+ },
+ "type": "Roadm"
+
+ },
+
+ {
+ "allowed": true,
+ "latitude": 33.8,
+ "longitude": 84.1,
+ "name": "ATL-S10",
+ "nodeDpid": "00:00:ff:ff:ff:ff:ff:0A",
+ "params": {
+ "numRegen": 0
+ },
+ "type": "Roadm"
+ }
+
+ ],
+
+ "opticalLinks": [
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:ff:01",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:02",
+ "params": {
+ "distKms": 1000,
+ "nodeName1": "SFO-W10",
+ "nodeName2": "SJC-W10",
+ "numWaves": 80,
+ "port1": 10,
+ "port2": 10
+ },
+ "type": "wdmLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:ff:02",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:03",
+ "params": {
+ "distKms": 1000,
+ "nodeName1": "SJC-W10",
+ "nodeName2": "LAX-W10",
+ "numWaves": 80,
+ "port1": 20,
+ "port2": 10
+ },
+ "type": "wdmLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:ff:03",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:04",
+ "params": {
+ "distKms": 1000,
+ "nodeName1": "LAX-W10",
+ "nodeName2": "SDG-W10",
+ "numWaves": 80,
+ "port1": 30,
+ "port2": 10
+ },
+ "type": "wdmLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:ff:02",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:05",
+ "params": {
+ "distKms": 4000,
+ "nodeName1": "SJC-W10",
+ "nodeName2": "MSP-M10",
+ "numWaves": 80,
+ "port1": 20,
+ "port2": 10
+ },
+ "type": "wdmLink"
+ },
+
+ {
+
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:ff:03",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:06",
+ "params": {
+ "distKms": 5000,
+ "nodeName1": "LAX-W10",
+ "nodeName2": "DFW-M10",
+ "numWaves": 80,
+ "port1": 20,
+ "port2": 10
+ },
+ "type": "wdmLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:ff:05",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:06",
+ "params": {
+ "distKms": 3000,
+ "nodeName1": "MSP-M10",
+ "nodeName2": "DFW-M10",
+ "numWaves": 80,
+ "port1": 30,
+ "port2": 20
+ },
+ "type": "wdmLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:ff:05",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:07",
+ "params": {
+ "distKms": 3000,
+ "nodeName1": "MSP-M10",
+ "nodeName2": "CHG-N10",
+ "numWaves": 80,
+ "port1": 20,
+ "port2": 21
+ },
+ "type": "wdmLink"
+ },
+
+ {
+
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:ff:06",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:08",
+ "params": {
+ "distKms": 4000,
+ "nodeName1": "DFW-M10",
+ "nodeName2": "IAD-M10",
+ "numWaves": 80,
+ "port1": 30,
+ "port2": 10
+ },
+ "type": "wdmLink"
+ },
+
+ {
+
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:ff:07",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:08",
+ "params": {
+ "distKms": 4000,
+ "nodeName1": "CHG-M10",
+ "nodeName2": "IAD-M10",
+ "numWaves": 80,
+ "port1": 30,
+ "port2": 20
+ },
+ "type": "wdmLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:ff:07",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:09",
+ "params": {
+ "distKms": 5000,
+ "nodeName1": "CHG-M10",
+ "nodeName2": "JFK-E10",
+ "numWaves": 80,
+ "port1": 20,
+ "port2": 10
+ },
+ "type": "wdmLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:ff:08",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:0A",
+ "params": {
+ "distKms": 3000,
+ "nodeName1": "IAD-M10",
+ "nodeName2": "ATL-S10",
+ "numWaves": 80,
+ "port1": 30,
+ "port2": 10
+ },
+ "type": "wdmLink"
+ },
+
+ {
+
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:ff:09",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:0A",
+ "params": {
+ "distKms": 4000,
+ "nodeName1": "JFK-E10",
+ "nodeName2": "ATL-S10",
+ "numWaves": 80,
+ "port1": 20,
+ "port2": 20
+ },
+ "type": "wdmLink"
+ },
+
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:00:01",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:01",
+ "params": {
+ "nodeName1": "SFO-R10",
+ "nodeName2": "SFO-W10",
+ "port1": 10,
+ "port2": 1
+ },
+ "type": "pktOptLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:00:03",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:03",
+ "params": {
+ "nodeName1": "LAX-R10",
+ "nodeName2": "LAX-W10",
+ "port1": 10,
+ "port2": 1
+ },
+ "type": "pktOptLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:00:04",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:04",
+ "params": {
+ "nodeName1": "SDG-R10",
+ "nodeName2": "SDG-W10",
+ "port1": 10,
+ "port2": 1
+ },
+ "type": "pktOptLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:00:07",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:07",
+ "params": {
+ "nodeName1": "CHG-R10",
+ "nodeName2": "CHG-W10",
+ "port1": 10,
+ "port2": 1
+ },
+ "type": "pktOptLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:00:09",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:09",
+ "params": {
+ "nodeName1": "JFK-R10",
+ "nodeName2": "JFK-W10",
+ "port1": 10,
+ "port2": 1
+ },
+ "type": "pktOptLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:00:0A",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:0A",
+ "params": {
+ "nodeName1": "ATL-R10",
+ "nodeName2": "ATL-W10",
+ "port1": 10,
+ "port2": 1
+ },
+ "type": "pktOptLink"
+ },
+
+ ]
+}
diff --git a/framework/src/onos/apps/optical/src/main/resources/demo-3-roadm-2-ps.json b/framework/src/onos/apps/optical/src/main/resources/demo-3-roadm-2-ps.json
new file mode 100644
index 00000000..125a307b
--- /dev/null
+++ b/framework/src/onos/apps/optical/src/main/resources/demo-3-roadm-2-ps.json
@@ -0,0 +1,100 @@
+{
+ "opticalSwitches": [
+ {
+ "allowed": true,
+ "latitude": 37.6,
+ "longitude": 122.3,
+ "name": "ROADM1",
+ "nodeDpid": "00:00:ff:ff:ff:ff:ff:01",
+ "params": {
+ "numRegen": 0
+ },
+ "type": "Roadm"
+ },
+
+ {
+ "allowed": true,
+ "latitude": 37.3,
+ "longitude": 121.9,
+ "name": "ROADM2",
+ "nodeDpid": "00:00:ff:ff:ff:ff:ff:02",
+ "params": {
+ "numRegen": 0
+ },
+ "type": "Roadm"
+ },
+
+ {
+ "allowed": true,
+ "latitude": 33.9,
+ "longitude": 118.4,
+ "name": "ROADM3",
+ "nodeDpid": "00:00:ff:ff:ff:ff:ff:03",
+ "params": {
+ "numRegen": 2
+ },
+ "type": "Roadm"
+ }
+ ],
+
+ "opticalLinks": [
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:ff:01",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:03",
+ "params": {
+ "distKms": 1000,
+ "nodeName1": "ROADM1",
+ "nodeName2": "ROADM3",
+ "numWaves": 80,
+ "port1": 20,
+ "port2": 30
+ },
+ "type": "wdmLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:ff:03",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:02",
+ "params": {
+ "distKms": 2000,
+ "nodeName1": "ROADM3",
+ "nodeName2": "ROADM2",
+ "numWaves": 80,
+ "port1": 31,
+ "port2": 21
+ },
+ "type": "wdmLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:00:01",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:01",
+ "params": {
+ "nodeName1": "ROUTER1",
+ "nodeName2": "ROADM1",
+ "bandWidth": 100000,
+ "port1": 2,
+ "port2": 10
+ },
+ "type": "pktOptLink"
+ },
+
+ {
+ "allowed": true,
+ "nodeDpid1": "00:00:ff:ff:ff:ff:00:02",
+ "nodeDpid2": "00:00:ff:ff:ff:ff:ff:02",
+ "params": {
+ "nodeName1": "ROUTER2",
+ "nodeName2": "ROADM2",
+ "bandWidth": 100000,
+ "port1": 2,
+ "port2": 11
+ },
+ "type": "pktOptLink"
+ }
+
+ ]
+}