Add Optical ODU cross-connect Intent

Create a new intent: OpticalOduIntent in the OTN Topology.
 - This intent finds a path of OTU links, and
 - Allocates TributarySlots resources on the OTU ports (in the path)
 - also add a utility for converting various SignalTypes to
   OduSignalType, and to build the OduSignalId.

Note: this patch follows the example given in patch
https://gerrit.onosproject.org/#/c/7321 of
separate resource search from resource allocation.

Change-Id: Id9808f61aebb80a21481f3882aff23b236b68078
diff --git a/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java b/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java
index e1ef13f..346e315 100644
--- a/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/AddOpticalIntentCommand.java
@@ -20,6 +20,7 @@
 import org.apache.karaf.shell.commands.Option;
 import org.onosproject.net.CltSignalType;
 import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.Device;
 import org.onosproject.net.OchPort;
 import org.onosproject.net.OduCltPort;
 import org.onosproject.net.DeviceId;
@@ -30,6 +31,7 @@
 import org.onosproject.net.intent.IntentService;
 import org.onosproject.net.intent.OpticalCircuitIntent;
 import org.onosproject.net.intent.OpticalConnectivityIntent;
+import org.onosproject.net.intent.OpticalOduIntent;
 
 import java.util.List;
 
@@ -96,27 +98,52 @@
         Port dstPort = deviceService.getPort(egress.deviceId(), egress.port());
 
         Intent intent;
-        // FIXME: Hardcoded signal types
+
         if (srcPort instanceof OduCltPort && dstPort instanceof OduCltPort) {
-            intent = OpticalCircuitIntent.builder()
-                    .appId(appId())
-                    .key(key())
-                    .src(ingress)
-                    .dst(egress)
-                    .signalType(CltSignalType.CLT_10GBE)
-                    .bidirectional(bidirectional)
-                    .build();
+            Device srcDevice = deviceService.getDevice(ingress.deviceId());
+            Device dstDevice = deviceService.getDevice(egress.deviceId());
+
+            // continue only if both OduClt port's Devices are of the same type
+            if (!(srcDevice.type().equals(dstDevice.type()))) {
+                print("Devices without same deviceType: SRC=%s and DST=%s", srcDevice.type(), dstDevice.type());
+                return;
+            }
+
+            CltSignalType signalType = ((OduCltPort) srcPort).signalType();
+            if (Device.Type.ROADM.equals(srcDevice.type())) {
+                intent = OpticalCircuitIntent.builder()
+                        .appId(appId())
+                        .key(key())
+                        .src(ingress)
+                        .dst(egress)
+                        .signalType(signalType)
+                        .bidirectional(bidirectional)
+                        .build();
+            } else if (Device.Type.OTN.equals(srcDevice.type())) {
+                intent = OpticalOduIntent.builder()
+                        .appId(appId())
+                        .key(key())
+                        .src(ingress)
+                        .dst(egress)
+                        .signalType(signalType)
+                        .bidirectional(bidirectional)
+                        .build();
+            } else {
+                print("Wrong Device Type for connect points %s and %s", ingress, egress);
+                return;
+            }
         } else if (srcPort instanceof OchPort && dstPort instanceof OchPort) {
+            OduSignalType signalType = ((OchPort) srcPort).signalType();
             intent = OpticalConnectivityIntent.builder()
                     .appId(appId())
                     .key(key())
                     .src(ingress)
                     .dst(egress)
-                    .signalType(OduSignalType.ODU4)
+                    .signalType(signalType)
                     .bidirectional(bidirectional)
                     .build();
         } else {
-            print("Unable to create optical intent between connect points {} and {}", ingress, egress);
+            print("Unable to create optical intent between connect points %s and %s", ingress, egress);
             return;
         }
 
diff --git a/cli/src/main/java/org/onosproject/cli/net/IntentsListCommand.java b/cli/src/main/java/org/onosproject/cli/net/IntentsListCommand.java
index 3bed89b..7baabe1 100644
--- a/cli/src/main/java/org/onosproject/cli/net/IntentsListCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/IntentsListCommand.java
@@ -29,6 +29,7 @@
 import org.onosproject.net.intent.MultiPointToSinglePointIntent;
 import org.onosproject.net.intent.OpticalCircuitIntent;
 import org.onosproject.net.intent.OpticalConnectivityIntent;
+import org.onosproject.net.intent.OpticalOduIntent;
 import org.onosproject.net.intent.PathIntent;
 import org.onosproject.net.intent.PointToPointIntent;
 import org.onosproject.net.intent.SinglePointToMultiPointIntent;
@@ -118,6 +119,7 @@
         private IntentSummary summaryLinkCollection;
         private IntentSummary summaryOpticalCircuit;
         private IntentSummary summaryOpticalConnectivity;
