[ONOS-4513] Slice optical-model into separate bundle (1/3)
- net and cli bundle has dependency to optical-model bundle,
which should be removed in the longer run. (ONOS-4626)
Change-Id: Ieff43ef2002ee21f4578a6e2a729cd35ce3eae3d
diff --git a/apps/newoptical/BUCK b/apps/newoptical/BUCK
index db15c64..ac24ee1 100644
--- a/apps/newoptical/BUCK
+++ b/apps/newoptical/BUCK
@@ -3,6 +3,7 @@
'//core/store/serializers:onos-core-serializers',
'//lib:org.apache.karaf.shell.console',
'//cli:onos-cli',
+ '//apps/optical-model:onos-apps-optical-model',
]
TEST_DEPS = [
@@ -19,4 +20,5 @@
category = 'Traffic Steering',
url = 'http://onosproject.org',
description = 'Packet/Optical use-case application.',
+ required_apps = [ 'org.onosproject.optical-model' ],
)
diff --git a/apps/newoptical/pom.xml b/apps/newoptical/pom.xml
index 13821f7..9eb579c 100644
--- a/apps/newoptical/pom.xml
+++ b/apps/newoptical/pom.xml
@@ -32,9 +32,13 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<onos.app.name>org.onosproject.newoptical</onos.app.name>
+ <onos.app.title>Packet/Optical Use-Case App</onos.app.title>
<onos.app.category>Traffic Steering</onos.app.category>
<onos.app.url>https://wiki.onosproject.org/display/ONOS/Packet+Optical+Convergence</onos.app.url>
<onos.app.origin>ON.Lab</onos.app.origin>
+ <onos.app.requires>
+ org.onosproject.optical-model
+ </onos.app.requires>
</properties>
<dependencies>
@@ -46,6 +50,12 @@
<dependency>
<groupId>org.onosproject</groupId>
+ <artifactId>onos-optical-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
<artifactId>onos-core-dist</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/apps/optical-model/BUCK b/apps/optical-model/BUCK
new file mode 100644
index 0000000..cf06443
--- /dev/null
+++ b/apps/optical-model/BUCK
@@ -0,0 +1,26 @@
+COMPILE_DEPS = [
+ '//lib:CORE_DEPS',
+ '//incubator/api:onos-incubator-api',
+]
+
+TEST_DEPS = [
+ '//lib:TEST',
+]
+
+
+osgi_jar_with_tests (
+ deps = COMPILE_DEPS,
+ test_deps = TEST_DEPS,
+)
+
+onos_app (
+ app_name = 'org.onosproject.optical-model',
+ # Is there a way to change BUCK target name properly?
+ #name = 'onos-optical-model',
+ feature_coords = 'org.onosproject:onos-optical-model:%s' % (ONOS_VERSION),
+ title = 'Optical information model',
+ category = 'Optical',
+ url = 'https://wiki.onosproject.org/x/C4m',
+ description = 'ONOS optical information model.',
+ required_apps = [ ],
+)
diff --git a/apps/optical-model/features.xml b/apps/optical-model/features.xml
new file mode 100644
index 0000000..c16534a
--- /dev/null
+++ b/apps/optical-model/features.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<!--
+ ~ Copyright 2016-present 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.
+ -->
+<features xmlns="http://karaf.apache.org/xmlns/features/v1.2.1" name="${project.artifactId}-${project.version}">
+ <feature name="${project.artifactId}" version="${project.version}"
+ description="${project.description}">
+ <feature>onos-api</feature>
+ <bundle>mvn:${project.groupId}/${project.artifactId}/${project.version}</bundle>
+ </feature>
+</features>
diff --git a/apps/optical-model/pom.xml b/apps/optical-model/pom.xml
new file mode 100644
index 0000000..90fd800
--- /dev/null
+++ b/apps/optical-model/pom.xml
@@ -0,0 +1,61 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright 2016-present 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/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>onos-apps</artifactId>
+ <groupId>org.onosproject</groupId>
+ <version>1.7.0-SNAPSHOT</version>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>onos-optical-model</artifactId>
+ <packaging>bundle</packaging>
+
+ <description>ONOS Optical Model extensions</description>
+
+ <properties>
+ <onos.app.name>org.onosproject.optical-model</onos.app.name>
+ <onos.app.origin>ON.Lab</onos.app.origin>
+ <onos.app.category>Optical</onos.app.category>
+ <onos.app.title>Optical information model</onos.app.title>
+ <onos.app.url>https://wiki.onosproject.org/x/C4m</onos.app.url>
+ <onos.app.requires>
+ </onos.app.requires>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onos-api</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.onosproject</groupId>
+ <artifactId>onlab-junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava-testlib</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ </dependencies>
+</project>
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/DefaultOpticalDevice.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/DefaultOpticalDevice.java
new file mode 100644
index 0000000..c5b1ff0
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/DefaultOpticalDevice.java
@@ -0,0 +1,139 @@
+/*
+ * Copyright 2016 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.net.optical;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Preconditions.checkState;
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.Map;
+import java.util.Optional;
+import org.onlab.osgi.DefaultServiceDirectory;
+import org.onosproject.net.Device;
+import org.onosproject.net.Port;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.driver.AbstractBehaviour;
+import org.onosproject.net.driver.DriverData;
+import org.onosproject.net.optical.device.port.OchPortMapper;
+import org.onosproject.net.optical.device.port.OduCltPortMapper;
+import org.onosproject.net.optical.device.port.OmsPortMapper;
+import org.onosproject.net.optical.device.port.OtuPortMapper;
+import org.onosproject.net.optical.device.port.PortMapper;
+import org.onosproject.net.utils.ForwardingDevice;
+import org.slf4j.Logger;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.MoreObjects;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Implementation of {@link OpticalDevice}.
+ * <p>
+ * Currently supports
+ * <ul>
+ * <li> {@link OchPort}
+ * <li> {@link OmsPort}
+ * <li> {@link OduCltPort}
+ * <li> {@link OtuPort}
+ * </ul>
+ */
+@Beta
+public class DefaultOpticalDevice
+ extends AbstractBehaviour
+ implements OpticalDevice, ForwardingDevice {
+
+ private static final Logger log = getLogger(DefaultOpticalDevice.class);
+
+ // shared Port type handler map.
+ // TODO Is there a use case, where we need to differentiate this map per Device?
+ private static final Map<Class<? extends Port>, PortMapper<? extends Port>> MAPPERS
+ = ImmutableMap.<Class<? extends Port>, PortMapper<? extends Port>>builder()
+ .put(OchPort.class, new OchPortMapper())
+ .put(OmsPort.class, new OmsPortMapper())
+ .put(OduCltPort.class, new OduCltPortMapper())
+ .put(OtuPort.class, new OtuPortMapper())
+ // TODO add other optical port type here
+ .build();
+
+
+
+ // effectively final
+ private Device delegate;
+
+ // Default constructor required as a Behaviour.
+ public DefaultOpticalDevice() {}
+
+ @Override
+ public Device delegate() {
+ if (delegate == null) {
+ // dirty work around.
+ // wanted to pass delegate Device at construction,
+ // but was not possible. A Behaviour requires no-arg constructor.
+ checkState(data() != null, "DriverData must exist");
+ DriverData data = data();
+ DeviceService service = DefaultServiceDirectory.getService(DeviceService.class);
+ delegate = checkNotNull(service.getDevice(data.deviceId()),
+ "No Device found for %s", data.deviceId());
+ }
+ return delegate;
+ }
+
+ @Override
+ public <T extends Port> boolean portIs(Port port, Class<T> portClass) {
+
+ PortMapper<? extends Port> mapper = MAPPERS.get(portClass);
+ if (mapper != null) {
+ return mapper.is(port);
+ }
+ return false;
+ }
+
+ @Override
+ public <T extends Port> Optional<T> portAs(Port port, Class<T> portClass) {
+ PortMapper<? extends Port> mapper = MAPPERS.get(portClass);
+ if (mapper != null) {
+ return (Optional<T>) (mapper.as(port));
+ }
+ return Optional.empty();
+ }
+
+ @Override
+ public Port port(Port port) {
+ for (PortMapper<? extends Port> mapper : MAPPERS.values()) {
+ if (mapper.is(port)) {
+ return mapper.as(port).map(Port.class::cast).orElse(port);
+ }
+ }
+ return port;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return delegate().equals(obj);
+ }
+
+ @Override
+ public int hashCode() {
+ return delegate().hashCode();
+ }
+
+ @Override
+ public String toString() {
+ return MoreObjects.toStringHelper(this)
+ .add("delegate", delegate)
+ .toString();
+ }
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/OchPort.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/OchPort.java
new file mode 100644
index 0000000..8d19889
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/OchPort.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2016 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.net.optical;
+
+import org.onosproject.net.OchSignal;
+import org.onosproject.net.OduSignalType;
+import org.onosproject.net.Port;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * OCh port (Optical Channel).
+ * Also referred to as a line side port (L-port) or narrow band port.
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
+ */
+@Beta
+public interface OchPort extends Port {
+
+ /**
+ * Returns ODU signal type.
+ *
+ * @return ODU signal type
+ */
+ public OduSignalType signalType();
+
+ /**
+ * Returns true if port is wavelength tunable.
+ *
+ * @return tunable wavelength capability
+ */
+ public boolean isTunable();
+
+ /**
+ * Returns OCh signal.
+ *
+ * @return OCh signal
+ */
+ public OchSignal lambda();
+
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/OduCltPort.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/OduCltPort.java
new file mode 100644
index 0000000..b4342f4
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/OduCltPort.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2016-present 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.net.optical;
+
+import org.onosproject.net.CltSignalType;
+import org.onosproject.net.Port;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * ODU client port (Optical channel Data Unit).
+ * Also referred to as a T-port or wide band port.
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
+ */
+@Beta
+public interface OduCltPort extends Port {
+
+ /**
+ * Returns ODU client signal type.
+ *
+ * @return ODU client signal type
+ */
+ CltSignalType signalType();
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/OmsPort.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/OmsPort.java
new file mode 100644
index 0000000..898fce9
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/OmsPort.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2016-present 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.net.optical;
+
+import org.onlab.util.Frequency;
+import org.onosproject.net.Port;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * OMS port (Optical Multiplexing Section).
+ * Also referred to as a WDM port or W-port.
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
+ *
+ * Assumes we only support fixed grid for now.
+ */
+@Beta
+public interface OmsPort extends Port {
+
+ /**
+ * Returns the total number of channels on the port.
+ *
+ * @return total number of channels
+ */
+ default short totalChannels() {
+ Frequency diff = maxFrequency().subtract(minFrequency());
+ return (short) (diff.asHz() / grid().asHz() + 1);
+ }
+
+ /**
+ * Returns the minimum frequency.
+ *
+ * @return minimum frequency
+ */
+ Frequency minFrequency();
+
+ /**
+ * Returns the maximum frequency.
+ *
+ * @return maximum frequency
+ */
+ Frequency maxFrequency();
+
+ /**
+ * Returns the grid spacing frequency.
+ *
+ * @return grid spacing frequency
+ */
+ Frequency grid();
+
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/OpticalDevice.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/OpticalDevice.java
new file mode 100644
index 0000000..a1498ab
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/OpticalDevice.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016 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.net.optical;
+
+import java.util.Optional;
+
+import org.onosproject.net.Device;
+import org.onosproject.net.Port;
+import org.onosproject.net.driver.Behaviour;
+
+import com.google.common.annotations.Beta;
+
+
+// TODO consider more fine grained device type. e.g., Transponder, WSS, ROADM
+/**
+ * Representation of a optical network infrastructure device.
+ */
+@Beta
+public interface OpticalDevice extends Device, Behaviour {
+
+ /**
+ * Returns true if {@code port} is capable of being projected as the
+ * specified class.
+ *
+ * @param port Port instance to test
+ * @param portClass requested projection class
+ * @param <T> type of Port
+ * @return true if the requested projection is supported
+ */
+ <T extends Port> boolean portIs(Port port, Class<T> portClass);
+
+ /**
+ * Returns the specified projection of the {@code port} if such projection
+ * is supported.
+ *
+ * @param port Port instance to project
+ * @param portClass requested projection class
+ * @param <T> type of Port
+ * @return projection instance or empty if not supported.
+ */
+ <T extends Port> Optional<T> portAs(Port port, Class<T> portClass);
+
+ /**
+ * Returns most specific projection of the {@code port} or the {@code port}
+ * itself.
+ *
+ * @param port Port instance
+ * @return projection instance or {@code port} itself
+ */
+ Port port(Port port);
+
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/OtuPort.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/OtuPort.java
new file mode 100644
index 0000000..15f284d
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/OtuPort.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016-present 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 gcd ~/Dooverning permissions and
+ * limitations under the License.
+ */
+package org.onosproject.net.optical;
+
+import org.onosproject.net.OtuSignalType;
+import org.onosproject.net.Port;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * OTU port (Optical channel Transport Unit).
+ * <p>
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)" and
+ * Open Networking Foundation "Optical Transport Protocol Extensions Version 1.0".
+ */
+@Beta
+public interface OtuPort extends Port {
+
+ /**
+ * Returns OTU signal type.
+ *
+ * @return OTU signal type
+ */
+ public OtuSignalType signalType();
+
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OchPortHelper.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OchPortHelper.java
new file mode 100644
index 0000000..50dc98c
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OchPortHelper.java
@@ -0,0 +1,156 @@
+/*
+ * Copyright 2016 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.net.optical.device;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.io.IOException;
+import java.util.Optional;
+
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DefaultAnnotations.Builder;
+import org.onosproject.net.OchSignal;
+import org.onosproject.net.OduSignalType;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.device.DefaultPortDescription;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.impl.DefaultOchPort;
+import org.onosproject.net.optical.json.OchSignalCodec;
+import org.slf4j.Logger;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.annotations.Beta;
+
+/**
+ * OCh port related helpers.
+ */
+@Beta
+public final class OchPortHelper {
+
+ private static final Logger log = getLogger(OchPortHelper.class);
+
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ // Annotation keys
+ private static final String SIGNAL_TYPE = "signalType";
+ private static final String TUNABLE = "tunable";
+ private static final String LAMBDA = "lambda";
+
+ /**
+ * Creates OCh port DefaultPortDescription based on the supplied information.
+ *
+ * @param number port number
+ * @param isEnabled port enabled state
+ * @param signalType ODU signal type
+ * @param isTunable tunable wavelength capability
+ * @param lambda OCh signal
+ * @return OCh port DefaultPortDescription with OCh annotations
+ */
+ public static PortDescription ochPortDescription(PortNumber number,
+ boolean isEnabled,
+ OduSignalType signalType,
+ boolean isTunable,
+ OchSignal lambda) {
+ return ochPortDescription(number, isEnabled, signalType, isTunable, lambda, DefaultAnnotations.EMPTY);
+ }
+
+ /**
+ * Creates OCh port DefaultPortDescription based on the supplied information.
+ *
+ * @param number port number
+ * @param isEnabled port enabled state
+ * @param signalType ODU signal type
+ * @param isTunable tunable wavelength capability
+ * @param lambda OCh signal
+ * @param annotationsIn key/value annotations map
+ * @return OCh port DefaultPortDescription with OCh annotations
+ */
+ public static PortDescription ochPortDescription(PortNumber number,
+ boolean isEnabled,
+ OduSignalType signalType,
+ boolean isTunable,
+ OchSignal lambda,
+ SparseAnnotations annotationsIn) {
+
+ Builder builder = DefaultAnnotations.builder();
+ builder.putAll(annotationsIn);
+
+ builder.set(TUNABLE, String.valueOf(isTunable));
+ builder.set(LAMBDA, OchSignalCodec.encode(lambda).toString());
+ builder.set(SIGNAL_TYPE, signalType.toString());
+
+ DefaultAnnotations annotations = builder.build();
+ long portSpeed = 0; // FIXME assign appropriate value
+ return new DefaultPortDescription(number, isEnabled, Port.Type.OCH, portSpeed, annotations);
+ }
+
+ /**
+ * Creates OCh port DefaultPortDescription based on the supplied information.
+ *
+ * @param base PortDescription to get basic information from
+ * @param signalType ODU signal type
+ * @param isTunable tunable wavelength capability
+ * @param lambda OCh signal
+ * @param annotations key/value annotations map
+ * @return OCh port DefaultPortDescription with OCh annotations
+ */
+ public static PortDescription ochPortDescription(PortDescription base,
+ OduSignalType signalType,
+ boolean isTunable,
+ OchSignal lambda,
+ SparseAnnotations annotations) {
+ return ochPortDescription(base.portNumber(), base.isEnabled(), signalType, isTunable, lambda, annotations);
+ }
+
+
+ public static Optional<OchPort> asOchPort(Port port) {
+ if (port instanceof OchPort) {
+ return Optional.of((OchPort) port);
+ }
+
+ try {
+ Annotations an = port.annotations();
+
+ OduSignalType signalType = Enum.valueOf(OduSignalType.class,
+ an.value(SIGNAL_TYPE));
+
+ boolean isTunable = Boolean.valueOf(an.value(TUNABLE));
+
+ ObjectNode obj = (ObjectNode) MAPPER.readTree(an.value(LAMBDA));
+ OchSignal lambda = OchSignalCodec.decode(obj);
+
+ // Note: OCh specific annotations is not filtered-out here.
+ // DefaultOchPort should filter them, if necessary.
+ return Optional.of(new DefaultOchPort(port, signalType, isTunable, lambda));
+
+ // TODO: it'll be better to verify each inputs properly
+ // instead of catching all these Exceptions.
+ } catch (IOException | NullPointerException
+ | IllegalArgumentException | ClassCastException e) {
+
+ log.warn("{} was not well-formed OCh port.", port, e);
+ return Optional.empty();
+ }
+ }
+
+ // not meant to be instantiated
+ private OchPortHelper() {}
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OduCltPortHelper.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OduCltPortHelper.java
new file mode 100644
index 0000000..efda401
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OduCltPortHelper.java
@@ -0,0 +1,127 @@
+/*
+ * Copyright 2016-present 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.net.optical.device;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.Optional;
+
+import org.onosproject.net.Annotations;
+import org.onosproject.net.CltSignalType;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.DefaultAnnotations.Builder;
+import org.onosproject.net.device.DefaultPortDescription;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.optical.OduCltPort;
+import org.onosproject.net.optical.impl.DefaultOduCltPort;
+import org.slf4j.Logger;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * ODU client port related helpers.
+ */
+@Beta
+public final class OduCltPortHelper {
+
+ private static final Logger log = getLogger(OduCltPortHelper.class);
+
+ // Annotation keys
+ /**
+ * {@link CltSignalType} as String.
+ */
+ private static final String SIGNAL_TYPE = "signalType";
+
+ /**
+ * Creates ODU client port description based on the supplied information.
+ *
+ * @param number port number
+ * @param isEnabled port enabled state
+ * @param signalType ODU client signal type
+ */
+ public static PortDescription oduCltPortDescription(PortNumber number,
+ boolean isEnabled,
+ CltSignalType signalType) {
+ return oduCltPortDescription(number, isEnabled, signalType, DefaultAnnotations.EMPTY);
+ }
+
+ /**
+ * Creates ODU client port description based on the supplied information.
+ *
+ * @param number port number
+ * @param isEnabled port enabled state
+ * @param signalType ODU client signal type
+ * @param annotations key/value annotations map
+ */
+ public static PortDescription oduCltPortDescription(PortNumber number,
+ boolean isEnabled,
+ CltSignalType signalType,
+ SparseAnnotations annotations) {
+ Builder builder = DefaultAnnotations.builder();
+ builder.putAll(annotations);
+
+ builder.set(SIGNAL_TYPE, signalType.toString());
+
+ long portSpeed = signalType.bitRate();
+ return new DefaultPortDescription(number,
+ isEnabled,
+ Port.Type.ODUCLT,
+ portSpeed,
+ builder.build());
+ }
+
+ /**
+ * Creates ODU client port description based on the supplied information.
+ *
+ * @param base PortDescription to get basic information from
+ * @param signalType ODU client signal type
+ * @param annotations key/value annotations map
+ */
+ public static PortDescription oduCltPortDescription(PortDescription base,
+ CltSignalType signalType,
+ SparseAnnotations annotations) {
+ return oduCltPortDescription(base.portNumber(), base.isEnabled(), signalType, annotations);
+ }
+
+ public static Optional<OduCltPort> asOduCltPort(Port port) {
+ if (port instanceof OduCltPort) {
+ return Optional.of((OduCltPort) port);
+ }
+
+ try {
+ Annotations an = port.annotations();
+
+ CltSignalType signalType = Enum.valueOf(CltSignalType.class,
+ an.value(SIGNAL_TYPE));
+
+
+ // Note: ODU specific annotations is not filtered-out here.
+ // DefaultOduCltPort should filter them, if necessary.
+ return Optional.of(new DefaultOduCltPort(port, signalType));
+
+ } catch (NullPointerException | IllegalArgumentException e) {
+
+ log.warn("{} was not well-formed OduClt port.", port, e);
+ return Optional.empty();
+ }
+ }
+
+ // not meant to be instantiated
+ private OduCltPortHelper() {}
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OmsPortHelper.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OmsPortHelper.java
new file mode 100644
index 0000000..2c99c53
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OmsPortHelper.java
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2016-present 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.net.optical.device;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.Optional;
+
+import org.onlab.util.Frequency;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.DefaultAnnotations.Builder;
+import org.onosproject.net.device.DefaultPortDescription;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.optical.OmsPort;
+import org.onosproject.net.optical.impl.DefaultOmsPort;
+import org.slf4j.Logger;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * OMS port related helpers.
+ */
+@Beta
+public final class OmsPortHelper {
+
+ private static final Logger log = getLogger(OmsPortHelper.class);
+
+ // Annotation keys
+ /**
+ * minFrequency in Hz.
+ */
+ private static final String MIN_FREQ_HZ = "minFrequency";
+ /**
+ * maxFrequency in Hz.
+ */
+ private static final String MAX_FREQ_HZ = "maxFrequency";
+ /**
+ * grid in Hz.
+ */
+ private static final String GRID_HZ = "grid";
+
+ /**
+ * Creates OMS port description based on the supplied information.
+ *
+ * @param number port number
+ * @param isEnabled port enabled state
+ * @param minFrequency minimum frequency
+ * @param maxFrequency maximum frequency
+ * @param grid grid spacing frequency
+ * @param annotations key/value annotations map
+ */
+ public static PortDescription omsPortDescription(PortNumber number,
+ boolean isEnabled,
+ Frequency minFrequency,
+ Frequency maxFrequency,
+ Frequency grid,
+ SparseAnnotations annotations) {
+
+ Builder builder = DefaultAnnotations.builder();
+ builder.putAll(annotations);
+
+ builder.set(MIN_FREQ_HZ, String.valueOf(minFrequency.asHz()));
+ builder.set(MAX_FREQ_HZ, String.valueOf(maxFrequency.asHz()));
+ builder.set(GRID_HZ, String.valueOf(grid.asHz()));
+
+ long portSpeed = 0;
+ return new DefaultPortDescription(number, isEnabled, Port.Type.OMS, portSpeed, builder.build());
+ }
+
+ /**
+ * Creates OMS port description based on the supplied information.
+ *
+ * @param number port number
+ * @param isEnabled port enabled state
+ * @param minFrequency minimum frequency
+ * @param maxFrequency maximum frequency
+ * @param grid grid spacing frequency
+ */
+ public static PortDescription omsPortDescription(PortNumber number,
+ boolean isEnabled,
+ Frequency minFrequency,
+ Frequency maxFrequency,
+ Frequency grid) {
+ return omsPortDescription(number, isEnabled, minFrequency, maxFrequency, grid, DefaultAnnotations.EMPTY);
+ }
+
+ /**
+ * Creates OMS port description based on the supplied information.
+ *
+ * @param base PortDescription to get basic information from
+ * @param minFrequency minimum frequency
+ * @param maxFrequency maximum frequency
+ * @param grid grid spacing frequency
+ * @param annotations key/value annotations map
+ */
+ public static PortDescription omsPortDescription(PortDescription base,
+ Frequency minFrequency,
+ Frequency maxFrequency,
+ Frequency grid,
+ SparseAnnotations annotations) {
+
+ return omsPortDescription(base.portNumber(), base.isEnabled(),
+ minFrequency, maxFrequency, grid,
+ annotations);
+ }
+
+ public static Optional<OmsPort> asOmsPort(Port port) {
+ if (port instanceof OmsPort) {
+ return Optional.of((OmsPort) port);
+ }
+
+ try {
+ Annotations an = port.annotations();
+
+ Frequency minFrequency = Frequency.ofHz(Long.parseLong(an.value(MIN_FREQ_HZ)));
+ Frequency maxFrequency = Frequency.ofHz(Long.parseLong(an.value(MAX_FREQ_HZ)));
+ Frequency grid = Frequency.ofHz(Long.parseLong(an.value(GRID_HZ)));
+
+ return Optional.of(new DefaultOmsPort(port, minFrequency, maxFrequency, grid));
+
+ } catch (NumberFormatException e) {
+
+ log.warn("{} was not well-formed OMS port.", port, e);
+ return Optional.empty();
+ }
+ }
+
+ // not meant to be instantiated
+ private OmsPortHelper() {}
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OpticalDeviceServiceView.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OpticalDeviceServiceView.java
new file mode 100644
index 0000000..da4da82
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OpticalDeviceServiceView.java
@@ -0,0 +1,194 @@
+/*
+ * Copyright 2016 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.net.optical.device;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+
+import org.onosproject.net.device.DeviceEvent;
+import org.onosproject.net.device.DeviceListener;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.optical.OpticalDevice;
+import org.onosproject.net.utils.ForwardingDeviceService;
+import org.slf4j.Logger;
+
+import com.google.common.annotations.Beta;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+
+import org.apache.commons.lang3.tuple.Pair;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Element;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+
+
+// TODO replace places using DeviceService expecting Optical specific ports.
+// with this
+
+/**
+ * Decorator, which provides a DeviceService view, which returns
+ * Ports in optical specific ports.
+ */
+@Beta
+public class OpticalDeviceServiceView
+ extends ForwardingDeviceService
+ implements DeviceService {
+
+ private static final Logger log = getLogger(OpticalDeviceServiceView.class);
+
+ /**
+ * DeviceListener to wrapped DeviceListener map.
+ * <p>
+ * {@literal original listener -> wrapped listener}
+ */
+ private final Map<DeviceListener, DeviceListener> wrapped = Maps.newIdentityHashMap();
+
+ // May need a way to monitor Drivers loaded on ONOS and
+ // invalidate this Cache if a driver was added/updated
+ /**
+ * Device to {@link OpticalDevice} map cache.
+ */
+ private final LoadingCache<Element, Optional<OpticalDevice>> optdev
+ = CacheBuilder.newBuilder()
+ .weakKeys() // == for Key comparison
+ .maximumSize(100)
+ .build(CacheLoader.from(elm -> {
+ if (elm.is(OpticalDevice.class)) {
+ return Optional.of(elm.as(OpticalDevice.class));
+ } else {
+ return Optional.empty();
+ }
+ }));
+
+ // Not intended to be instantiated directly
+ protected OpticalDeviceServiceView(DeviceService base) {
+ super(base);
+ }
+
+ /**
+ * Wraps the given DeviceService to provide a view,
+ * which returns port as optical specific Port class.
+ *
+ * @param base {@link DeviceService} view to use as baseline.
+ * @return Decorated view of {@code base}
+ */
+ public static OpticalDeviceServiceView opticalView(DeviceService base) {
+ // TODO might make sense to track and assign an instance for each `base`
+ return new OpticalDeviceServiceView(base);
+ }
+
+ /**
+ * Transform Port instance on the event to Optical specific port, if it is well-formed.
+ *
+ * @param event original event to transform
+ * @return transformed {@link DeviceEvent}
+ */
+ public DeviceEvent augment(DeviceEvent event) {
+ final Port port = augment(event.port());
+ if (port == event.port()) {
+ // If the Port not changed, pass through
+ return event;
+ }
+ return new DeviceEvent(event.type(), event.subject(), port, event.time());
+ }
+
+ /**
+ * Transform Port instance to Optical specific port, if it is well-formed.
+ *
+ * @param port Port instance to translate
+ * @return Optical specific port instance or original {@code port}.
+ */
+ public Port augment(Port port) {
+ if (port == null) {
+ return null;
+ }
+ return optdev.getUnchecked(port.element())
+ .map(odev -> odev.port(port))
+ .orElse(port);
+ }
+
+ @Override
+ public void addListener(DeviceListener listener) {
+ super.addListener(wrapped.computeIfAbsent(listener, OpticalDeviceListener::new));
+ }
+
+ @Override
+ public void removeListener(DeviceListener listener) {
+ DeviceListener wrappedListener = wrapped.remove(listener);
+ if (wrappedListener != null) {
+ super.removeListener(wrappedListener);
+ }
+ }
+
+
+ @Override
+ public List<Port> getPorts(DeviceId deviceId) {
+ return Lists.transform(super.getPorts(deviceId),
+ this::augment);
+ }
+
+ @Override
+ public Port getPort(DeviceId deviceId, PortNumber portNumber) {
+ return augment(super.getPort(deviceId, portNumber));
+ }
+
+
+ /**
+ * DeviceListener, which translates generic Port to optical specific Port
+ * before passing.
+ */
+ class OpticalDeviceListener implements DeviceListener {
+
+ private final DeviceListener listener;
+
+ // shallow cache to reuse transformed event in isRelevant and event call
+ private Pair<DeviceEvent, DeviceEvent> cache;
+
+ public OpticalDeviceListener(DeviceListener listener) {
+ this.listener = listener;
+ }
+
+ private DeviceEvent opticalEvent(DeviceEvent event) {
+
+ Pair<DeviceEvent, DeviceEvent> entry = cache;
+ if (entry != null && entry.getLeft() == event) {
+ return entry.getRight();
+ }
+
+ DeviceEvent opticalEvent = augment(event);
+ cache = Pair.of(event, opticalEvent);
+ return opticalEvent;
+ }
+
+ @Override
+ public boolean isRelevant(DeviceEvent event) {
+ return listener.isRelevant(opticalEvent(event));
+ }
+
+ @Override
+ public void event(DeviceEvent event) {
+ listener.event(opticalEvent(event));
+ }
+ }
+
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OtuPortHelper.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OtuPortHelper.java
new file mode 100644
index 0000000..aeac4f9
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/OtuPortHelper.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2016-present 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.net.optical.device;
+
+import static org.slf4j.LoggerFactory.getLogger;
+
+import java.util.Optional;
+
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.DefaultAnnotations.Builder;
+import org.onosproject.net.OtuSignalType;
+import org.onosproject.net.device.DefaultPortDescription;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.optical.OtuPort;
+import org.onosproject.net.optical.impl.DefaultOtuPort;
+import org.slf4j.Logger;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * OTU port related helpers.
+ */
+@Beta
+public final class OtuPortHelper {
+
+ private static final Logger log = getLogger(OtuPortHelper.class);
+
+ // Annotation keys
+ /**
+ * {@link OtuSignalType} as String.
+ */
+ private static final String SIGNAL_TYPE = "signalType";
+
+ /**
+ * Creates OTU port description based on the supplied information.
+ *
+ * @param number port number
+ * @param isEnabled port enabled state
+ * @param signalType OTU client signal type
+ */
+ public static PortDescription otuPortDescription(PortNumber number,
+ boolean isEnabled,
+ OtuSignalType signalType) {
+ return otuPortDescription(number, isEnabled, signalType, DefaultAnnotations.EMPTY);
+ }
+
+ /**
+ * Creates OTU port description based on the supplied information.
+ *
+ * @param number port number
+ * @param isEnabled port enabled state
+ * @param signalType OTU client signal type
+ * @param annotations key/value annotations map
+ */
+ public static PortDescription otuPortDescription(PortNumber number,
+ boolean isEnabled,
+ OtuSignalType signalType,
+ SparseAnnotations annotations) {
+ Builder builder = DefaultAnnotations.builder();
+ builder.putAll(annotations);
+
+ builder.set(SIGNAL_TYPE, signalType.toString());
+
+ long portSpeed = 0; // TODO specify appropriate value?
+ return new DefaultPortDescription(number,
+ isEnabled,
+ Port.Type.OTU,
+ portSpeed,
+ builder.build());
+ }
+
+ /**
+ * Creates OTU port description based on the supplied information.
+ *
+ * @param base PortDescription to get basic information from
+ * @param signalType OTU client signal type
+ * @param annotations key/value annotations map
+ */
+ public static PortDescription otuPortDescription(PortDescription base,
+ OtuSignalType signalType,
+ SparseAnnotations annotations) {
+ return otuPortDescription(base.portNumber(), base.isEnabled(), signalType, annotations);
+ }
+
+ public static Optional<OtuPort> asOtuPort(Port port) {
+ if (port instanceof OtuPort) {
+ return Optional.of((OtuPort) port);
+ }
+
+ try {
+ Annotations an = port.annotations();
+
+ OtuSignalType signalType = Enum.valueOf(OtuSignalType.class,
+ an.value(SIGNAL_TYPE));
+
+
+ // Note: OTU specific annotations is not filtered-out here.
+ // DefaultOtuPort should filter them, if necessary.
+ return Optional.of(new DefaultOtuPort(port, signalType));
+
+ } catch (NullPointerException | IllegalArgumentException e) {
+
+ log.warn("{} was not well-formed Otu port.", port, e);
+ return Optional.empty();
+ }
+ }
+
+
+ // not meant to be instantiated
+ private OtuPortHelper() {}
+
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/device/package-info.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/package-info.java
new file mode 100644
index 0000000..20b6d33
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 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.
+ */
+
+/**
+ * Optical device models.
+ */
+package org.onosproject.net.optical.device;
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/AbstractPortMapper.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/AbstractPortMapper.java
new file mode 100644
index 0000000..8162dd3
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/AbstractPortMapper.java
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2016-present 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.net.optical.device.port;
+
+import java.util.Optional;
+
+import org.onosproject.net.Port;
+
+import com.google.common.annotations.Beta;
+import com.google.common.cache.CacheBuilder;
+import com.google.common.cache.CacheLoader;
+import com.google.common.cache.LoadingCache;
+
+/**
+ * PortMapper which caches mapped Port instance.
+ */
+@Beta
+public abstract class AbstractPortMapper<P extends Port> implements PortMapper<P> {
+
+ private final LoadingCache<Port, Optional<P>> cache
+ = CacheBuilder.newBuilder()
+ .weakKeys() // use == to compare keys
+ .maximumSize(100)
+ .build(CacheLoader.from(this::mapPort));
+
+ /**
+ * {@inheritDoc}
+ *
+ * <p>
+ * Note: Subclasses should override and implement short-cut conditions
+ * and call {@code super.is(port)}.
+ */
+ @Override
+ public boolean is(Port port) {
+ return as(port).isPresent();
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * <p>
+ * Note: Subclasses should override and check if {@code port} is
+ * already of type {@code P} and directly return {@code Optional.of((P) port)},
+ * if not call {@code super.as(port)}.
+ */
+ @Override
+ public Optional<P> as(Port port) {
+ if (port == null) {
+ return Optional.empty();
+ }
+ return cache.getUnchecked(port);
+ }
+
+ /**
+ * Returns {@code port} mapped to {@code <P>}.
+ *
+ * @param port Port to map
+ * @return {@code port} mapped to {@code <P>}
+ */
+ protected abstract Optional<P> mapPort(Port port);
+
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/IdentityMapper.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/IdentityMapper.java
new file mode 100644
index 0000000..40c25af
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/IdentityMapper.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2016-present 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.net.optical.device.port;
+
+import java.util.Optional;
+
+import org.onosproject.net.Port;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * {@link PortMapper} which simply return given input.
+ */
+@Beta
+public class IdentityMapper implements PortMapper<Port> {
+
+ @Override
+ public boolean is(Port port) {
+ return true;
+ }
+
+ @Override
+ public Optional<Port> as(Port port) {
+ return Optional.of(port);
+ }
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/OchPortMapper.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/OchPortMapper.java
new file mode 100644
index 0000000..badca9d
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/OchPortMapper.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016-present 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.net.optical.device.port;
+
+import java.util.Optional;
+
+import org.onosproject.net.Port;
+import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.device.OchPortHelper;
+import org.onosproject.net.optical.impl.DefaultOchPort;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * {@link PortMapper} to handler {@link OchPort} translation.
+ */
+@Beta
+public class OchPortMapper extends AbstractPortMapper<OchPort> {
+
+ @Override
+ public boolean is(Port port) {
+ return port != null &&
+ port.type() == Port.Type.OCH &&
+ super.is(port);
+ }
+
+ @Override
+ public Optional<OchPort> as(Port port) {
+ if (port instanceof OchPort) {
+ return Optional.of((OchPort) port);
+ }
+ return super.as(port);
+ }
+
+ @Override
+ protected Optional<OchPort> mapPort(Port port) {
+ if (port instanceof OchPort) {
+ return Optional.of((OchPort) port);
+ } else if (port instanceof org.onosproject.net.OchPort) {
+ // TODO remove after deprecation of old OchPort is complete
+
+ // translate to new OchPort
+ org.onosproject.net.OchPort old = (org.onosproject.net.OchPort) port;
+ return Optional.of(new DefaultOchPort(old,
+ old.signalType(),
+ old.isTunable(),
+ old.lambda()));
+ }
+
+ return OchPortHelper.asOchPort(port);
+ }
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/OduCltPortMapper.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/OduCltPortMapper.java
new file mode 100644
index 0000000..6eeb631
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/OduCltPortMapper.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2016-present 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.net.optical.device.port;
+
+import java.util.Optional;
+
+import org.onosproject.net.Port;
+import org.onosproject.net.optical.OduCltPort;
+import org.onosproject.net.optical.device.OduCltPortHelper;
+import org.onosproject.net.optical.impl.DefaultOduCltPort;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * {@link PortMapper} to handler {@link OduCltPort} translation.
+ */
+@Beta
+public class OduCltPortMapper extends AbstractPortMapper<OduCltPort> {
+
+ @Override
+ public boolean is(Port port) {
+ return port != null &&
+ port.type() == Port.Type.ODUCLT &&
+ super.is(port);
+ }
+
+ @Override
+ public Optional<OduCltPort> as(Port port) {
+ if (port instanceof OduCltPort) {
+ return Optional.of((OduCltPort) port);
+ }
+ return super.as(port);
+ }
+
+ @Override
+ protected Optional<OduCltPort> mapPort(Port port) {
+ if (port instanceof OduCltPort) {
+ return Optional.of((OduCltPort) port);
+ } else if (port instanceof org.onosproject.net.OduCltPort) {
+ // TODO remove after deprecation of old OduCltPort is complete
+
+ // translate to new OduCltPort
+ org.onosproject.net.OduCltPort old = (org.onosproject.net.OduCltPort) port;
+ return Optional.of(new DefaultOduCltPort(old,
+ old.signalType()));
+ }
+
+ return OduCltPortHelper.asOduCltPort(port);
+ }
+
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/OmsPortMapper.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/OmsPortMapper.java
new file mode 100644
index 0000000..70a8aa9
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/OmsPortMapper.java
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2016-present 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.net.optical.device.port;
+
+import java.util.Optional;
+
+import org.onosproject.net.Port;
+import org.onosproject.net.optical.OmsPort;
+import org.onosproject.net.optical.device.OmsPortHelper;
+import org.onosproject.net.optical.impl.DefaultOmsPort;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * {@link PortMapper} to handler {@link OmsPort} translation.
+ */
+@Beta
+public class OmsPortMapper extends AbstractPortMapper<OmsPort> {
+
+ @Override
+ public boolean is(Port port) {
+ return port != null &&
+ port.type() == Port.Type.OMS &&
+ super.is(port);
+ }
+
+ @Override
+ public Optional<OmsPort> as(Port port) {
+ if (port instanceof OmsPort) {
+ return Optional.of((OmsPort) port);
+ }
+ return super.as(port);
+ }
+
+ @Override
+ protected Optional<OmsPort> mapPort(Port port) {
+ if (port instanceof OmsPort) {
+ return Optional.of((OmsPort) port);
+ } else if (port instanceof org.onosproject.net.OmsPort) {
+ // TODO remove after deprecation of old OmsPort is complete
+
+ // translate to new OmsPort
+ org.onosproject.net.OmsPort old = (org.onosproject.net.OmsPort) port;
+ return Optional.of(new DefaultOmsPort(old,
+ old.minFrequency(),
+ old.maxFrequency(),
+ old.grid()));
+ }
+
+ return OmsPortHelper.asOmsPort(port);
+ }
+
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/OtuPortMapper.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/OtuPortMapper.java
new file mode 100644
index 0000000..c70033a
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/OtuPortMapper.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016-present 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.net.optical.device.port;
+
+import java.util.Optional;
+
+import org.onosproject.net.Port;
+import org.onosproject.net.optical.OtuPort;
+import org.onosproject.net.optical.device.OtuPortHelper;
+import org.onosproject.net.optical.impl.DefaultOtuPort;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * {@link PortMapper} to handler {@link OtuPort} translation.
+ */
+@Beta
+public class OtuPortMapper extends AbstractPortMapper<OtuPort> {
+
+ @Override
+ public boolean is(Port port) {
+ return port != null &&
+ port.type() == Port.Type.OTU &&
+ super.is(port);
+ }
+
+ @Override
+ public Optional<OtuPort> as(Port port) {
+ if (port instanceof OtuPort) {
+ return Optional.of((OtuPort) port);
+ }
+ return super.as(port);
+ }
+
+ @Override
+ protected Optional<OtuPort> mapPort(Port port) {
+ if (port instanceof OtuPort) {
+ return Optional.of((OtuPort) port);
+ } else if (port instanceof org.onosproject.net.OtuPort) {
+ // TODO remove after deprecation of old OtuPort is complete
+
+ // translate to new OtuPort
+ org.onosproject.net.OtuPort old = (org.onosproject.net.OtuPort) port;
+ return Optional.of(new DefaultOtuPort(old,
+ old.signalType()));
+ }
+
+ return OtuPortHelper.asOtuPort(port);
+ }
+
+
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/PortMapper.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/PortMapper.java
new file mode 100644
index 0000000..90da7ae
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/PortMapper.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2016-present 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.net.optical.device.port;
+
+import java.util.Optional;
+
+import org.onosproject.net.Port;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Abstraction of a class capable of translating generic-Port object
+ * as another domain-specific Port of type {@code P}.
+ *
+ * @param <P> Port type to map generic Port to
+ */
+@Beta
+public interface PortMapper<P extends Port> {
+
+ /**
+ * Returns true if this port is capable of being projected as {@code <P>}.
+ */
+ boolean is(Port port);
+
+ /**
+ * Returns {@code port} mapped to {@code <P>}.
+ *
+ * @param port Port to map
+ * @return {@code port} mapped to {@code <P>}
+ */
+ Optional<P> as(Port port);
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/package-info.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/package-info.java
new file mode 100644
index 0000000..4b53003
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/device/port/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2016-present 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.
+ */
+/**
+ * Optical device port related utilities.
+ */
+package org.onosproject.net.optical.device.port;
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/DefaultOchPort.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/DefaultOchPort.java
new file mode 100644
index 0000000..593b021
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/DefaultOchPort.java
@@ -0,0 +1,145 @@
+/*
+ * Copyright 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.net.optical.impl;
+
+import org.onosproject.net.Annotations;
+import org.onosproject.net.OchSignal;
+import org.onosproject.net.OduSignalType;
+import org.onosproject.net.Port;
+import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.utils.ForwardingPort;
+
+import com.google.common.annotations.Beta;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+/**
+ * Implementation of OCh port (Optical Channel).
+ * Also referred to as a line side port (L-port) or narrow band port.
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
+ */
+@Beta
+public class DefaultOchPort extends ForwardingPort implements OchPort {
+
+ // Note: try to avoid direct access to the field, use accessor.
+ // We might want to lazily parse annotation in the future
+ private final OduSignalType signalType;
+ private final boolean isTunable;
+ private final OchSignal lambda;
+
+ /**
+ * Creates an OCh port in the specified network element.
+ *
+ * @param base Port
+ * @param signalType ODU signal type
+ * @param isTunable tunable wavelength capability
+ * @param lambda OCh signal
+ */
+ public DefaultOchPort(Port base,
+ OduSignalType signalType,
+ boolean isTunable,
+ OchSignal lambda) {
+ super(base);
+ // TODO should this class be parsing annotation to instantiate signalType?
+ this.signalType = checkNotNull(signalType);
+ this.isTunable = isTunable;
+ this.lambda = checkNotNull(lambda);
+ }
+
+ @Override
+ public Type type() {
+ return Type.OCH;
+ }
+
+ @Override
+ public long portSpeed() {
+ return signalType.bitRate();
+ }
+
+
+ @Override
+ public Annotations annotations() {
+ // FIXME Filter OCh annotations, after confirming that
+ // it'll not result in information-loss
+ return super.annotations();
+ }
+
+ /**
+ * Returns ODU signal type.
+ *
+ * @return ODU signal type
+ */
+ @Override
+ public OduSignalType signalType() {
+ return signalType;
+ }
+
+ /**
+ * Returns true if port is wavelength tunable.
+ *
+ * @return tunable wavelength capability
+ */
+ @Override
+ public boolean isTunable() {
+ return isTunable;
+ }
+
+ /**
+ * Returns OCh signal.
+ *
+ * @return OCh signal
+ */
+ @Override
+ public OchSignal lambda() {
+ return lambda;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(),
+ signalType(),
+ isTunable(),
+ lambda());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj != null && getClass() == obj.getClass()) {
+ final DefaultOchPort that = (DefaultOchPort) obj;
+ return super.toEqualsBuilder(that)
+ .append(this.signalType(), that.signalType())
+ .append(this.isTunable(), that.isTunable())
+ .append(this.lambda(), that.lambda())
+ .isEquals();
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return super.toStringHelper()
+ .add("signalType", signalType())
+ .add("isTunable", isTunable())
+ .add("lambda", lambda())
+ .toString();
+ }
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/DefaultOduCltPort.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/DefaultOduCltPort.java
new file mode 100644
index 0000000..78a4266
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/DefaultOduCltPort.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2016-present 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.net.optical.impl;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onosproject.net.CltSignalType;
+import org.onosproject.net.Port;
+import org.onosproject.net.optical.OduCltPort;
+import org.onosproject.net.utils.ForwardingPort;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Implementation of ODU client port (Optical channel Data Unit).
+ * Also referred to as a T-port or wide band port.
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
+ */
+@Beta
+public class DefaultOduCltPort extends ForwardingPort implements OduCltPort {
+
+ private final CltSignalType signalType;
+
+ /**
+ * Creates an ODU client port.
+ *
+ * @param delegate Port
+ * @param signalType ODU client signal type
+ */
+ public DefaultOduCltPort(Port delegate, CltSignalType signalType) {
+ super(delegate);
+ this.signalType = checkNotNull(signalType);
+ }
+
+ @Override
+ public Type type() {
+ return Type.ODUCLT;
+ }
+
+ @Override
+ public long portSpeed() {
+ return signalType().bitRate();
+ }
+
+ @Override
+ public CltSignalType signalType() {
+ return signalType;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(),
+ signalType());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj != null && getClass() == obj.getClass()) {
+ final DefaultOduCltPort that = (DefaultOduCltPort) obj;
+ return super.toEqualsBuilder(that)
+ .append(this.signalType(), that.signalType())
+ .isEquals();
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return super.toStringHelper()
+ .add("signalType", signalType())
+ .toString();
+ }
+
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/DefaultOmsPort.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/DefaultOmsPort.java
new file mode 100644
index 0000000..eb2c426
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/DefaultOmsPort.java
@@ -0,0 +1,118 @@
+/*
+ * Copyright 2016-present 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.net.optical.impl;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onlab.util.Frequency;
+import org.onosproject.net.Port;
+import org.onosproject.net.optical.OmsPort;
+import org.onosproject.net.utils.ForwardingPort;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Implementation of OMS port (Optical Multiplexing Section).
+ * Also referred to as a WDM port or W-port.
+ * See ITU G.709 "Interfaces for the Optical Transport Network (OTN)"
+ *
+ * Assumes we only support fixed grid for now.
+ */
+@Beta
+public class DefaultOmsPort extends ForwardingPort implements OmsPort {
+
+ private final Frequency minFrequency; // Minimum frequency
+ private final Frequency maxFrequency; // Maximum frequency
+ private final Frequency grid; // Grid spacing frequency
+
+ /**
+ * Creates an OMS port.
+ *
+ * @param delegate Port
+ * @param minFrequency minimum frequency
+ * @param maxFrequency maximum frequency
+ * @param grid grid spacing frequency
+ */
+ public DefaultOmsPort(Port delegate, Frequency minFrequency, Frequency maxFrequency, Frequency grid) {
+ super(delegate);
+
+ this.minFrequency = checkNotNull(minFrequency);
+ this.maxFrequency = checkNotNull(maxFrequency);
+ this.grid = checkNotNull(grid);
+ }
+
+ @Override
+ public Type type() {
+ return Type.OMS;
+ }
+
+ @Override
+ public long portSpeed() {
+ return 0;
+ }
+
+ @Override
+ public Frequency minFrequency() {
+ return minFrequency;
+ }
+
+ @Override
+ public Frequency maxFrequency() {
+ return maxFrequency;
+ }
+
+ @Override
+ public Frequency grid() {
+ return grid;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(),
+ minFrequency(),
+ maxFrequency(),
+ grid());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj != null && getClass() == obj.getClass()) {
+ final DefaultOmsPort that = (DefaultOmsPort) obj;
+ return super.toEqualsBuilder(that)
+ .append(this.minFrequency(), that.minFrequency())
+ .append(this.maxFrequency(), that.maxFrequency())
+ .append(this.grid(), that.grid())
+ .isEquals();
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return super.toStringHelper()
+ .add("minFrequency", minFrequency())
+ .add("maxFrequency", maxFrequency())
+ .add("grid", grid())
+ .toString();
+ }
+
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/DefaultOtuPort.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/DefaultOtuPort.java
new file mode 100644
index 0000000..2c038c8
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/DefaultOtuPort.java
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2016-present 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.net.optical.impl;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Objects;
+
+import org.onosproject.net.OtuSignalType;
+import org.onosproject.net.Port;
+import org.onosproject.net.optical.OtuPort;
+import org.onosproject.net.utils.ForwardingPort;
+
+import com.google.common.annotations.Beta;
+
+/**
+ * Implementation of OTU port (Optical channel Transport Unit).
+ *
+ */
+@Beta
+public class DefaultOtuPort extends ForwardingPort implements OtuPort {
+
+ private final OtuSignalType signalType;
+
+ /**
+ * Creates an ODU client port.
+ *
+ * @param delegate Port
+ * @param signalType OTU signal type
+ */
+ public DefaultOtuPort(Port delegate, OtuSignalType signalType) {
+ super(delegate);
+ this.signalType = checkNotNull(signalType);
+ }
+
+ @Override
+ public Type type() {
+ return Type.OTU;
+ }
+
+// @Override
+// public long portSpeed() {
+// return signalType().bitRate();
+// }
+
+ @Override
+ public OtuSignalType signalType() {
+ return signalType;
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(super.hashCode(),
+ signalType());
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+
+ if (obj != null && getClass() == obj.getClass()) {
+ final DefaultOtuPort that = (DefaultOtuPort) obj;
+ return super.toEqualsBuilder(that)
+ .append(this.signalType(), that.signalType())
+ .isEquals();
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return super.toStringHelper()
+ .add("signalType", signalType())
+ .toString();
+ }
+
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/package-info.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/package-info.java
new file mode 100644
index 0000000..8542c62
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/impl/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * Copyright 2016 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.
+ */
+
+// Note: All classes in this package is expected to be instance local, and
+// are not expected to be serialized (by Kryo, etc.)
+/**
+ * Implementation of Optical augmentation classes.
+ */
+package org.onosproject.net.optical.impl;
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/json/OchSignalCodec.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/json/OchSignalCodec.java
new file mode 100644
index 0000000..0fba4fa
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/json/OchSignalCodec.java
@@ -0,0 +1,90 @@
+/*
+ * Copyright 2016 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.net.optical.json;
+
+import static com.google.common.base.Preconditions.checkArgument;
+
+import org.onosproject.net.ChannelSpacing;
+import org.onosproject.net.GridType;
+import org.onosproject.net.OchSignal;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.google.common.annotations.Beta;
+
+// TODO define common interface for JsonCodec for annotation?
+// unlike existing JsonCodec, this use-case requires that encode/decode is
+// reversible. (e.g., obj.equals(decode(encode(obj))))
+/**
+ * JSON codec for OchSignal.
+ */
+@Beta
+public abstract class OchSignalCodec {
+
+ // TODO should probably use shared mapper across optical codecs.
+ private static final ObjectMapper MAPPER = new ObjectMapper();
+
+ /**
+ * Creates an instance of {@link OchSignal} from JSON representation.
+ *
+ * @param obj JSON Object representing OchSignal
+ * @return OchSignal
+ * @throws IllegalArgumentException - if JSON object is ill-formed
+ * @see OchSignalCodec#encode(OchSignal)
+ */
+ public static OchSignal decode(ObjectNode obj) {
+ final GridType gridType;
+ final ChannelSpacing channelSpacing;
+ final int spacingMultiplier;
+ final int slotGranularity;
+
+ String s;
+ s = obj.get("channelSpacing").textValue();
+ checkArgument(s != null, "ill-formed channelSpacing");
+ channelSpacing = Enum.valueOf(ChannelSpacing.class, s);
+
+ s = obj.get("gridType").textValue();
+ checkArgument(s != null, "ill-formed gridType");
+ gridType = Enum.valueOf(GridType.class, s);
+
+ JsonNode node;
+ node = obj.get("spacingMultiplier");
+ checkArgument(node.canConvertToInt(), "ill-formed spacingMultiplier");
+ spacingMultiplier = node.asInt();
+
+ node = obj.get("slotGranularity");
+ checkArgument(node.canConvertToInt(), "ill-formed slotGranularity");
+ slotGranularity = node.asInt();
+
+ return new OchSignal(gridType, channelSpacing, spacingMultiplier, slotGranularity);
+ }
+
+ /**
+ * Returns a JSON Object representation of this instance.
+ *
+ * @return JSON Object representing OchSignal
+ */
+ public static ObjectNode encode(OchSignal j) {
+ ObjectNode obj = MAPPER.createObjectNode();
+ obj.put("channelSpacing", j.channelSpacing().toString());
+ obj.put("gridType", j.gridType().toString());
+ obj.put("slotGranularity", j.slotGranularity());
+ obj.put("spacingMultiplier", j.spacingMultiplier());
+ return obj;
+ }
+
+}
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/json/package-info.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/json/package-info.java
new file mode 100644
index 0000000..93f2ed3
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/json/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2016 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.
+ */
+
+/**
+ * JSON related utilities.
+ */
+package org.onosproject.net.optical.json;
diff --git a/apps/optical-model/src/main/java/org/onosproject/net/optical/package-info.java b/apps/optical-model/src/main/java/org/onosproject/net/optical/package-info.java
new file mode 100644
index 0000000..fbb4d4e
--- /dev/null
+++ b/apps/optical-model/src/main/java/org/onosproject/net/optical/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2016 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.
+ */
+
+// Note: this package sub-tree will be moved out from onos-api bundle soon.
+/**
+ * Optical augmentation classes.
+ */
+package org.onosproject.net.optical;
diff --git a/apps/optical-model/src/test/java/org/onosproject/net/optical/device/OmsPortHelperTest.java b/apps/optical-model/src/test/java/org/onosproject/net/optical/device/OmsPortHelperTest.java
new file mode 100644
index 0000000..6a309aa
--- /dev/null
+++ b/apps/optical-model/src/test/java/org/onosproject/net/optical/device/OmsPortHelperTest.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2016-present 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.net.optical.device;
+
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+
+import java.util.Optional;
+
+import org.junit.Test;
+import org.onlab.packet.ChassisId;
+import org.onlab.util.Frequency;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DefaultDevice;
+import org.onosproject.net.DefaultPort;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.SparseAnnotations;
+import org.onosproject.net.device.PortDescription;
+import org.onosproject.net.optical.OmsPort;
+import org.onosproject.net.Device.Type;
+import org.onosproject.net.provider.ProviderId;
+
+/**
+ * Tests for {@link OmsPortHelper}.
+ */
+public class OmsPortHelperTest {
+
+ private static final ProviderId PID = new ProviderId("test", "id");
+ private static final DeviceId DID = DeviceId.deviceId("test:00123");
+ private static final String MFC = "MFC";
+ private static final String HW = "HW V";
+ private static final String SW = "SW V";
+ private static final String SER = "SER";
+ private static final ChassisId CHS = new ChassisId(42);
+ private static final Annotations DEV_ANON = DefaultAnnotations.EMPTY;
+ private static final Device DEV = new DefaultDevice(PID, DID, Type.ROADM, MFC, HW, SW, SER, CHS, DEV_ANON);
+
+
+ @Test
+ public void testOmsPortDescriptionCanBeConvertedToOmsPort() {
+ PortNumber pn = PortNumber.portNumber(4900);
+
+ boolean isEnabled = true;
+ String anKey = "Base";
+ String anValue = "value";
+ SparseAnnotations an = DefaultAnnotations.builder()
+ .set(anKey, anValue)
+ .build();
+
+ Frequency minF = Frequency.ofGHz(3);
+ Frequency maxF = Frequency.ofGHz(33);
+ Frequency grid = Frequency.ofGHz(2);
+
+ PortDescription portDescription = OmsPortHelper.omsPortDescription(pn, isEnabled, minF, maxF, grid, an);
+ Port port = new DefaultPort(DEV,
+ portDescription.portNumber(),
+ portDescription.isEnabled(),
+ portDescription.type(),
+ portDescription.portSpeed(),
+ portDescription.annotations());
+
+ Optional<OmsPort> maybeOms = OmsPortHelper.asOmsPort(port);
+ assertTrue(maybeOms.isPresent());
+
+ OmsPort oms = maybeOms.get();
+
+ assertThat(oms.isEnabled(), is(isEnabled));
+ assertThat(oms.number(), is(pn));
+ assertThat(oms.annotations().value(anKey), is(anValue));
+
+ assertThat("type is always OMS", oms.type(), is(Port.Type.OMS));
+ assertThat("port speed is undefined", oms.portSpeed(), is(equalTo(0L)));
+
+ assertThat(oms.maxFrequency(), is(maxF));
+ assertThat(oms.minFrequency(), is(minF));
+ assertThat(oms.grid(), is(grid));
+ assertThat("((33-3)/2)+1 = 16", oms.totalChannels(), is((short) 16));
+ }
+
+}
diff --git a/apps/optical-model/src/test/java/org/onosproject/net/optical/impl/DefaultOmsPortTest.java b/apps/optical-model/src/test/java/org/onosproject/net/optical/impl/DefaultOmsPortTest.java
new file mode 100644
index 0000000..a09d5ec
--- /dev/null
+++ b/apps/optical-model/src/test/java/org/onosproject/net/optical/impl/DefaultOmsPortTest.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright 2016-present 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.net.optical.impl;
+
+import static org.hamcrest.Matchers.*;
+import static org.junit.Assert.*;
+import static org.onosproject.net.PortNumber.portNumber;
+
+import org.junit.Test;
+import org.onlab.packet.ChassisId;
+import org.onlab.util.Frequency;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.DefaultDevice;
+import org.onosproject.net.DefaultPort;
+import org.onosproject.net.Device;
+import org.onosproject.net.Device.Type;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.optical.OmsPort;
+import org.onosproject.net.provider.ProviderId;
+
+import com.google.common.testing.EqualsTester;
+
+/**
+ * Tests for {@link DefaultOmsPort}.
+ */
+public class DefaultOmsPortTest {
+
+ private static final ProviderId PID = new ProviderId("test", "id");
+ private static final DeviceId DID = DeviceId.deviceId("test:00123");
+ private static final String MFC = "MFC";
+ private static final String HW = "HW V";
+ private static final String SW = "SW V";
+ private static final String SER = "SER";
+ private static final ChassisId CHS = new ChassisId(42);
+ private static final Annotations DEV_ANON = DefaultAnnotations.EMPTY;
+ private static final Device DEV = new DefaultDevice(PID, DID, Type.ROADM, MFC, HW, SW, SER, CHS, DEV_ANON);
+
+ @Test
+ public void testEquality() {
+ PortNumber pn = PortNumber.portNumber(4900);
+ Annotations an = DefaultAnnotations.builder()
+ .set("Base", "value")
+ .build();
+ Annotations an2 = DefaultAnnotations.builder()
+ .set("Base", "value2")
+ .build();
+
+ Port base = new DefaultPort(DEV, pn, true, Port.Type.VIRTUAL, 2, an);
+ Frequency minF = Frequency.ofGHz(3);
+ Frequency maxF = Frequency.ofGHz(33);
+ Frequency grid = Frequency.ofGHz(2);
+
+ // reference OMS port
+ OmsPort oms = new DefaultOmsPort(base, minF, maxF, grid);
+
+ new EqualsTester()
+ .addEqualityGroup(oms,
+ // different base port type or portspeed is ignored
+ new DefaultOmsPort(new DefaultPort(DEV, pn, true, an), minF, maxF, grid))
+ // different port number
+ .addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, portNumber(1), true, an), minF, maxF, grid))
+ // different isEnabled
+ .addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, pn, false, an), minF, maxF, grid))
+ // different annotation
+ .addEqualityGroup(new DefaultOmsPort(new DefaultPort(DEV, pn, true, an2), minF, maxF, grid))
+ // different minFreq
+ .addEqualityGroup(new DefaultOmsPort(base, Frequency.ofKHz(3), maxF, grid))
+ // different maxFreq
+ .addEqualityGroup(new DefaultOmsPort(base, minF, Frequency.ofKHz(33), grid))
+ // different grid
+ .addEqualityGroup(new DefaultOmsPort(base, minF, maxF, Frequency.ofKHz(2)))
+ .testEquals();
+
+ }
+
+ @Test
+ public void basicTests() {
+ PortNumber pn = PortNumber.portNumber(4900);
+ Annotations annotations = DefaultAnnotations.builder()
+ .set("Base", "value")
+ .build();
+
+ boolean isEnabled = true;
+ Port base = new DefaultPort(DEV, pn, isEnabled, Port.Type.VIRTUAL, 2, annotations);
+ Frequency minFrequency = Frequency.ofGHz(3);
+ Frequency maxFrequency = Frequency.ofGHz(33);
+ Frequency grid = Frequency.ofGHz(2);
+ OmsPort oms = new DefaultOmsPort(base, minFrequency, maxFrequency, grid);
+
+ // basic attributes and annotations are inherited from base
+ assertThat(oms.element(), is(DEV));
+ assertThat(oms.isEnabled(), is(isEnabled));
+ assertThat(oms.number(), is(pn));
+ assertThat(oms.annotations(), is(annotations));
+
+ assertThat("type is always OMS", oms.type(), is(Port.Type.OMS));
+ assertThat("port speed is undefined", oms.portSpeed(), is(equalTo(0L)));
+
+ assertThat(oms.maxFrequency(), is(maxFrequency));
+ assertThat(oms.minFrequency(), is(minFrequency));
+ assertThat(oms.grid(), is(grid));
+ assertThat("((33-3)/2)+1 = 16", oms.totalChannels(), is((short) 16));
+ }
+
+}
diff --git a/apps/optical/BUCK b/apps/optical/BUCK
index 49a3743..c70cbb8 100644
--- a/apps/optical/BUCK
+++ b/apps/optical/BUCK
@@ -1,5 +1,6 @@
COMPILE_DEPS = [
'//lib:CORE_DEPS',
+ '//apps/optical-model:onos-apps-optical-model',
]
osgi_jar_with_tests (
@@ -11,4 +12,5 @@
category = 'Traffic Steering',
url = 'http://onosproject.org',
description = 'Packet/Optical use-case application.',
+ required_apps = [ 'org.onosproject.optical-model' ],
)
diff --git a/apps/optical/pom.xml b/apps/optical/pom.xml
index 08d0937..afda139 100644
--- a/apps/optical/pom.xml
+++ b/apps/optical/pom.xml
@@ -36,11 +36,19 @@
<onos.app.category>Traffic Steering</onos.app.category>
<onos.app.url>http://onosproject.org</onos.app.url>
<onos.app.readme>Packet/Optical use-case application.</onos.app.readme>
+ <onos.app.requires>
+ org.onosproject.optical-model
+ </onos.app.requires>
</properties>
<dependencies>
<dependency>
<groupId>org.onosproject</groupId>
+ <artifactId>onos-optical-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.onosproject</groupId>
<artifactId>onos-cli</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/apps/pom.xml b/apps/pom.xml
index 887199f..fdc7e53 100644
--- a/apps/pom.xml
+++ b/apps/pom.xml
@@ -34,6 +34,7 @@
<module>mobility</module>
<module>proxyarp</module>
<module>sdnip</module>
+ <module>optical-model</module>
<module>optical</module>
<module>newoptical</module>
<module>metrics</module>