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,