+        private IntentSummary summaryOpticalOdu;
         private IntentSummary summaryUnknownType;
 
         /**
@@ -136,6 +138,7 @@
             summaryLinkCollection = new IntentSummary("LinkCollection");
             summaryOpticalCircuit = new IntentSummary("OpticalCircuit");
             summaryOpticalConnectivity = new IntentSummary("OpticalConnectivity");
+            summaryOpticalOdu = new IntentSummary("OpticalOdu");
             summaryUnknownType = new IntentSummary("UnknownType");
         }
 
@@ -196,6 +199,10 @@
                     summaryOpticalConnectivity.update(intentState);
                     continue;
                 }
+                if (intent instanceof OpticalOduIntent) {
+                    summaryOpticalOdu.update(intentState);
+                    continue;
+                }
                 summaryUnknownType.update(intentState);
             }
         }
@@ -219,6 +226,7 @@
             result.set("linkCollection", summaryLinkCollection.json(mapper));
             result.set("opticalCircuit", summaryOpticalCircuit.json(mapper));
             result.set("opticalConnectivity", summaryOpticalConnectivity.json(mapper));
+            result.set("opticalOdu", summaryOpticalOdu.json(mapper));
             result.set("unknownType", summaryUnknownType.json(mapper));
             result.set("all", summaryAll.json(mapper));
             return result;
@@ -237,6 +245,7 @@
             summaryLinkCollection.printState();
             summaryOpticalCircuit.printState();
             summaryOpticalConnectivity.printState();
+            summaryOpticalOdu.printState();
             summaryUnknownType.printState();
             summaryAll.printState();
         }
@@ -401,6 +410,9 @@
         } else if (intent instanceof OpticalConnectivityIntent) {
             OpticalConnectivityIntent ci = (OpticalConnectivityIntent) intent;
             print("    src=%s, dst=%s", ci.getSrc(), ci.getDst());
+        } else if (intent instanceof OpticalOduIntent) {
+            OpticalOduIntent ci = (OpticalOduIntent) intent;
+            print("    src=%s, dst=%s", ci.getSrc(), ci.getDst());
         }
 
         List<Intent> installable = service.getInstallableIntents(intent.key());
diff --git a/core/api/src/main/java/org/onosproject/net/OduSignalUtils.java b/core/api/src/main/java/org/onosproject/net/OduSignalUtils.java
new file mode 100644
index 0000000..26eb143
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/OduSignalUtils.java
@@ -0,0 +1,89 @@
+/*
+ * 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;
+
+import java.util.Set;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Collection of helper methods to convert various SignalTypes to OduSignalType, and to build OduSignalId.
+ */
+public final class OduSignalUtils {
+
+    private static final Logger log = LoggerFactory.getLogger(OduSignalUtils.class);
+
+    // prohibit instantiation
+    private OduSignalUtils() {}
+
+    /**
+     * Maps from OduClt SignalType to OduSignalType.
+     *
+     * @param cltSignalType OduClt port signal type
+     * @return OduSignalType the result of mapping CltSignalType to OduSignalType
+     */
+    public static OduSignalType mappingCltSignalTypeToOduSignalType(CltSignalType cltSignalType) {
+        switch (cltSignalType) {
+            case CLT_1GBE:
+                return OduSignalType.ODU0;
+            case CLT_10GBE:
+                return OduSignalType.ODU2;
+            case CLT_40GBE:
+                return OduSignalType.ODU3;
+            case CLT_100GBE:
+                return OduSignalType.ODU4;
+            default:
+                log.error("Unsupported CltSignalType {}", cltSignalType);
+                return OduSignalType.ODU0;
+        }
+    }
+
+    /**
+     * Maps from OtuPort SignalType to OduSignalType.
+     *
+     * @param otuSignalType Otu port signal type
+     * @return OduSignalType the result of mapping OtuSignalType to OduSignalType
+     */
+    public static OduSignalType mappingOtuSignalTypeToOduSignalType(OtuSignalType otuSignalType) {
+        switch (otuSignalType) {
+        case OTU2:
+            return OduSignalType.ODU2;
+        case OTU4:
+            return OduSignalType.ODU4;
+        default:
+            log.error("Unsupported OtuSignalType {}", otuSignalType);
+            return OduSignalType.ODU0;
+        }
+    }
+
+    /**
+     * Creates OduSignalId from OduSignalType and TributarySlots.
+     * @param oduSignalType - OduSignalType
+     * @param slots - a set of TributarySlots
+     * @return OduSignalId
+     */
+    public static OduSignalId buildOduSignalId(OduSignalType oduSignalType, Set<TributarySlot> slots) {
+        int tributaryPortNumber = (int) slots.stream().findFirst().get().index();
+        int tributarySlotLen = oduSignalType.tributarySlots();
+        byte[] tributarySlotBitmap = new byte[OduSignalId.TRIBUTARY_SLOT_BITMAP_SIZE];
+
+        slots.forEach(ts -> tributarySlotBitmap[(byte) (ts.index() - 1) / 8] |= 0x1 << ((ts.index() - 1) % 8));
+        return OduSignalId.oduSignalId(tributaryPortNumber, tributarySlotLen, tributarySlotBitmap);
+    }
+
+}
\ No newline at end of file
diff --git a/core/api/src/main/java/org/onosproject/net/intent/OpticalOduIntent.java b/core/api/src/main/java/org/onosproject/net/intent/OpticalOduIntent.java
new file mode 100644
index 0000000..361cb03
--- /dev/null
+++ b/core/api/src/main/java/org/onosproject/net/intent/OpticalOduIntent.java
@@ -0,0 +1,223 @@
+/*
+ * 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.intent;
+
+import com.google.common.annotations.Beta;
+import com.google.common.base.MoreObjects;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.net.CltSignalType;
+import org.onosproject.net.ConnectPoint;
+
+import java.util.Collections;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+/**
+ * An optical layer intent between two OduClt ports - in an OTN Topology.
+ * No traffic selector or traffic treatment are needed.
+ */
+@Beta
+public final class OpticalOduIntent extends Intent {
+    private final ConnectPoint src;
+    private final ConnectPoint dst;
+    private final CltSignalType signalType;
+    private final boolean isBidirectional;
+
+    /**
+     * Creates an optical ODU intent between the specified connection points.
+     *
+     * @param appId application identification
+     * @param key intent key
+     * @param src the source transponder port
+     * @param dst the destination transponder port
+     * @param signalType CltSignalType signal type
+     * @param isBidirectional indicate if intent is bidirectional
+     * @param priority priority to use for flows from this intent
+     */
+    protected OpticalOduIntent(ApplicationId appId,
+                                        Key key,
+                                        ConnectPoint src,
+                                        ConnectPoint dst,
+                                        CltSignalType signalType,
+                                        boolean isBidirectional,
+                                        int priority) {
+        super(appId, key, Collections.emptyList(), priority);
+        this.src = checkNotNull(src);
+        this.dst = checkNotNull(dst);
+        this.signalType = checkNotNull(signalType);
+        this.isBidirectional = isBidirectional;
+    }
+
+    /**
+     * Returns a new optical ODU intent builder.
+     *
+     * @return intent builder
+     */
+    public static Builder builder() {
+        return new Builder();
+    }
+
+
+    /**
+     * Builder for optical ODU intents.
+     */
+    public static class Builder extends Intent.Builder {
+        private ConnectPoint src;
+        private ConnectPoint dst;
+        private CltSignalType signalType;
+        private boolean isBidirectional;
+
+        @Override
+        public Builder appId(ApplicationId appId) {
+            return (Builder) super.appId(appId);
+        }
+
+        @Override
+        public Builder key(Key key) {
+            return (Builder) super.key(key);
+        }
+
+        @Override
+        public Builder priority(int priority) {
+            return (Builder) super.priority(priority);
+        }
+
+        /**
+         * Sets the source for the intent that will be built.
+         *
+         * @param src source to use for built intent
+         * @return this builder
+         */
+        public Builder src(ConnectPoint src) {
+            this.src = src;
+            return this;
+        }
+
+        /**
+         * Sets the destination for the intent that will be built.
+         *
+         * @param dst dest to use for built intent
+         * @return this builder
+         */
+        public Builder dst(ConnectPoint dst) {
+            this.dst = dst;
+            return this;
+        }
+
+        /**
+         * Sets the ODU signal type for the intent that will be built.
+         *
+         * @param signalType signal type to use for built intent
+         * @return this builder
+         */
+        public Builder signalType(CltSignalType signalType) {
+            this.signalType = signalType;
+            return this;
+        }
+
+        /**
+         * Sets the directionality of the intent.
+         *
+         * @param isBidirectional true if bidirectional, false if unidirectional
+         * @return this builder
+         */
+        public Builder bidirectional(boolean isBidirectional) {
+            this.isBidirectional = isBidirectional;
+            return this;
+        }
+
+        /**
+         * Builds an optical ODU intent from the accumulated parameters.
+         *
+         * @return point to point intent
+         */
+        public OpticalOduIntent build() {
+
+            return new OpticalOduIntent(
+                    appId,
+                    key,
+                    src,
+                    dst,
+                    signalType,
+                    isBidirectional,
+                    priority
+            );
+        }
+    }
+
+    /**
+     * Constructor for serializer.
+     */
+    protected OpticalOduIntent() {
+        super();
+        this.src = null;
+        this.dst = null;
+        this.signalType = null;
+        this.isBidirectional = false;
+    }
+
+    /**
+     * Returns the source transponder port.
+     *
+     * @return source transponder port
+     */
+    public ConnectPoint getSrc() {
+        return src;
+    }
+
+    /**
+     * Returns the destination transponder port.
+     *
+     * @return source transponder port
+     */
+    public ConnectPoint getDst() {
+        return dst;
+    }
+
+    /**
+     * Returns the CltSignalType signal type.
+     *
+     * @return CltSignalType signal type
+     */
+    public CltSignalType getSignalType() {
+        return signalType;
+    }
+
+    /**
+     * Returns the directionality of the intent.
+     *
+     * @return true if bidirectional, false if unidirectional
+     */
+    public boolean isBidirectional() {
+        return isBidirectional;
+    }
+
+    @Override
+    public String toString() {
+        return MoreObjects.toStringHelper(this)
+                .add("id", id())
+                .add("key", key())
+                .add("appId", appId())
+                .add("priority", priority())
+                .add("resources", resources())
+                .add("src", src)
+                .add("dst", dst)
+                .add("signalType", signalType)
+                .add("isBidirectional", isBidirectional)
+                .toString();
+    }
+
+}
\ No newline at end of file
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java
index b96b79b..47dd852 100644
--- a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompiler.java
@@ -36,6 +36,7 @@
 import org.onosproject.net.OduCltPort;
 import org.onosproject.net.OduSignalId;
 import org.onosproject.net.OduSignalType;
