[ONOS-4588] Separate optical driver from "default" driver bundle

Note: If you're using optical devices currently in "default" driver bundle,
(LINC-OE, Calient fiber switch, ECI devices, OpLink ROADM)

you'll need to load the driver/app "drivers.optical" in adition to default drivers

e.g.,
a) Add to cell definition
 export ONOS_APPS=${ONOS_APPS},drivers.optical

b) Activate after starting ONOS
 onos> app activate org.onosproject.drivers.optical

Change-Id: I126c09bebc816d11b4700a80e7a36a8e6c3e1b49
diff --git a/drivers/optical/BUCK b/drivers/optical/BUCK
new file mode 100644
index 0000000..23ee9b7
--- /dev/null
+++ b/drivers/optical/BUCK
@@ -0,0 +1,20 @@
+COMPILE_DEPS = [
+    '//lib:CORE_DEPS',
+    '//lib:openflowj',
+    '//protocols/openflow/api:onos-protocols-openflow-api',
+    '//drivers/default:onos-drivers-default',
+]
+
+osgi_jar_with_tests (
+    deps = COMPILE_DEPS,
+    resources_root = 'src/main/resources',
+    resources = glob(['src/main/resources/**']),
+)
+
+onos_app (
+    title = 'Other optical Device Drivers',
+    category = 'Drivers',
+    url = 'http://onosproject.org',
+    description = 'ONOS other optical Device Drivers application.',
+    required_apps = [ 'org.onosproject.drivers' ],
+)
diff --git a/drivers/optical/pom.xml b/drivers/optical/pom.xml
new file mode 100644
index 0000000..64e7153
--- /dev/null
+++ b/drivers/optical/pom.xml
@@ -0,0 +1,63 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2016-present Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <parent>
+        <artifactId>onos-drivers-general</artifactId>
+        <groupId>org.onosproject</groupId>
+        <version>1.7.0-SNAPSHOT</version>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+
+    <artifactId>onos-drivers-optical</artifactId>
+    <packaging>bundle</packaging>
+
+    <description>Other optical device drivers</description>
+
+    <properties>
+        <onos.app.name>org.onosproject.drivers.optical</onos.app.name>
+        <onos.app.origin>ON.Lab</onos.app.origin>
+        <onos.app.category>Drivers</onos.app.category>
+        <onos.app.title>Other optical Device Drivers</onos.app.title>
+        <onos.app.url>http://onosproject.org</onos.app.url>
+        <onos.app.requires>
+            org.onosproject.drivers
+        </onos.app.requires>
+    </properties>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-drivers</artifactId>
+            <version>${project.version}</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>openflowj</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.onosproject</groupId>
+            <artifactId>onos-of-api</artifactId>
+        </dependency>
+
+    </dependencies>
+
+</project>
diff --git a/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/CalientFiberSwitchHandshaker.java b/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/CalientFiberSwitchHandshaker.java
new file mode 100644
index 0000000..338d25c
--- /dev/null
+++ b/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/CalientFiberSwitchHandshaker.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.optical.handshaker;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+import org.onosproject.net.Device;
+import org.onosproject.openflow.controller.OpenFlowOpticalSwitch;
+import org.onosproject.openflow.controller.PortDescPropertyType;
+import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch;
+import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeAlreadyStarted;
+import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeCompleted;
+import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeNotStarted;
+import org.projectfloodlight.openflow.protocol.OFCalientFlowStatsRequest;
+import org.projectfloodlight.openflow.protocol.OFCalientPortDescStatsEntry;
+import org.projectfloodlight.openflow.protocol.OFCalientPortDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFCalientPortDescStatsRequest;
+import org.projectfloodlight.openflow.protocol.OFFlowStatsRequest;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFObject;
+import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags;
+import org.projectfloodlight.openflow.protocol.OFStatsRequest;
+import org.projectfloodlight.openflow.protocol.OFType;
+import org.projectfloodlight.openflow.types.OFPort;
+import org.projectfloodlight.openflow.types.TableId;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Driver for Calient S160 Optical Circuit Switch. Untested on Calient S320 but probably works ok.
+ *
+ * Driver implements custom handshaker, and rewrites flow stats as expected by the device. Port stats are currently
+ * not supported.
+ *
+ * The device consists of OMS ports only.
+ */
+public class CalientFiberSwitchHandshaker extends AbstractOpenFlowSwitch implements OpenFlowOpticalSwitch {
+
+    private final AtomicBoolean driverHandshakeComplete = new AtomicBoolean(false);
+    private List<OFCalientPortDescStatsEntry> fiberPorts = new ArrayList<>();
+
+
+    @Override
+    public Boolean supportNxRole() {
+        return false;
+    }
+
+    @Override
+    public void startDriverHandshake() {
+        log.warn("Starting driver handshake for sw {}", getStringId());
+        if (startDriverHandshakeCalled) {
+            throw new SwitchDriverSubHandshakeAlreadyStarted();
+        }
+        startDriverHandshakeCalled = true;
+        try {
+            sendHandshakeOFExperimenterPortDescRequest();
+        } catch (IOException e) {
+            log.error("Exception while sending experimenter port desc:", e);
+        }
+
+    }
+
+    private void sendHandshakeOFExperimenterPortDescRequest() throws IOException {
+        // send multi part message for port description for optical switches
+        OFCalientPortDescStatsRequest portsRequest = factory()
+                .buildCalientPortDescStatsRequest()
+                .build();
+        log.warn("Sending experimenter port description message {}",
+                portsRequest.toString());
+        this.sendHandshakeMessage(portsRequest);
+    }
+
+    @Override
+    public boolean isDriverHandshakeComplete() {
+        return driverHandshakeComplete.get();
+    }
+
+    @Override
+    public void processDriverHandshakeMessage(OFMessage m) {
+        if (!startDriverHandshakeCalled) {
+            throw new SwitchDriverSubHandshakeNotStarted();
+        }
+        if (driverHandshakeComplete.get()) {
+            throw new SwitchDriverSubHandshakeCompleted(m);
+        }
+
+        switch (m.getType()) {
+            case BARRIER_REPLY:
+                break;
+            case ERROR:
+                log.error("Switch Error {} {}", getStringId(), m);
+                break;
+            case FEATURES_REPLY:
+                break;
+            case FLOW_REMOVED:
+                break;
+            case GET_ASYNC_REPLY:
+                break;
+            case PACKET_IN:
+                break;
+            case PORT_STATUS:
+                break;
+            case QUEUE_GET_CONFIG_REPLY:
+                break;
+            case ROLE_REPLY:
+                break;
+            case STATS_REPLY:
+                log.warn("Received port desc reply");
+                OFCalientPortDescStatsReply descStatsReply = (OFCalientPortDescStatsReply) m;
+                fiberPorts.addAll(descStatsReply.getPortDesc());
+                // Multi-part message
+                if (!descStatsReply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
+                    driverHandshakeComplete.set(true);
+                }
+                break;
+            default:
+                log.warn("Received message {} during switch-driver " +
+                                "subhandshake " + "from switch {} ... " +
+                                "Ignoring message", m,
+                        getStringId());
+
+        }
+    }
+
+    @Override
+    public Device.Type deviceType() {
+        return Device.Type.FIBER_SWITCH;
+    }
+
+    @Override
+    public List<? extends OFObject> getPortsOf(PortDescPropertyType type) {
+        return ImmutableList.copyOf(fiberPorts);
+    }
+
+    @Override
+    public Set<PortDescPropertyType> getPortTypes() {
+        return ImmutableSet.of(PortDescPropertyType.OPTICAL_TRANSPORT);
+    }
+
+    @Override
+    public final void sendMsg(OFMessage m) {
+        OFMessage newMsg = m;
+
+        if (m.getType() == OFType.STATS_REQUEST) {
+            OFStatsRequest sr = (OFStatsRequest) m;
+            log.debug("Rebuilding stats request type {}", sr.getStatsType());
+            switch (sr.getStatsType()) {
+                case FLOW:
+                    OFCalientFlowStatsRequest request = this.factory().buildCalientFlowStatsRequest()
+                            .setCookie(((OFFlowStatsRequest) sr).getCookie())
+                            .setCookieMask(((OFFlowStatsRequest) sr).getCookieMask())
+                            .setMatch(this.factory().matchWildcardAll())
+                            .setOutGroup(((OFFlowStatsRequest) sr).getOutGroup().getGroupNumber())
+                            .setOutPort(OFPort.ANY)
+                            .setTableId(TableId.ALL)
+                            .setXid(sr.getXid())
+                            .setFlags(sr.getFlags())
+                            .build();
+                    newMsg = request;
+                    break;
+                case PORT:
+                    // TODO
+                    break;
+                default:
+                    break;
+            }
+        }
+
+        super.sendMsg(newMsg);
+    }
+}
diff --git a/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/OFOpticalSwitch13.java b/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/OFOpticalSwitch13.java
new file mode 100644
index 0000000..c1cc39c
--- /dev/null
+++ b/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/OFOpticalSwitch13.java
@@ -0,0 +1,177 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.optical.handshaker;
+
+import org.projectfloodlight.openflow.protocol.OFExpPort;
+import org.projectfloodlight.openflow.protocol.OFExpPortDescReply;
+import org.projectfloodlight.openflow.protocol.OFExpPortDescRequest;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFPortDesc;
+import org.projectfloodlight.openflow.protocol.OFStatsReply;
+import org.projectfloodlight.openflow.protocol.OFStatsReplyFlags;
+import org.projectfloodlight.openflow.protocol.OFStatsType;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.stream.Collectors;
+
+import org.onosproject.net.Device;
+import org.onosproject.openflow.controller.OpenFlowOpticalSwitch;
+import org.onosproject.openflow.controller.PortDescPropertyType;
+import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch;
+import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeAlreadyStarted;
+import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeCompleted;
+import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeNotStarted;
+import org.projectfloodlight.openflow.protocol.OFObject;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
+
+/**
+ * Open Flow Optical Switch handshaker - for Open Flow 13.
+ */
+public class OFOpticalSwitch13 extends AbstractOpenFlowSwitch implements OpenFlowOpticalSwitch {
+
+    private final AtomicBoolean driverHandshakeComplete = new AtomicBoolean(false);
+    private List<OFExpPort> expPortDes = new ArrayList<>();
+
+    @Override
+    public Boolean supportNxRole() {
+        return false;
+    }
+
+    @Override
+    public void startDriverHandshake() {
+        log.info("Starting driver handshake for sw {}", getStringId());
+        if (startDriverHandshakeCalled) {
+            throw new SwitchDriverSubHandshakeAlreadyStarted();
+        }
+        startDriverHandshakeCalled = true;
+
+        log.debug("sendHandshakeOFExperimenterPortDescRequest for sw {}", getStringId());
+
+        try {
+            sendHandshakeOFExperimenterPortDescRequest();
+        } catch (IOException e) {
+            log.error("Failed to send handshaker message OFExperimenterPortDescRequestfor sw {}", e);
+        }
+    }
+
+     @Override
+    public void processDriverHandshakeMessage(OFMessage m) {
+        if (!startDriverHandshakeCalled) {
+            throw new SwitchDriverSubHandshakeNotStarted();
+        }
+        if (driverHandshakeComplete.get()) {
+            throw new SwitchDriverSubHandshakeCompleted(m);
+        }
+
+        log.debug("processDriverHandshakeMessage for sw {}", getStringId());
+
+        switch (m.getType()) {
+        case STATS_REPLY: // multipart message is reported as STAT
+            processOFMultipartReply((OFStatsReply) m);
+            break;
+        default:
+            log.warn("Received message {} during switch-driver " +
+                    "subhandshake " + "from switch {} ... " +
+                    "Ignoring message", m,
+                    getStringId());
+        }
+    }
+
+    private void processOFMultipartReply(OFStatsReply stats) {
+        log.debug("Received message {} during switch-driver " +
+                   "subhandshake " + "from switch {} ... " +
+                   stats,
+                   getStringId());
+
+         if (stats.getStatsType() == OFStatsType.EXPERIMENTER) {
+             try {
+               OFExpPortDescReply expPortDescReply =  (OFExpPortDescReply) stats;
+               expPortDes.addAll(expPortDescReply.getEntries());
+               if (!expPortDescReply.getFlags().contains(OFStatsReplyFlags.REPLY_MORE)) {
+                   driverHandshakeComplete.set(true);
+                   return;
+               }
+              } catch (ClassCastException e) {
+                  log.error("Unexspected Experimenter Multipart message type {} ",
+                          stats.getClass().getName());
+            }
+        }
+    }
+
+
+    @Override
+    public boolean isDriverHandshakeComplete() {
+        return driverHandshakeComplete.get();
+    }
+
+    private void sendHandshakeOFExperimenterPortDescRequest() throws
+            IOException {
+
+        OFExpPortDescRequest preq = factory()
+                .buildExpPortDescRequest()
+                .setXid(getNextTransactionId())
+                .build();
+
+        log.debug("Sending experimented port description " +
+                "message " +
+                "{}",
+                preq.toString());
+
+        this.sendHandshakeMessage(preq);
+    }
+
+    @Override
+    public Device.Type deviceType() {
+        String hwDesc = hardwareDescription();
+        switch (hwDesc) {
+            case "Optical-ROADM":
+                return Device.Type.ROADM;
+            case "Optical-OTN":
+                return Device.Type.OTN;
+            default:
+                log.error("Unsupported hardwareDescription {}", hwDesc);
+                return Device.Type.OTHER;
+        }
+    }
+
+    /*
+     * OduClt ports are reported as regular ETH ports.
+     */
+    @Override
+    public List<OFPortDesc> getPorts() {
+        return ImmutableList.copyOf(
+                ports.stream().flatMap(p -> p.getEntries().stream())
+                .collect(Collectors.toList()));
+    }
+
+    @Override
+    public List<? extends OFObject> getPortsOf(PortDescPropertyType type) {
+        return ImmutableList.copyOf(expPortDes);
+    }
+
+   @Override
+    public Set<PortDescPropertyType> getPortTypes() {
+        return ImmutableSet.of(PortDescPropertyType.OPTICAL_TRANSPORT);
+    }
+
+}
diff --git a/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/OfOpticalSwitchImplLinc13.java b/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/OfOpticalSwitchImplLinc13.java
new file mode 100644
index 0000000..5e55fb4
--- /dev/null
+++ b/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/OfOpticalSwitchImplLinc13.java
@@ -0,0 +1,350 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.optical.handshaker;
+
+import com.google.common.collect.ImmutableSet;
+import org.onosproject.net.Device;
+import org.onosproject.openflow.controller.OpenFlowOpticalSwitch;
+import org.onosproject.openflow.controller.PortDescPropertyType;
+import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch;
+import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeAlreadyStarted;
+import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeCompleted;
+import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeNotStarted;
+import org.projectfloodlight.openflow.protocol.OFCircuitPortStatus;
+import org.projectfloodlight.openflow.protocol.OFCircuitPortsReply;
+import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest;
+import org.projectfloodlight.openflow.protocol.OFFlowMod;
+import org.projectfloodlight.openflow.protocol.OFFlowStatsRequest;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFObject;
+import org.projectfloodlight.openflow.protocol.OFPortDesc;
+import org.projectfloodlight.openflow.protocol.OFPortDescPropOpticalTransport;
+import org.projectfloodlight.openflow.protocol.OFPortDescStatsReply;
+import org.projectfloodlight.openflow.protocol.OFPortOptical;
+import org.projectfloodlight.openflow.protocol.OFStatsReply;
+import org.projectfloodlight.openflow.protocol.OFStatsType;
+import org.projectfloodlight.openflow.protocol.action.OFAction;
+import org.projectfloodlight.openflow.protocol.action.OFActionSetField;
+import org.projectfloodlight.openflow.protocol.match.Match;
+import org.projectfloodlight.openflow.protocol.match.MatchField;
+import org.projectfloodlight.openflow.protocol.oxm.OFOxmExpOchSigId;
+import org.projectfloodlight.openflow.types.CircuitSignalID;
+import org.projectfloodlight.openflow.types.U8;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * LINC-OE Optical Emulator switch class.
+ *
+ * The LINC ROADM emulator exposes two types of ports: OCh ports connect to ports in the packet layer,
+ * while OMS ports connect to an OMS port on a neighbouring ROADM.
+ *
+ * LINC sends the tap ports (OCh for our purposes) in the regular port desc stats reply,
+ * while it sends *all* ports (both tap and WDM ports, i.e., OCh and OMS) in the experimenter port desc stats reply.
+ *
+ * As LINC implements custom OF optical extensions (in contrast to the final standard as specified in
+ * ONF TS-022 (March 15, 2015), we need to rewrite flow stat requests and flow mods in {@link #sendMsg(OFMessage)}.
+ */
+public class OfOpticalSwitchImplLinc13 extends AbstractOpenFlowSwitch implements OpenFlowOpticalSwitch {
+
+    private final AtomicBoolean driverHandshakeComplete = new AtomicBoolean(false);
+    private long barrierXidToWaitFor = -1;
+
+    private List<OFPortOptical> opticalPorts;
+
+    @Override
+    public void startDriverHandshake() {
+        log.warn("Starting driver handshake for sw {}", getStringId());
+        if (startDriverHandshakeCalled) {
+            throw new SwitchDriverSubHandshakeAlreadyStarted();
+        }
+        startDriverHandshakeCalled = true;
+        try {
+            sendHandshakeOFExperimenterPortDescRequest();
+        } catch (IOException e) {
+            log.error("LINC-OE exception while sending experimenter port desc:",
+                     e);
+        }
+    }
+
+    @Override
+    public boolean isDriverHandshakeComplete() {
+        return driverHandshakeComplete.get();
+    }
+
+    @Override
+    public void processDriverHandshakeMessage(OFMessage m) {
+        if (!startDriverHandshakeCalled) {
+            throw new SwitchDriverSubHandshakeNotStarted();
+        }
+        if (driverHandshakeComplete.get()) {
+            throw new SwitchDriverSubHandshakeCompleted(m);
+        }
+
+        switch (m.getType()) {
+            case BARRIER_REPLY:
+                if (m.getXid() == barrierXidToWaitFor) {
+                    log.debug("LINC-OE Received barrier response");
+                }
+                break;
+            case ERROR:
+                log.error("Switch {} Error {}", getStringId(), m);
+                break;
+            case FEATURES_REPLY:
+                break;
+            case FLOW_REMOVED:
+                break;
+            case GET_ASYNC_REPLY:
+                break;
+            case PACKET_IN:
+                break;
+            case PORT_STATUS:
+                log.warn("****LINC-OE Port Status {} {}", getStringId(), m);
+                processOFPortStatus((OFCircuitPortStatus) m);
+                break;
+            case QUEUE_GET_CONFIG_REPLY:
+                break;
+            case ROLE_REPLY:
+                break;
+            case STATS_REPLY:
+                OFStatsReply stats = (OFStatsReply) m;
+                if (stats.getStatsType() == OFStatsType.EXPERIMENTER) {
+                    log.warn("LINC-OE : Received stats reply message {}", m);
+                    createOpticalPortList((OFCircuitPortsReply) m);
+                    driverHandshakeComplete.set(true);
+                }
+                break;
+            default:
+                log.warn("Received message {} during switch-driver " +
+                                 "subhandshake " + "from switch {} ... " +
+                                 "Ignoring message", m,
+                         getStringId());
+
+        }
+    }
+
+    public void processOFPortStatus(OFCircuitPortStatus ps) {
+        log.debug("LINC-OE ..OF Port Status :", ps);
+    }
+
+    private void sendHandshakeOFExperimenterPortDescRequest() throws
+            IOException {
+        // send multi part message for port description for optical switches
+        OFCircuitPortsRequest circuitPortsRequest = factory()
+                .buildCircuitPortsRequest().setXid(getNextTransactionId())
+                .build();
+        log.warn("LINC-OE : Sending experimented circuit port stats " +
+                         "message " +
+                         "{}",
+                 circuitPortsRequest.toString());
+        this.sendHandshakeMessage(circuitPortsRequest);
+    }
+
+    @Override
+    /**
+     * Returns a list of standard (Ethernet) ports.
+     *
+     * @return List of ports
+     */
+    public List<OFPortDesc> getPorts() {
+        return Collections.EMPTY_LIST;
+    }
+
+    /**
+     * Rewrite match object to use LINC OF optical extensions.
+     *
+     * @param match original match
+     * @return rewritten match
+     */
+    private Match rewriteMatch(Match match) {
+        Match.Builder mBuilder = factory().buildMatch();
+        for (MatchField mf : match.getMatchFields()) {
+            if (mf == MatchField.EXP_OCH_SIG_ID) {
+                mBuilder.setExact(MatchField.OCH_SIGID, (CircuitSignalID) match.get(mf));
+                continue;
+            }
+            if (mf == MatchField.EXP_OCH_SIGTYPE) {
+                mBuilder.setExact(MatchField.OCH_SIGTYPE, (U8) match.get(mf));
+                continue;
+            }
+            mBuilder.setExact(mf, match.get(mf));
+        }
+
+        return mBuilder.build();
+    }
+
+    /**
+     * Rewrite actions to use LINC OF optical extensions.
+     *
+     * @param actions original actions
+     * @return rewritten actions
+     */
+    private List<OFAction> rewriteActions(List<OFAction> actions) {
+        List<OFAction> newActions = new LinkedList<>();
+
+        for (OFAction action : actions) {
+            if (!(action instanceof OFActionSetField)) {
+                newActions.add(action);
+                continue;
+            }
+
+            OFActionSetField sf = (OFActionSetField) action;
+            if (!(sf.getField() instanceof OFOxmExpOchSigId)) {
+                newActions.add(action);
+                continue;
+            }
+
+            OFOxmExpOchSigId oxm = (OFOxmExpOchSigId) sf.getField();
+            CircuitSignalID signalId = oxm.getValue();
+
+            newActions.add(
+                    factory().actions().circuit(factory().oxms().ochSigid(signalId)));
+        }
+
+        return newActions;
+    }
+
+    @Override
+    public void sendMsg(OFMessage msg) {
+        // Ignore everything but flow mods and stat requests
+        if (!(msg instanceof OFFlowMod || msg instanceof OFFlowStatsRequest)) {
+            super.sendMsg(msg);
+            return;
+        }
+
+        Match newMatch;
+        OFMessage newMsg = null;
+
+        if (msg instanceof OFFlowStatsRequest) {
+            // Rewrite match only
+            OFFlowStatsRequest fsr = (OFFlowStatsRequest) msg;
+            newMatch = rewriteMatch(fsr.getMatch());
+            newMsg = fsr.createBuilder().setMatch(newMatch).build();
+        } else if (msg instanceof OFFlowMod) {
+            // Rewrite match and actions
+            OFFlowMod fm = (OFFlowMod) msg;
+            newMatch = rewriteMatch(fm.getMatch());
+            List<OFAction> actions = rewriteActions(fm.getActions());
+            newMsg = fm.createBuilder().setMatch(newMatch).setActions(actions).build();
+        }
+
+        super.sendMsg(newMsg);
+    }
+
+    @Override
+    public Boolean supportNxRole() {
+        return false;
+    }
+
+    @Override
+    public Device.Type deviceType() {
+        return Device.Type.ROADM;
+    }
+
+    /**
+     * Checks if given port is also part of the regular port desc stats, i.e., is the port a tap port.
+     *
+     * @param port given port number
+     * @return true if the port is a tap (OCh), false otherwise (OMS port)
+     */
+    private boolean isOChPort(long port) {
+        for (OFPortDescStatsReply reply : this.ports) {
+            for (OFPortDesc p : reply.getEntries()) {
+                if (p.getPortNo().getPortNumber() == port) {
+                    return true;
+                }
+            }
+        }
+
+        return false;
+    }
+
+    /**
+     * Creates an OpenFlow optical port based on the given port and transport type.
+     *
+     * @param port OpenFlow optical port
+     * @param type transport type
+     * @return OpenFlow optical port
+     */
+    private OFPortOptical createOpticalPort(OFPortOptical port, short type) {
+        List<OFPortDescPropOpticalTransport> descList = new ArrayList<>(port.getDesc().size());
+
+        for (OFPortDescPropOpticalTransport desc : port.getDesc()) {
+            OFPortDescPropOpticalTransport newDesc = desc.createBuilder()
+                    .setType(desc.getType())
+                    .setPortSignalType(type)
+                    .setPortType(desc.getPortType())
+                    .setReserved(desc.getReserved())
+                    .build();
+            descList.add(newDesc);
+        }
+
+        OFPortOptical newPort = port.createBuilder()
+                .setConfig(port.getConfig())
+                .setDesc(descList)
+                .setHwAddr(port.getHwAddr())
+                .setName(port.getName())
+                .setPortNo(port.getPortNo())
+                .setState(port.getState())
+                .build();
+
+        return newPort;
+    }
+
+    /**
+     * Builds list of OFPortOptical ports based on the multi-part circuit ports reply.
+     *
+     * Ensure the optical transport port's signal type is configured correctly.
+     *
+     * @param wPorts OF reply with circuit ports
+     */
+    private void createOpticalPortList(OFCircuitPortsReply wPorts) {
+        opticalPorts = new ArrayList<>(wPorts.getEntries().size());
+
+        for (OFPortOptical p : wPorts.getEntries()) {
+            short signalType;
+
+            // FIXME: use constants once loxi has full optical extensions
+            if (isOChPort(p.getPortNo().getPortNumber())) {
+                signalType = 5;      // OCH port
+            } else {
+                signalType = 2;      // OMS port
+            }
+
+            opticalPorts.add(createOpticalPort(p, signalType));
+        }
+    }
+
+    @Override
+    public List<? extends OFObject> getPortsOf(PortDescPropertyType type) {
+        if (!type.equals(PortDescPropertyType.OPTICAL_TRANSPORT)) {
+            return Collections.EMPTY_LIST;
+        }
+
+        return opticalPorts;
+    }
+
+    @Override
+    public Set<PortDescPropertyType> getPortTypes() {
+        return ImmutableSet.of(PortDescPropertyType.OPTICAL_TRANSPORT);
+    }
+}
diff --git a/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/OplinkRoadmHandshaker.java b/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/OplinkRoadmHandshaker.java
new file mode 100644
index 0000000..13c238b
--- /dev/null
+++ b/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/OplinkRoadmHandshaker.java
@@ -0,0 +1,188 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.optical.handshaker;
+
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableSet;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.onosproject.net.Device;
+import org.onosproject.openflow.controller.OpenFlowOpticalSwitch;
+import org.onosproject.openflow.controller.PortDescPropertyType;
+import org.onosproject.openflow.controller.driver.AbstractOpenFlowSwitch;
+import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeAlreadyStarted;
+import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeCompleted;
+import org.onosproject.openflow.controller.driver.SwitchDriverSubHandshakeNotStarted;
+import org.projectfloodlight.openflow.protocol.OFCircuitPortStatus;
+import org.projectfloodlight.openflow.protocol.OFCircuitPortsReply;
+import org.projectfloodlight.openflow.protocol.OFCircuitPortsRequest;
+import org.projectfloodlight.openflow.protocol.OFMessage;
+import org.projectfloodlight.openflow.protocol.OFObject;
+import org.projectfloodlight.openflow.protocol.OFPortDesc;
+import org.projectfloodlight.openflow.protocol.OFPortOptical;
+import org.projectfloodlight.openflow.protocol.OFStatsReply;
+import org.projectfloodlight.openflow.protocol.OFStatsType;
+
+/**
+ * Driver for Oplink single WSS 8D ROADM.
+ *
+ * Driver implements custom handshaker and supports for Optical channel Port based on OpenFlow OTN extension.
+ * The device consists of Och ports, and performances wavelength cross-connect among the ports.
+ */
+public class OplinkRoadmHandshaker extends AbstractOpenFlowSwitch implements OpenFlowOpticalSwitch {
+    private final AtomicBoolean driverHandshakeComplete = new AtomicBoolean(false);
+    private List<OFPortOptical> opticalPorts;
+
+    @Override
+    public List<? extends OFObject> getPortsOf(PortDescPropertyType type) {
+        return ImmutableList.copyOf(opticalPorts);
+    }
+
+    @Override
+    /**
+     * Returns a list of standard (Ethernet) ports.
+     *
+     * @return List of ports
+     */
+    public List<OFPortDesc> getPorts() {
+        return Collections.EMPTY_LIST;
+    }
+
+    @Override
+    public Set<PortDescPropertyType> getPortTypes() {
+        return ImmutableSet.of(PortDescPropertyType.OPTICAL_TRANSPORT);
+    }
+
+    @Override
+    public Boolean supportNxRole() {
+        return false;
+    }
+
+    @Override
+    public void startDriverHandshake() {
+        log.warn("Starting driver handshake for sw {}", getStringId());
+        if (startDriverHandshakeCalled) {
+            throw new SwitchDriverSubHandshakeAlreadyStarted();
+        }
+        startDriverHandshakeCalled = true;
+        try {
+            sendHandshakeOFExperimenterPortDescRequest();
+        } catch (IOException e) {
+            log.error("OPLK ROADM exception while sending experimenter port desc:", e);
+        }
+    }
+
+    @Override
+    public boolean isDriverHandshakeComplete() {
+        return driverHandshakeComplete.get();
+    }
+
+    @Override
+    public void processDriverHandshakeMessage(OFMessage m) {
+
+        if (!startDriverHandshakeCalled) {
+            throw new SwitchDriverSubHandshakeNotStarted();
+        }
+
+        if (driverHandshakeComplete.get()) {
+            throw new SwitchDriverSubHandshakeCompleted(m);
+        }
+
+        switch (m.getType()) {
+            case BARRIER_REPLY:
+                log.debug("OPLK ROADM Received barrier response");
+                break;
+            case ERROR:
+                log.error("Switch {} Error {}", getStringId(), m);
+                break;
+            case FEATURES_REPLY:
+                break;
+            case FLOW_REMOVED:
+                break;
+            case GET_ASYNC_REPLY:
+                break;
+            case PACKET_IN:
+                break;
+            case PORT_STATUS:
+                processOFPortStatus((OFCircuitPortStatus) m);
+                break;
+            case QUEUE_GET_CONFIG_REPLY:
+                break;
+            case ROLE_REPLY:
+                break;
+            case STATS_REPLY:
+                OFStatsReply stats = (OFStatsReply) m;
+                if (stats.getStatsType() == OFStatsType.EXPERIMENTER) {
+                    log.warn("OPLK ROADM : Received multipart (port desc) reply message {}", m);
+                    //OTN Optical extension 1.0 port-desc
+                    createOpticalPortList((OFCircuitPortsReply) m);
+                    driverHandshakeComplete.set(true);
+                }
+                break;
+            default:
+                log.warn("Received message {} during switch-driver " +
+                                 "subhandshake " + "from switch {} ... " +
+                                 "Ignoring message", m,
+                         getStringId());
+
+        }
+    }
+
+    private void processOFPortStatus(OFCircuitPortStatus ps) {
+        log.debug("OPLK ROADM ..OF Port Status :", ps);
+    }
+
+    @Override
+    public Device.Type deviceType() {
+        return Device.Type.ROADM;
+    }
+
+    @Override
+    public final void sendMsg(OFMessage m) {
+        OFMessage newMsg = m;
+        //Stub for later enhancement.
+        super.sendMsg(newMsg);
+    }
+
+    private void sendHandshakeOFExperimenterPortDescRequest() throws IOException {
+        // send multi part message for port description for optical switches
+        OFCircuitPortsRequest circuitPortsRequest = factory()
+                .buildCircuitPortsRequest().setXid(getNextTransactionId())
+                .build();
+        log.info("OPLK ROADM : Sending experimented circuit port stats " +
+                 "message " +
+                 "{}",
+                 circuitPortsRequest);
+        this.sendHandshakeMessage(circuitPortsRequest);
+    }
+
+    /**
+     * Builds list of OFPortOptical ports based on the multi-part circuit ports reply.
+     * Ensure the optical transport port's signal type is configured correctly.
+     *
+     * @param wPorts OF reply with circuit ports
+     */
+    private void createOpticalPortList(OFCircuitPortsReply wPorts) {
+        opticalPorts = new ArrayList<>();
+        opticalPorts.addAll(wPorts.getEntries());
+    }
+}
diff --git a/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/package-info.java b/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/package-info.java
new file mode 100644
index 0000000..0960665
--- /dev/null
+++ b/drivers/optical/src/main/java/org/onosproject/driver/optical/handshaker/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Implementations of the handshake driver behaviours for optical devices.
+ */
+package org.onosproject.driver.optical.handshaker;
diff --git a/drivers/optical/src/main/java/org/onosproject/driver/optical/query/CalientLambdaQuery.java b/drivers/optical/src/main/java/org/onosproject/driver/optical/query/CalientLambdaQuery.java
new file mode 100644
index 0000000..05d7f7e
--- /dev/null
+++ b/drivers/optical/src/main/java/org/onosproject/driver/optical/query/CalientLambdaQuery.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.optical.query;
+
+import org.onlab.util.Spectrum;
+import org.onosproject.net.ChannelSpacing;
+import org.onosproject.net.GridType;
+import org.onosproject.net.OchSignal;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.behaviour.LambdaQuery;
+import org.onosproject.net.driver.AbstractHandlerBehaviour;
+
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+/**
+ * Lambda query implementation for Calient S160 and S320 Optical Circuit Switch.
+ *
+ * The device consists of OMS ports only, and each port exposes lambda resources covering the whole
+ * usable optical spectrum (U to O band, see {@link Spectrum} for spectrum definitions).
+ */
+public class CalientLambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery {
+
+    @Override
+    public Set<OchSignal> queryLambdas(PortNumber port) {
+        // S160 data sheet
+        // Wavelength range: 1260 - 1630 nm
+        long startSpacingMultiplier = Spectrum.U_BAND_MIN.subtract(Spectrum.CENTER_FREQUENCY).asHz() /
+                ChannelSpacing.CHL_12P5GHZ.frequency().asHz();
+        long stopSpacingMultiplier = Spectrum.O_BAND_MAX.subtract(Spectrum.CENTER_FREQUENCY).asHz() /
+                ChannelSpacing.CHL_12P5GHZ.frequency().asHz();
+
+        // Only consider odd values for the multiplier (for easy mapping to fixed grid)
+        return IntStream.rangeClosed((int) startSpacingMultiplier, (int) stopSpacingMultiplier)
+                .filter(i -> i % 2 == 1)
+                .mapToObj(i -> new OchSignal(GridType.FLEX, ChannelSpacing.CHL_6P25GHZ, i, 1))
+                .collect(Collectors.toSet());
+    }
+}
diff --git a/drivers/optical/src/main/java/org/onosproject/driver/optical/query/DefaultTributarySlotQuery.java b/drivers/optical/src/main/java/org/onosproject/driver/optical/query/DefaultTributarySlotQuery.java
new file mode 100644
index 0000000..1d5ec1a
--- /dev/null
+++ b/drivers/optical/src/main/java/org/onosproject/driver/optical/query/DefaultTributarySlotQuery.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.optical.query;
+
+import org.onlab.util.GuavaCollectors;
+import org.onosproject.net.OduSignalType;
+import org.onosproject.net.OtuSignalType;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.TributarySlot;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.driver.AbstractHandlerBehaviour;
+import org.onosproject.net.optical.OchPort;
+import org.onosproject.net.optical.OtuPort;
+import org.onosproject.net.behaviour.TributarySlotQuery;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.stream.IntStream;
+
+/**
+ * TributarySlotQuery implementation which responds that all slots of ODU2 or ODU4 are available for the port.
+ */
+public class DefaultTributarySlotQuery extends AbstractHandlerBehaviour implements TributarySlotQuery {
+
+    private static final Logger log = LoggerFactory.getLogger(DefaultTributarySlotQuery.class);
+
+    private static final int TOTAL_ODU2_TRIBUTARY_SLOTS = 8;
+    private static final int TOTAL_ODU4_TRIBUTARY_SLOTS = 80;
+
+    private static Set<TributarySlot> getEntireOdu2TributarySlots() {
+        return IntStream.rangeClosed(1, TOTAL_ODU2_TRIBUTARY_SLOTS)
+                .mapToObj(TributarySlot::of)
+                .collect(GuavaCollectors.toImmutableSet());
+    }
+
+    private static Set<TributarySlot> getEntireOdu4TributarySlots() {
+        return IntStream.rangeClosed(1, TOTAL_ODU4_TRIBUTARY_SLOTS)
+                .mapToObj(TributarySlot::of)
+                .collect(GuavaCollectors.toImmutableSet());
+    }
+
+    private static final Set<TributarySlot> ENTIRE_ODU2_TRIBUTARY_SLOTS = getEntireOdu2TributarySlots();
+    private static final Set<TributarySlot> ENTIRE_ODU4_TRIBUTARY_SLOTS = getEntireOdu4TributarySlots();
+
+    @Override
+    public Set<TributarySlot> queryTributarySlots(PortNumber port) {
+        // currently return all slots by default.
+        DeviceService deviceService = opticalView(this.handler().get(DeviceService.class));
+        Port p = deviceService.getPort(this.data().deviceId(), port);
+
+        switch (p.type()) {
+            case OCH:
+                return queryOchTributarySlots(p);
+            case OTU:
+                return queryOtuTributarySlots(p);
+            default:
+                return Collections.emptySet();
+        }
+    }
+
+    private Set<TributarySlot> queryOchTributarySlots(Port ochPort) {
+        OduSignalType signalType = null;
+        if (ochPort instanceof org.onosproject.net.OchPort) {
+            // remove once deprecation of old OchPort model is done
+            signalType = ((org.onosproject.net.OchPort) ochPort).signalType();
+        }
+        if (ochPort instanceof OchPort) {
+            signalType = ((OchPort) ochPort).signalType();
+        }
+
+        if (signalType == null) {
+            log.warn("{} was not an OchPort", ochPort);
+            return Collections.emptySet();
+        }
+
+        switch (signalType) {
+            case ODU2:
+                return ENTIRE_ODU2_TRIBUTARY_SLOTS;
+            case ODU4:
+                return ENTIRE_ODU4_TRIBUTARY_SLOTS;
+            default:
+                log.error("Unsupported signal type {} for {}", signalType, ochPort);
+                return Collections.emptySet();
+        }
+    }
+
+    private Set<TributarySlot> queryOtuTributarySlots(Port otuPort) {
+        OtuSignalType signalType = null;
+        if (otuPort instanceof org.onosproject.net.OtuPort) {
+            // remove once deprecation of old OtuPort model is done
+            signalType = ((org.onosproject.net.OtuPort) otuPort).signalType();
+        }
+        if (otuPort instanceof OtuPort) {
+            signalType = ((OtuPort) otuPort).signalType();
+        }
+
+        if (signalType == null) {
+            log.warn("{} was not an OtuPort", otuPort);
+            return Collections.emptySet();
+        }
+
+        switch (signalType) {
+            case OTU2:
+                return ENTIRE_ODU2_TRIBUTARY_SLOTS;
+            case OTU4:
+                return ENTIRE_ODU4_TRIBUTARY_SLOTS;
+            default:
+                log.error("Unsupported signal type {} for {}", signalType, otuPort);
+                return Collections.emptySet();
+        }
+    }
+}
\ No newline at end of file
diff --git a/drivers/optical/src/main/java/org/onosproject/driver/optical/query/LincOELambdaQuery.java b/drivers/optical/src/main/java/org/onosproject/driver/optical/query/LincOELambdaQuery.java
new file mode 100644
index 0000000..0d8cb45
--- /dev/null
+++ b/drivers/optical/src/main/java/org/onosproject/driver/optical/query/LincOELambdaQuery.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.optical.query;
+
+import org.onosproject.net.ChannelSpacing;
+import org.onosproject.net.GridType;
+import org.onosproject.net.OchSignal;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.behaviour.LambdaQuery;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.driver.AbstractHandlerBehaviour;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+/**
+ * Lambda query implementation for LINC-OE Optical Emulator switch.
+ *
+ * The LINC ROADM emulator exposes two types of ports: OCh ports connect to ports in the packet layer,
+ * while OMS ports connect to an OMS port on a neighbouring ROADM.
+ *
+ * LINC exposes OchSignal resources: 80 lambdas of 50 GHz (fixed grid) around ITU-T G.694.1 center frequency 193.1 GHz.
+ */
+
+public class LincOELambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery {
+
+    private static final int LAMBDA_COUNT = 80;
+
+    @Override
+    public Set<OchSignal> queryLambdas(PortNumber port) {
+        DeviceService deviceService = this.handler().get(DeviceService.class);
+        Port p = deviceService.getPort(this.data().deviceId(), port);
+
+        // OCh ports don't expose lambda resources
+        if (!p.type().equals(Port.Type.OMS)) {
+            return Collections.emptySet();
+        }
+
+        // OMS ports expose 80 fixed grid lambdas of 50GHz width, centered around the ITU-T center frequency 193.1 THz.
+        return IntStream.range(0, LAMBDA_COUNT)
+                .mapToObj(x -> new OchSignal(GridType.DWDM, ChannelSpacing.CHL_50GHZ, x - (LAMBDA_COUNT / 2), 4))
+                .collect(Collectors.toSet());
+    }
+}
diff --git a/drivers/optical/src/main/java/org/onosproject/driver/optical/query/OFOpticalSwitch13LambdaQuery.java b/drivers/optical/src/main/java/org/onosproject/driver/optical/query/OFOpticalSwitch13LambdaQuery.java
new file mode 100644
index 0000000..838955b
--- /dev/null
+++ b/drivers/optical/src/main/java/org/onosproject/driver/optical/query/OFOpticalSwitch13LambdaQuery.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.onosproject.driver.optical.query;
+
+import org.onosproject.net.ChannelSpacing;
+import org.onosproject.net.OchSignal;
+import org.onosproject.net.Port;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.behaviour.LambdaQuery;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.driver.AbstractHandlerBehaviour;
+import org.onosproject.net.optical.OmsPort;
+
+import static org.onosproject.net.optical.device.OpticalDeviceServiceView.opticalView;
+
+import java.util.Collections;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.IntStream;
+
+/**
+ * Lambda query implementation for OFOpticalSwitch13.
+ *
+ * Note: Standard (ONF TS-022, March 15, 2015) does not support negative values for spacingMultiplier in exp_OCH_sigid.
+ * Thus, Lambda values cannot be calculated using center and spacingMultiplier of +/- values.
+ * Therefore, Lambda values are calculated with positive values only: starting from min-frequency of 191.7 THz.
+ *
+ * TODO: When standard is fixed - modify queryLambdas accordingly.
+ *
+ * OFOpticalSwitch13 exposes OchSignal resources: 'lambdaCount' lambdas with 50GHz width (fixed grid)
+ * starting from min-frequency of 191.7 THz.
+ */
+
+public class OFOpticalSwitch13LambdaQuery extends AbstractHandlerBehaviour implements LambdaQuery {
+
+    @Override
+    public Set<OchSignal> queryLambdas(PortNumber port) {
+        DeviceService deviceService = opticalView(this.handler().get(DeviceService.class));
+        Port p = deviceService.getPort(this.data().deviceId(), port);
+
+        // Only OMS ports expose lambda resources
+        if (!p.type().equals(Port.Type.OMS)) {
+            return Collections.emptySet();
+        }
+
+        short lambdaCount = ((OmsPort) p).totalChannels();
+        // OMS ports expose 'lambdaCount' fixed grid lambdas of 50GHz width, starting from min-frequency 191.7 THz.
+        return IntStream.rangeClosed(1, lambdaCount)
+                .mapToObj(x -> OchSignal.newDwdmSlot(ChannelSpacing.CHL_50GHZ, x))
+                .collect(Collectors.toSet());
+    }
+}
diff --git a/drivers/optical/src/main/java/org/onosproject/driver/optical/query/package-info.java b/drivers/optical/src/main/java/org/onosproject/driver/optical/query/package-info.java
new file mode 100644
index 0000000..5190f32
--- /dev/null
+++ b/drivers/optical/src/main/java/org/onosproject/driver/optical/query/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Implementations of the query driver behaviours for optical devices.
+ */
+package org.onosproject.driver.optical.query;
diff --git a/drivers/optical/src/main/java/org/onosproject/drivers/optical/OpticalDriversLoader.java b/drivers/optical/src/main/java/org/onosproject/drivers/optical/OpticalDriversLoader.java
new file mode 100644
index 0000000..4b84302
--- /dev/null
+++ b/drivers/optical/src/main/java/org/onosproject/drivers/optical/OpticalDriversLoader.java
@@ -0,0 +1,37 @@
+package org.onosproject.drivers.optical;
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+
+import org.apache.felix.scr.annotations.Component;
+import org.onosproject.net.driver.AbstractDriverLoader;
+import org.onosproject.net.optical.OpticalDevice;
+
+/**
+ * Loader for other optical device drivers.
+ */
+@Component(immediate = true)
+public class OpticalDriversLoader extends AbstractDriverLoader {
+
+    // OSGI: help bundle plugin discover runtime package dependency.
+    @SuppressWarnings("unused")
+    private OpticalDevice optical;
+
+    public OpticalDriversLoader() {
+        super("/optical-drivers.xml");
+    }
+}
diff --git a/drivers/optical/src/main/java/org/onosproject/drivers/optical/package-info.java b/drivers/optical/src/main/java/org/onosproject/drivers/optical/package-info.java
new file mode 100644
index 0000000..de01512
--- /dev/null
+++ b/drivers/optical/src/main/java/org/onosproject/drivers/optical/package-info.java
@@ -0,0 +1,19 @@
+/*
+ * Copyright 2016-present Open Networking Laboratory
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+/**
+ * Package for other optical device drivers.
+ */
+package org.onosproject.drivers.optical;
diff --git a/drivers/optical/src/main/resources/optical-drivers.xml b/drivers/optical/src/main/resources/optical-drivers.xml
new file mode 100644
index 0000000..0047895
--- /dev/null
+++ b/drivers/optical/src/main/resources/optical-drivers.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2016-present Open Networking Laboratory
+  ~
+  ~ Licensed under the Apache License, Version 2.0 (the "License");
+  ~ you may not use this file except in compliance with the License.
+  ~ You may obtain a copy of the License at
+  ~
+  ~     http://www.apache.org/licenses/LICENSE-2.0
+  ~
+  ~ Unless required by applicable law or agreed to in writing, software
+  ~ distributed under the License is distributed on an "AS IS" BASIS,
+  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  ~ See the License for the specific language governing permissions and
+  ~ limitations under the License.
+  -->
+<drivers>
+    <driver name="linc-oe" extends="default"
+            manufacturer="FlowForwarding.org" hwVersion="Unknown"
+            swVersion="LINC-OE OpenFlow Software Switch 1.1">
+        <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
+                   impl="org.onosproject.driver.optical.handshaker.OfOpticalSwitchImplLinc13"/>
+        <behaviour api="org.onosproject.net.behaviour.LambdaQuery"
+                   impl="org.onosproject.driver.optical.query.LincOELambdaQuery"/>
+        <behaviour api="org.onosproject.net.optical.OpticalDevice"
+                   impl="org.onosproject.net.optical.DefaultOpticalDevice"/>
+    </driver>
+
+    <driver name="calient" extends="default"
+            manufacturer="calient technologies inc" hwVersion="calient hardware.*"
+            swVersion="ocs software version.*">
+        <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
+                   impl="org.onosproject.driver.optical.handshaker.CalientFiberSwitchHandshaker"/>
+        <behaviour api="org.onosproject.net.behaviour.LambdaQuery"
+                   impl="org.onosproject.driver.optical.query.CalientLambdaQuery"/>
+    </driver>
+
+    <driver name="eci" extends="default"
+            manufacturer="ECI Telecom" hwVersion="Optical.*" swVersion="V_1_0">
+        <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
+                   impl="org.onosproject.driver.optical.handshaker.OFOpticalSwitch13"/>
+        <behaviour api="org.onosproject.net.behaviour.TributarySlotQuery"
+                   impl="org.onosproject.driver.optical.query.DefaultTributarySlotQuery" />
+        <behaviour api="org.onosproject.net.behaviour.LambdaQuery"
+                   impl="org.onosproject.driver.optical.query.OFOpticalSwitch13LambdaQuery"/>
+        <behaviour api="org.onosproject.net.optical.OpticalDevice"
+                   impl="org.onosproject.net.optical.DefaultOpticalDevice"/>
+    </driver>
+
+    <driver name="oplk-roadm" extends="default"
+            manufacturer="Oplink a Molex company" hwVersion="ROADM"
+            swVersion="of-agent">
+        <behaviour api="org.onosproject.openflow.controller.driver.OpenFlowSwitchDriver"
+                   impl="org.onosproject.driver.optical.handshaker.OplinkRoadmHandshaker"/>
+        <behaviour api="org.onosproject.net.optical.OpticalDevice"
+                   impl="org.onosproject.net.optical.DefaultOpticalDevice"/>
+    </driver>
+
+</drivers>
+