+import org.onosproject.net.OduSignalUtils;
 import org.onosproject.net.Port;
 import org.onosproject.net.TributarySlot;
 import org.onosproject.net.behaviour.TributarySlotQuery;
@@ -276,7 +277,7 @@
     }
 
     private List<Resource> availableSlotResources(ConnectPoint src, ConnectPoint dst, CltSignalType signalType) {
-        OduSignalType oduSignalType = mappingCltSignalTypeToOduSignalType(signalType);
+        OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(signalType);
         int requestedTsNum = oduSignalType.tributarySlots();
         Set<TributarySlot> commonTributarySlots = findCommonTributarySlotsOnCps(src, dst);
         if (commonTributarySlots.isEmpty()) {
@@ -339,7 +340,7 @@
                                                                     CltSignalType signalType,
                                                                     boolean multiplexingSupported) {
 
-        OduSignalType oduSignalType = mappingCltSignalTypeToOduSignalType(signalType);
+        OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(signalType);
 
         return Tools.stream(intentService.getIntents())
                 .filter(x -> x instanceof OpticalConnectivityIntent)
@@ -509,23 +510,25 @@
             OduSignalType ochPortOduSignalType;
 
             if (srcPort instanceof OduCltPort) {
-                oduCltPortOduSignalType = mappingCltSignalTypeToOduSignalType(((OduCltPort) srcPort).signalType());
+                oduCltPortOduSignalType =
+                        OduSignalUtils.mappingCltSignalTypeToOduSignalType(((OduCltPort) srcPort).signalType());
                 ochPortOduSignalType = ((OchPort) dstPort).signalType();
 
                 selectorBuilder.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
                 // use Instruction of OduSignalId only in case of ODU Multiplexing
                 if (oduCltPortOduSignalType != ochPortOduSignalType) {
-                    OduSignalId oduSignalId = buildOduSignalId(ochPortOduSignalType, slots);
+                    OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(ochPortOduSignalType, slots);
                     treatmentBuilder.add(Instructions.modL1OduSignalId(oduSignalId));
                 }
             } else { // srcPort is OchPort
-                oduCltPortOduSignalType = mappingCltSignalTypeToOduSignalType(((OduCltPort) dstPort).signalType());
+                oduCltPortOduSignalType =
+                        OduSignalUtils.mappingCltSignalTypeToOduSignalType(((OduCltPort) dstPort).signalType());
                 ochPortOduSignalType = ((OchPort) srcPort).signalType();
 
                 selectorBuilder.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
                 // use Criteria of OduSignalId only in case of ODU Multiplexing
                 if (oduCltPortOduSignalType != ochPortOduSignalType) {
-                    OduSignalId oduSignalId = buildOduSignalId(ochPortOduSignalType, slots);
+                    OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(ochPortOduSignalType, slots);
                     selectorBuilder.add(Criteria.matchOduSignalId(oduSignalId));
                 }
             }
@@ -544,19 +547,6 @@
         return flowRule;
     }
 
-    OduSignalId buildOduSignalId(OduSignalType ochPortSignalType, Set<TributarySlot> slots) {
-        int tributaryPortNumber = findFirstTributarySlotIndex(slots);
-        int tributarySlotLen = ochPortSignalType.tributarySlots();
-        byte[] tributarySlotBitmap = new byte[OduSignalId.TRIBUTARY_SLOT_BITMAP_SIZE];
-
-        slots.forEach(ts -> tributarySlotBitmap[(byte) (ts.index() - 1) / 8] |= 0x1 << ((ts.index() - 1) % 8));
-        return OduSignalId.oduSignalId(tributaryPortNumber, tributarySlotLen, tributarySlotBitmap);
-    }
-
-    private int findFirstTributarySlotIndex(Set<TributarySlot> tributarySlots) {
-        return (int) tributarySlots.stream().findFirst().get().index();
-    }
-
     private boolean isMultiplexingSupported(ConnectPoint cp) {
         Driver driver = driverService.getDriver(cp.deviceId());
         return driver != null
@@ -565,28 +555,6 @@
     }
 
     /**
-     * Maps from Intent's OduClt SignalType to OduSignalType.
-     *
-     * @param cltSignalType OduClt port signal type
-     * @return OduSignalType the result of mapping CltSignalType to OduSignalType
-     */
-    OduSignalType mappingCltSignalTypeToOduSignalType(CltSignalType cltSignalType) {
-        switch (cltSignalType) {
-            case CLT_1GBE:
-                return OduSignalType.ODU0;
-            case CLT_10GBE:
-                return OduSignalType.ODU2;
-            case CLT_40GBE:
-                return OduSignalType.ODU3;
-            case CLT_100GBE:
-                return OduSignalType.ODU4;
-            default:
-                log.error("Unsupported CltSignalType {}", cltSignalType);
-                return OduSignalType.ODU0;
-        }
-    }
-
-    /**
      * Finds the common TributarySlots available on the two connect points.
      *
      * @param src source connect point
diff --git a/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompiler.java b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompiler.java
new file mode 100644
index 0000000..c327d58
--- /dev/null
+++ b/core/net/src/main/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompiler.java
@@ -0,0 +1,382 @@
+/*
+ * 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.intent.impl.compiler;
+
+
+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.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Link;
+import org.onosproject.net.LinkKey;
+import org.onosproject.net.OduCltPort;
+import org.onosproject.net.OduSignalId;
+import org.onosproject.net.OduSignalType;
+import org.onosproject.net.OduSignalUtils;
+import org.onosproject.net.OtuPort;
+import org.onosproject.net.Path;
+import org.onosproject.net.Port;
+import org.onosproject.net.TributarySlot;
+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.TrafficSelector;
+import org.onosproject.net.flow.TrafficTreatment;
+import org.onosproject.net.flow.criteria.Criteria;
+import org.onosproject.net.flow.instructions.Instructions;
+import org.onosproject.net.intent.FlowRuleIntent;
+import org.onosproject.net.intent.Intent;
+import org.onosproject.net.intent.IntentCompiler;
+import org.onosproject.net.intent.IntentExtensionService;
+import org.onosproject.net.intent.OpticalOduIntent;
+import org.onosproject.net.intent.impl.IntentCompilationException;
+import org.onosproject.net.resource.Resource;
+import org.onosproject.net.resource.ResourceService;
+import org.onosproject.net.resource.ResourceAllocation;
+import org.onosproject.net.resource.Resources;
+import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.Topology;
+import org.onosproject.net.topology.TopologyService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static org.onosproject.net.LinkKey.linkKey;
+
+/**
+ * An intent compiler for {@link org.onosproject.net.intent.OpticalOduIntent}.
+ */
+@Component(immediate = true)
+public class OpticalOduIntentCompiler implements IntentCompiler<OpticalOduIntent> {
+
+    private static final Logger log = LoggerFactory.getLogger(OpticalOduIntentCompiler.class);
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected IntentExtensionService intentManager;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected CoreService coreService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected TopologyService topologyService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected DeviceService deviceService;
+
+    @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY)
+    protected ResourceService resourceService;
+
+    private ApplicationId appId;
+
+    @Activate
+    public void activate() {
+        appId = coreService.registerApplication("org.onosproject.net.intent");
+        intentManager.registerCompiler(OpticalOduIntent.class, this);
+    }
+
+    @Deactivate
+    public void deactivate() {
+        intentManager.unregisterCompiler(OpticalOduIntent.class);
+    }
+
+    @Override
+    public List<Intent> compile(OpticalOduIntent intent, List<Intent> installable) {
+        // Check if ports are OduClt ports
+        ConnectPoint src = intent.getSrc();
+        ConnectPoint dst = intent.getDst();
+        Port srcPort = deviceService.getPort(src.deviceId(), src.port());
+        Port dstPort = deviceService.getPort(dst.deviceId(), dst.port());
+        checkArgument(srcPort instanceof OduCltPort);
+        checkArgument(dstPort instanceof OduCltPort);
+
+        log.debug("Compiling optical ODU intent between {} and {}", src, dst);
+
+        // Release of intent resources here is only a temporary solution for handling the
+        // case of recompiling due to intent restoration (when intent state is FAILED).
+        // TODO: try to release intent resources in IntentManager.
+        resourceService.release(intent.id());
+
+        // Check OduClt ports availability
+        Resource srcPortResource = Resources.discrete(src.deviceId(), src.port()).resource();
+        Resource dstPortResource = Resources.discrete(dst.deviceId(), dst.port()).resource();
+        // If ports are not available, compilation fails
+        if (!Stream.of(srcPortResource, dstPortResource).allMatch(resourceService::isAvailable)) {
+            throw new IntentCompilationException("Ports for the intent are not available. Intent: " + intent);
+        }
+        List<Resource> intentResources = new ArrayList<>();
+        intentResources.add(srcPortResource);
+        intentResources.add(dstPortResource);
+
+        // Calculate available light paths
+        Set<Path> paths = getOpticalPaths(intent);
+
+        if (paths.isEmpty()) {
+            throw new IntentCompilationException("Unable to find suitable lightpath for intent " + intent);
+        }
+
+        // Use first path that can be successfully reserved
+        for (Path path : paths) {
+
+            // Find available Tributary Slots on both directions of path
+            Map<LinkKey, Set<TributarySlot>> slotsMap = findAvailableTributarySlots(intent, path);
+            if (slotsMap.isEmpty()) {
+                continue;
+            }
+            List<Resource> tributarySlotResources = convertToResources(slotsMap);
+            if (!tributarySlotResources.stream().allMatch(resourceService::isAvailable)) {
+                continue;
+            }
+
+            intentResources.addAll(tributarySlotResources);
+
+            allocateResources(intent, intentResources);
+
+            List<FlowRule> rules = new LinkedList<>();
+
+            // Create rules for forward and reverse path
+            rules = createRules(intent, intent.getSrc(), intent.getDst(), path, slotsMap, false);
+            if (intent.isBidirectional()) {
+                rules.addAll(createRules(intent, intent.getDst(), intent.getSrc(), path, slotsMap, true));
+            }
+
+            return Collections.singletonList(new FlowRuleIntent(appId,
+                    rules, ImmutableSet.copyOf(path.links())));
+        }
+
+        throw new IntentCompilationException("Unable to find suitable lightpath for intent " + intent);
+    }
+
+    /**
+     * Find available TributarySlots across path.
+     *
+     * @param intent
+     * @param path path in OTU topology
+     * @return Map of Linkey and Set of available TributarySlots on its ports
+     */
+    private Map<LinkKey, Set<TributarySlot>> findAvailableTributarySlots(OpticalOduIntent intent, Path path) {
+        Set<LinkKey> linkRequest = Sets.newHashSetWithExpectedSize(path.links().size());
+        for (int i = 0; i < path.links().size(); i++) {
+            LinkKey link = linkKey(path.links().get(i));
+            linkRequest.add(link);
+        }
+
+        return findTributarySlots(intent, linkRequest);
+    }
+
+    private List<Resource> convertToResources(Map<LinkKey, Set<TributarySlot>> slotsMap) {
+       // Same TributarySlots are used for both directions
+        Set<Resource> resources = slotsMap.entrySet().stream()
+                .flatMap(x -> x.getValue()
+                        .stream()
+                        .flatMap(ts-> Stream.of(
+                                Resources.discrete(x.getKey().src().deviceId(), x.getKey().src().port())
+                                        .resource().child(ts),
+                                Resources.discrete(x.getKey().dst().deviceId(), x.getKey().dst().port())
+                                        .resource().child(ts))))
+                .collect(Collectors.toSet());
+        return (ImmutableList.copyOf(resources));
+    }
+
+    private void allocateResources(Intent intent, List<Resource> resources) {
+        // reserve all of required resources
+        List<ResourceAllocation> allocations = resourceService.allocate(intent.id(), resources);
+        if (allocations.isEmpty()) {
+            log.info("Resource allocation for {} failed (resource request: {})", intent, resources);
+            throw new IntentCompilationException("Unable to allocate resources: " + resources);
+        }
+    }
+
+    private Map<LinkKey, Set<TributarySlot>> findTributarySlots(OpticalOduIntent intent, Set<LinkKey> links) {
+        OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(intent.getSignalType());
+        int requestedTsNum = oduSignalType.tributarySlots();
+
+        Map<LinkKey, Set<TributarySlot>> slotsMap = new HashMap<>();
+        for (LinkKey link : links) {
+            Set<TributarySlot> common = findCommonTributarySlotsOnCps(link.src(), link.dst());
+            if (common.isEmpty() || (common.size() < requestedTsNum)) {
+                log.debug("Failed to find TributarySlots on link {} requestedTsNum={}", link, requestedTsNum);
+                return Collections.emptyMap(); // failed to find enough available TributarySlots on a link
+            }
+            slotsMap.put(link, common.stream()
+                                .limit(requestedTsNum)
+                                .collect(Collectors.toSet()));
+        }
+        return slotsMap;
+    }
+
+    /**
+     * Calculates optical paths in OTU topology.
+     *
+     * @param intent optical ODU intent
+     * @return set of paths in OTU topology
+     */
+    private Set<Path> getOpticalPaths(OpticalOduIntent intent) {
+        // Route in OTU topology
+        Topology topology = topologyService.currentTopology();
+
+        LinkWeight weight = edge -> {
+            // Disregard inactive or non-optical links
+            if (edge.link().state() == Link.State.INACTIVE) {
+                return -1;
+            }
+            if (edge.link().type() != Link.Type.OPTICAL) {
+                return -1;
+            }
+            // Find path with available TributarySlots resources
+            if (!isAvailableTributarySlots(intent, edge.link())) {
+                return -1;
+            }
+            return 1;
+        };
+
+        ConnectPoint start = intent.getSrc();
+        ConnectPoint end = intent.getDst();
+
+        return topologyService.getPaths(topology, start.deviceId(), end.deviceId(), weight);
+    }
+
+    private boolean isAvailableTributarySlots(OpticalOduIntent intent, Link link) {
+        OduSignalType oduSignalType = OduSignalUtils.mappingCltSignalTypeToOduSignalType(intent.getSignalType());
+        int requestedTsNum = oduSignalType.tributarySlots();
+
+        Set<TributarySlot> common = findCommonTributarySlotsOnCps(link.src(), link.dst());
+        if (common.isEmpty() || (common.size() < requestedTsNum)) {
+            log.debug("Not enough available TributarySlots on link {} requestedTsNum={}", link, requestedTsNum);
+            return false;
+        }
+        return true;
+    }
+
+    /**
+     * Create rules for the forward (or the reverse) path of the intent.
+     *
+     * @param intent OpticalOduIntent intent
+     * @param path path found for intent
+     * @param slotsMap Map of LinkKey and TributarySlots resources
+     * @return list of flow rules
+     */
+    private List<FlowRule> createRules(OpticalOduIntent intent, ConnectPoint src, ConnectPoint dst,
+            Path path, Map<LinkKey, Set<TributarySlot>> slotsMap, boolean reverse) {
+        // Build the ingress OTN rule
+        TrafficSelector.Builder selector = DefaultTrafficSelector.builder();
+        selector.matchInPort(src.port());
+        OduSignalType oduCltPortOduSignalType =
+                OduSignalUtils.mappingCltSignalTypeToOduSignalType(intent.getSignalType());
+        selector.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
+
+        List<FlowRule> rules = new LinkedList<>();
+        ConnectPoint current = src;
+
+        List<Link> links = ((!reverse) ? path.links() : Lists.reverse(path.links()));
+
+        for (Link link : links) {
+            Set<TributarySlot> slots = slotsMap.get(linkKey(link));
+            OtuPort otuPort = (OtuPort) (deviceService.getPort(link.src().deviceId(), link.src().port()));
+            OduSignalType otuPortOduSignalType =
+                    OduSignalUtils.mappingOtuSignalTypeToOduSignalType(otuPort.signalType());
+
+            TrafficTreatment.Builder treat = DefaultTrafficTreatment.builder();
+            OduSignalId oduSignalId = null;
+            // use Instruction of OduSignalId only in case of ODU Multiplexing
+            if (oduCltPortOduSignalType != otuPortOduSignalType) {
+                oduSignalId = OduSignalUtils.buildOduSignalId(otuPortOduSignalType, slots);
+                treat.add(Instructions.modL1OduSignalId(oduSignalId));
+            }
+            ConnectPoint next = ((!reverse) ? link.src() : link.dst());
+            treat.setOutput(next.port());
+
+            FlowRule rule = createFlowRule(intent, current.deviceId(), selector.build(), treat.build());
+            rules.add(rule);
+
+            current = ((!reverse) ? link.dst() : link.src());
+            selector = DefaultTrafficSelector.builder();
+            selector.matchInPort(current.port());
+            selector.add(Criteria.matchOduSignalType(oduCltPortOduSignalType));
+            // use Criteria of OduSignalId only in case of ODU Multiplexing
+            if (oduCltPortOduSignalType != otuPortOduSignalType) {
+                selector.add(Criteria.matchOduSignalId(oduSignalId));
+            }
+        }
+
+        // Build the egress OTN rule
+        TrafficTreatment.Builder treatLast = DefaultTrafficTreatment.builder();
+        treatLast.setOutput(dst.port());
+
+        FlowRule rule = createFlowRule(intent, dst.deviceId(), selector.build(), treatLast.build());
+        rules.add(rule);
+
+        return rules;
+    }
+
+    private FlowRule createFlowRule(OpticalOduIntent intent, DeviceId deviceId,
+            TrafficSelector selector, TrafficTreatment treat) {
+        return DefaultFlowRule.builder()
+                .forDevice(deviceId)
+                .withSelector(selector)
+                .withTreatment(treat)
+                .withPriority(intent.priority())
+                .fromApp(appId)
+                .makePermanent()
+                .build();
+    }
+
+    /**
+     * Finds the common TributarySlots available on the two connect points.
+     *
+     * @param src source connect point
+     * @param dst dest connect point
+     * @return set of common TributarySlots on both connect points
+     */
+    Set<TributarySlot> findCommonTributarySlotsOnCps(ConnectPoint src, ConnectPoint dst) {
+        Set<TributarySlot> forward = findTributarySlotsOnCp(src);
+        Set<TributarySlot> backward = findTributarySlotsOnCp(dst);
+        return Sets.intersection(forward, backward);
+    }
+
+    /**
+     * Finds the TributarySlots available on the connect point.
+     *
+     * @param cp connect point
+     * @return set of TributarySlots available on the connect point
+     */
+    Set<TributarySlot> findTributarySlotsOnCp(ConnectPoint cp) {
+        return resourceService.getAvailableResourceValues(
+                Resources.discrete(cp.deviceId(), cp.port()).id(),
+                TributarySlot.class);
+    }
+}
\ No newline at end of file
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompilerTest.java
index 836117e..a01d44c 100644
--- a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompilerTest.java
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalCircuitIntentCompilerTest.java
@@ -38,6 +38,7 @@
 import org.onosproject.net.OduCltPort;
 import org.onosproject.net.OduSignalId;
 import org.onosproject.net.OduSignalType;
+import org.onosproject.net.OduSignalUtils;
 import org.onosproject.net.Port;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.TributarySlot;
@@ -429,7 +430,7 @@
         TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
         Set<TributarySlot> slots = new HashSet<>();
         slots.add(TributarySlot.of(1));
-        OduSignalId oduSignalId = sut.buildOduSignalId(D1P2.signalType(), slots);
+        OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(D1P2.signalType(), slots);
         treatmentBuilder1.add(Instructions.modL1OduSignalId(oduSignalId));
         treatmentBuilder1.setOutput(ochSrcCP.port());
         assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
diff --git a/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompilerTest.java b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompilerTest.java
new file mode 100644
index 0000000..d5053b3
--- /dev/null
+++ b/core/net/src/test/java/org/onosproject/net/intent/impl/compiler/OpticalOduIntentCompilerTest.java
@@ -0,0 +1,433 @@
+/*
+ * 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.intent.impl.compiler;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onlab.packet.ChassisId;
+import org.onosproject.TestApplicationId;
+import org.onosproject.core.ApplicationId;
+import org.onosproject.core.CoreService;
+import org.onosproject.core.IdGenerator;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.CltSignalType;
+import org.onosproject.net.ConnectPoint;
+import org.onosproject.net.DefaultDevice;
+import org.onosproject.net.DefaultLink;
+import org.onosproject.net.DefaultPath;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.Link;
+import org.onosproject.net.OduCltPort;
+import org.onosproject.net.OduSignalId;
+import org.onosproject.net.OduSignalType;
+import org.onosproject.net.OduSignalUtils;
+import org.onosproject.net.OtuPort;
+import org.onosproject.net.OtuSignalType;
+import org.onosproject.net.Path;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.TributarySlot;
+import org.onosproject.net.flow.DefaultTrafficSelector;
+import org.onosproject.net.flow.DefaultTrafficTreatment;
+import org.onosproject.net.flow.FlowRule;
+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.onosproject.net.intent.FlowRuleIntent;
+import org.onosproject.net.intent.Intent;
+import org.onosproject.net.intent.IntentExtensionService;
+import org.onosproject.net.intent.Key;
+import org.onosproject.net.intent.MockIdGenerator;
+import org.onosproject.net.intent.OpticalOduIntent;
+import org.onosproject.net.provider.ProviderId;
+import org.onosproject.net.topology.LinkWeight;
+import org.onosproject.net.topology.Topology;
+import org.onosproject.net.topology.TopologyServiceAdapter;
+import org.onosproject.net.device.DeviceServiceAdapter;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.Sets;
+
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.expect;
+import static org.easymock.EasyMock.replay;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.is;
+import static org.junit.Assert.assertEquals;
+import static org.onosproject.net.AnnotationKeys.STATIC_PORT;
+import static org.onosproject.net.AnnotationKeys.PORT_NAME;
+import static org.onosproject.net.Device.Type.OTN;
+import static org.onosproject.net.DeviceId.deviceId;
+import static org.onosproject.net.Link.Type.OPTICAL;
+import static org.onosproject.net.NetTestTools.APP_ID;
+import static org.onosproject.net.NetTestTools.PID;
+
+public class OpticalOduIntentCompilerTest {
+
+    private static final String DEV1 = "of:1";
+    private static final String DEV2 = "of:2";
+    private static final String DEV3 = "of:3";
+
+    static final Key KEY1 = Key.of(5L, APP_ID);
+
+    private static final String STATIC_TRUE = "true";
+    private static final String PNAME = "p2";
+
+    private CoreService coreService;
+    private IntentExtensionService intentExtensionService;
+    private final IdGenerator idGenerator = new MockIdGenerator();
+    private OpticalOduIntentCompiler sut;
+
+    private final ApplicationId appId = new TestApplicationId("test");
+    private static Device device1 = new DefaultDevice(ProviderId.NONE, deviceId(DEV1), OTN,
+            "m", "h", "s", "n", new ChassisId(0L));
+    private static Device device2 = new DefaultDevice(ProviderId.NONE, deviceId(DEV2), OTN,
+            "m", "h", "s", "n", new ChassisId(1L));
+    private static Device device3 = new DefaultDevice(ProviderId.NONE, deviceId(DEV3), OTN,
+            "m", "h", "s", "n", new ChassisId(2L));
+
+    private static Annotations annotations1 = DefaultAnnotations.builder().set(STATIC_PORT, STATIC_TRUE).build();
+    private static Annotations annotations2 = DefaultAnnotations.builder().set(PORT_NAME, PNAME).build();
+
+    // OduClt ports with signalType=1GBE
+    private static final OduCltPort D1P1 =
+            new OduCltPort(device1, PortNumber.portNumber(1), true, CltSignalType.CLT_1GBE, annotations1);
+    private static final OduCltPort D3P2 =
+            new OduCltPort(device3, PortNumber.portNumber(2), true, CltSignalType.CLT_1GBE, annotations1);
+
+    // Otu ports with signalType=ODU2
+    private static final OtuPort D1P2 =
+            new OtuPort(device1, PortNumber.portNumber(2), true, OtuSignalType.OTU2, annotations2);
+    private static final OtuPort D2P1 =
+            new OtuPort(device2, PortNumber.portNumber(1), true, OtuSignalType.OTU2, annotations2);
+    private static final OtuPort D2P2 =
+            new OtuPort(device2, PortNumber.portNumber(2), true, OtuSignalType.OTU2, annotations2);
+    private static final OtuPort D3P1 =
+            new OtuPort(device3, PortNumber.portNumber(1), true, OtuSignalType.OTU2, annotations2);
+
+    // OduClt ports with signalType=10GBE
+    private static final OduCltPort D1P3 =
+            new OduCltPort(device1, PortNumber.portNumber(3), true, CltSignalType.CLT_10GBE, annotations1);
+    private static final OduCltPort D3P3 =
+            new OduCltPort(device3, PortNumber.portNumber(3), true, CltSignalType.CLT_10GBE, annotations1);
+
+    // OduCltPort ConnectPoints
+    private final ConnectPoint d1p1 = new ConnectPoint(device1.id(), D1P1.number());
+    private final ConnectPoint d1p3 = new ConnectPoint(device1.id(), D1P3.number());
+    private final ConnectPoint d3p2 = new ConnectPoint(device3.id(), D3P2.number());
+    private final ConnectPoint d3p3 = new ConnectPoint(device3.id(), D3P3.number());
+
+    // OtuPort ConnectPoints
+    private final ConnectPoint d1p2 = new ConnectPoint(device1.id(), D1P2.number());
+    private final ConnectPoint d2p1 = new ConnectPoint(device2.id(), D2P1.number());
+    private final ConnectPoint d2p2 = new ConnectPoint(device2.id(), D2P2.number());
+    private final ConnectPoint d3p1 = new ConnectPoint(device3.id(), D3P1.number());
+
+    private final List<Link> links = Arrays.asList(
+            DefaultLink.builder().providerId(PID).src(d1p2).dst(d2p1).type(OPTICAL).build(),
+            DefaultLink.builder().providerId(PID).src(d2p2).dst(d3p1).type(OPTICAL).build()
+    );
+    private final Path path = new DefaultPath(PID, links, 3);
+
+    private OpticalOduIntent intent;
+
+    /**
+     * Mocks the topology service to give paths in the test.
+     */
+    private class MockTopologyService extends TopologyServiceAdapter {
+        Set<Path> paths = Sets.newHashSet(path);
+
+        @Override
+        public Topology currentTopology() {
+            return null;
+        }
+
+        @Override
+        public Set<Path> getPaths(Topology topology, DeviceId src, DeviceId dst, LinkWeight weight) {
+            return paths;
+        }
+    }
+
+    /**
+     * Mocks the device service so that devices and ports appear available in the test.
+     */
+    private static class MockDeviceService extends DeviceServiceAdapter {
+        @Override
+        public boolean isAvailable(DeviceId deviceId) {
+            return true;
+        }
+
+        @Override
+        public List<Port> getPorts(DeviceId deviceId) {
+            if (deviceId.equals(deviceId(DEV1))) {
+                return ImmutableList.of((Port) D1P1, (Port) D1P2, (Port) D1P3);
+            }
+
+            if (deviceId.equals(deviceId(DEV2))) {
+                return ImmutableList.of((Port) D2P1, (Port) D2P2);
+            }
+
+            if (deviceId.equals(deviceId(DEV3))) {
+                return ImmutableList.of((Port) D3P1, (Port) D3P2, (Port) D3P3);
+            }
+
+            return Collections.emptyList();
+        }
+
+        @Override
+        public Port getPort(DeviceId deviceId, PortNumber portNumber) {
+            if (deviceId.equals(deviceId(DEV1))) {
+                switch (portNumber.toString()) {
+                    case "1":
+                        return (Port) D1P1;
+                    case "2":
+                        return (Port) D1P2;
+                    case "3":
+                        return (Port) D1P3;
+                    default:
+                        return null;
+                }
+            }
+            if (deviceId.equals(deviceId(DEV2))) {
+                switch (portNumber.toString()) {
+                    case "1":
+                        return (Port) D2P1;
+                    case "2":
+                        return (Port) D2P2;
+                    default:
+                        return null;
+                }
+            }
+            if (deviceId.equals(deviceId(DEV3))) {
+                switch (portNumber.toString()) {
+                    case "1":
+                        return (Port) D3P1;
+                    case "2":
+                        return (Port) D3P2;
+                    case "3":
+                        return (Port) D3P3;
+                    default:
+                        return null;
+                }
+            }
+            return null;
+        }
+    }
+
+    @Before
+    public void setUp() {
+        sut =  new OpticalOduIntentCompiler();
+        coreService = createMock(CoreService.class);
+        expect(coreService.registerApplication("org.onosproject.net.intent"))
+                .andReturn(appId);
+        sut.coreService = coreService;
+        sut.deviceService = new MockDeviceService();
+        sut.resourceService = new MockResourceService();
+        sut.topologyService = new MockTopologyService();
+
+        Intent.bindIdGenerator(idGenerator);
+
+        intentExtensionService = createMock(IntentExtensionService.class);
+        intentExtensionService.registerCompiler(OpticalOduIntent.class, sut);
+        intentExtensionService.unregisterCompiler(OpticalOduIntent.class);
+        sut.intentManager = intentExtensionService;
+
+        replay(coreService, intentExtensionService);
+    }
+
+    @After
+    public void tearDown() {
+        Intent.unbindIdGenerator(idGenerator);
+    }
+
+    /**
+     * Tests compile of OpticalOduIntent with allocation of TributarySlots.
+     * Compile two ODUCLT ports (with CLT_1GBE), over OTU ports (with OTU2):
+     *   - only one TributarySlot is used
+     */
+    @Test
+    public void test1GbeMultiplexOverOdu2() {
+
+        intent = OpticalOduIntent.builder()
+                .appId(APP_ID)
+                .key(KEY1)
+                .src(d1p1)
+                .dst(d3p2)
+                .signalType(D1P1.signalType())
+                .bidirectional(false)
+                .build();
+
+        sut.activate();
+
+        List<Intent> compiled = sut.compile(intent, Collections.emptyList());
+        assertThat(compiled, hasSize(1));
+
+        Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
+
+        // 1st Device
+        FlowRule rule1 = rules.stream()
+                .filter(x -> x.deviceId().equals(device1.id()))
+                .findFirst()
+                .get();
+        // validate SRC selector
+        TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
+        selectorBuilder1.matchInPort(d1p1.port());
+        selectorBuilder1.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
+        assertThat(rule1.selector(), is(selectorBuilder1.build()));
+
+        // validate SRC treatment  (with OduSignalId, where 1 TributarySlot is used)
+        TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
+        Set<TributarySlot> slots = new HashSet<>();
+        slots.add(TributarySlot.of(1));
+        OduSignalId oduSignalId = OduSignalUtils.buildOduSignalId(OduSignalType.ODU2, slots);
+        treatmentBuilder1.add(Instructions.modL1OduSignalId(oduSignalId));
+        treatmentBuilder1.setOutput(d1p2.port());
+        assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
+
+        // 2nd Device
+        FlowRule rule2 = rules.stream()
+                .filter(x -> x.deviceId().equals(device2.id()))
+                .findFirst()
+                .get();
+        // validate SRC selector
+        TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
+        selectorBuilder2.matchInPort(d2p1.port());
+        selectorBuilder2.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
+        selectorBuilder2.add(Criteria.matchOduSignalId(oduSignalId));
+        assertThat(rule2.selector(), is(selectorBuilder2.build()));
+
+        // validate SRC treatment  (with OduSignalId, where 1 TributarySlot is used)
+        TrafficTreatment.Builder treatmentBuilder2 = DefaultTrafficTreatment.builder();
+        treatmentBuilder2.add(Instructions.modL1OduSignalId(oduSignalId));
+        treatmentBuilder2.setOutput(d2p2.port());
+        assertThat(rule2.treatment(), is(treatmentBuilder2.build()));
+
+
+        // 3rd Device
+        FlowRule rule3 = rules.stream()
+                .filter(x -> x.deviceId().equals(device3.id()))
+                .findFirst()
+                .get();
+        // validate DST selector (with OduSignalId, where the same TributarySlot is used)
+        TrafficSelector.Builder selectorBuilder3 = DefaultTrafficSelector.builder();
+        selectorBuilder3.matchInPort(d3p1.port());
+        selectorBuilder3.add(Criteria.matchOduSignalType(OduSignalType.ODU0));
+        selectorBuilder3.add(Criteria.matchOduSignalId(oduSignalId));
+        assertThat(rule3.selector(), is(selectorBuilder3.build()));
+
+        // validate DST treatment
+        assertThat(rule3.treatment(), is(
+                DefaultTrafficTreatment.builder().setOutput(d3p2.port()).build()
+                ));
+
+        rules.forEach(rule -> assertEquals("FlowRule priority is incorrect",
+                intent.priority(), rule.priority()));
+
+        sut.deactivate();
+    }
+
+    /**
+     * Tests compile of OpticalOduIntent with allocation of TributarySlots.
+     * Compile two ODUCLT ports (with CLT_10GBE), over OTU ports (with OTU2):
+     *   - All TributarySlots are used
+     */
+    @Test
+    public void test10GbeMultiplexOverOdu2() {
+
+        intent = OpticalOduIntent.builder()
+                .appId(APP_ID)
+                .key(KEY1)
+                .src(d1p3)
+                .dst(d3p3)
+                .signalType(D1P3.signalType())
+                .bidirectional(false)
+                .build();
+
+        sut.activate();
+
+        List<Intent> compiled = sut.compile(intent, Collections.emptyList());
+        assertThat(compiled, hasSize(1));
+
+        Collection<FlowRule> rules = ((FlowRuleIntent) compiled.get(0)).flowRules();
+
+        // 1st Device
+        FlowRule rule1 = rules.stream()
+                .filter(x -> x.deviceId().equals(device1.id()))
+                .findFirst()
+                .get();
+        // validate SRC selector
+        TrafficSelector.Builder selectorBuilder1 = DefaultTrafficSelector.builder();
+        selectorBuilder1.matchInPort(d1p3.port());
+        selectorBuilder1.add(Criteria.matchOduSignalType(OduSignalType.ODU2));
+        assertThat(rule1.selector(), is(selectorBuilder1.build()));
+
+        // validate SRC treatment  (without OduSignalId - all TributarySlots are used)
+        TrafficTreatment.Builder treatmentBuilder1 = DefaultTrafficTreatment.builder();
+        treatmentBuilder1.setOutput(d1p2.port());
+        assertThat(rule1.treatment(), is(treatmentBuilder1.build()));
+
+        // 2nd Device
+        FlowRule rule2 = rules.stream()
+                .filter(x -> x.deviceId().equals(device2.id()))
+                .findFirst()
+                .get();
+        // validate SRC selector
+        TrafficSelector.Builder selectorBuilder2 = DefaultTrafficSelector.builder();
+        selectorBuilder2.matchInPort(d2p1.port());
+        selectorBuilder2.add(Criteria.matchOduSignalType(OduSignalType.ODU2));
+        assertThat(rule2.selector(), is(selectorBuilder2.build()));
+
+        // validate SRC treatment  (without OduSignalId - all TributarySlots are used)
+        TrafficTreatment.Builder treatmentBuilder2 = DefaultTrafficTreatment.builder();
+        treatmentBuilder2.setOutput(d2p2.port());
+        assertThat(rule2.treatment(), is(treatmentBuilder2.build()));
+
+
+        // 3rd Device
+        FlowRule rule3 = rules.stream()
+                .filter(x -> x.deviceId().equals(device3.id()))
+                .findFirst()
+                .get();
+        // validate DST selector (without OduSignalId - all TributarySlots are used)
+        TrafficSelector.Builder selectorBuilder3 = DefaultTrafficSelector.builder();
+        selectorBuilder3.matchInPort(d3p1.port());
+        selectorBuilder3.add(Criteria.matchOduSignalType(OduSignalType.ODU2));
+        assertThat(rule3.selector(), is(selectorBuilder3.build()));
+
+        // validate DST treatment
+        assertThat(rule3.treatment(), is(
+                DefaultTrafficTreatment.builder().setOutput(d3p3.port()).build()
+                ));
+
+        rules.forEach(rule -> assertEquals("FlowRule priority is incorrect",
+                intent.priority(), rule.priority()));
+
+        sut.deactivate();
+    }
+
+}
\ No newline at end of file
diff --git a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
index 0cd88b1..b0acd3b 100644
--- a/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
+++ b/core/store/serializers/src/main/java/org/onosproject/store/serializers/KryoNamespaces.java
@@ -163,6 +163,7 @@
 import org.onosproject.net.intent.MultiPointToSinglePointIntent;
 import org.onosproject.net.intent.OpticalCircuitIntent;
 import org.onosproject.net.intent.OpticalConnectivityIntent;
+import org.onosproject.net.intent.OpticalOduIntent;
 import org.onosproject.net.intent.OpticalPathIntent;
 import org.onosproject.net.intent.PathIntent;
 import org.onosproject.net.intent.PointToPointIntent;
@@ -422,6 +423,7 @@
                     OpticalConnectivityIntent.class,
                     OpticalPathIntent.class,
                     OpticalCircuitIntent.class,
+                    OpticalOduIntent.class,
                     DiscreteResource.class,
                     ContinuousResource.class,
                     DiscreteResourceId.class,