Cherry pick gNMI and Stratum related changes to this branch

Cherry picked commits:
20211 Update gNMI version and build script
20247 [ONOS-7829] Implement AbstractGrpcClient and AbstractGrpcClientControl
20233 [ONOS-7141][ONOS-7142] Add GnmiClient and GnmiController
20234 Refactor OpenConfig gNMI device description descovery
20260 [ONOS-7831] Implement GnmiHandshaker
20270 Add Stratum driver

Change-Id: I81ad8bce45251af5909cfcac0edbcfd11c8ebf1d
diff --git a/drivers/gnmi/BUILD b/drivers/gnmi/BUILD
index 50d8b5e..efc3f08 100644
--- a/drivers/gnmi/BUILD
+++ b/drivers/gnmi/BUILD
@@ -4,8 +4,8 @@
     "@io_grpc_grpc_java//netty",
     "@io_grpc_grpc_java//stub",
     "//core/store/serializers:onos-core-serializers",
-    "//protocols/gnmi/stub:gnmi_java_grpc",
-    "//protocols/gnmi/stub:gnmi_java_proto",
+    "//protocols/gnmi/stub:onos-protocols-gnmi-stub",
+    "//protocols/gnmi/api:onos-protocols-gnmi-api",
     "//protocols/grpc/api:onos-protocols-grpc-api",
     "//protocols/grpc/proto:onos-protocols-grpc-proto",
 ]
@@ -28,7 +28,6 @@
     included_bundles = BUNDLES,
     required_apps = [
         "org.onosproject.generaldeviceprovider",
-        "org.onosproject.protocols.grpc",
         "org.onosproject.protocols.gnmi",
     ],
     title = "gNMI Drivers",
diff --git a/drivers/gnmi/src/main/java/org/onosproject/drivers/gnmi/AbstractGnmiHandlerBehaviour.java b/drivers/gnmi/src/main/java/org/onosproject/drivers/gnmi/AbstractGnmiHandlerBehaviour.java
new file mode 100644
index 0000000..1e06c95
--- /dev/null
+++ b/drivers/gnmi/src/main/java/org/onosproject/drivers/gnmi/AbstractGnmiHandlerBehaviour.java
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.drivers.gnmi;
+
+import io.grpc.StatusRuntimeException;
+import org.onosproject.gnmi.api.GnmiClient;
+import org.onosproject.gnmi.api.GnmiClientKey;
+import org.onosproject.gnmi.api.GnmiController;
+import org.onosproject.net.Device;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.device.DeviceService;
+import org.onosproject.net.driver.AbstractHandlerBehaviour;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * Abstract implementation of a behaviour handler for a gNMI device.
+ */
+public class AbstractGnmiHandlerBehaviour extends AbstractHandlerBehaviour {
+
+    // Default timeout in seconds for device operations.
+    private static final String DEVICE_REQ_TIMEOUT = "deviceRequestTimeout";
+    private static final int DEFAULT_DEVICE_REQ_TIMEOUT = 60;
+
+    private static final String GNMI_SERVER_ADDR_KEY = "gnmi_ip";
+    private static final String GNMI_SERVER_PORT_KEY = "gnmi_port";
+
+    protected final Logger log = LoggerFactory.getLogger(getClass());
+    protected DeviceId deviceId;
+    protected DeviceService deviceService;
+    protected Device device;
+    protected GnmiController controller;
+    protected GnmiClient client;
+
+    protected boolean setupBehaviour() {
+        deviceId = handler().data().deviceId();
+
+        controller = handler().get(GnmiController.class);
+        client = controller.getClient(deviceId);
+
+        if (client == null) {
+            log.warn("Unable to find client for {}, aborting operation", deviceId);
+            return false;
+        }
+
+        return true;
+    }
+
+    GnmiClient createClient() {
+        deviceId = handler().data().deviceId();
+        controller = handler().get(GnmiController.class);
+
+        final String serverAddr = this.data().value(GNMI_SERVER_ADDR_KEY);
+        final String serverPortString = this.data().value(GNMI_SERVER_PORT_KEY);
+
+        if (serverAddr == null || serverPortString == null) {
+            log.warn("Unable to create client for {}, missing driver data key (required is {} and {})",
+                    deviceId, GNMI_SERVER_ADDR_KEY, GNMI_SERVER_PORT_KEY);
+            return null;
+        }
+
+        final int serverPort;
+        try {
+            serverPort = Integer.parseUnsignedInt(serverPortString);
+        } catch (NumberFormatException e) {
+            log.error("{} is not a valid port number", serverPortString);
+            return null;
+        }
+        GnmiClientKey clientKey = new GnmiClientKey(deviceId, serverAddr, serverPort);
+        if (!controller.createClient(clientKey)) {
+            log.warn("Unable to create client for {}, aborting operation", deviceId);
+            return null;
+        }
+        return controller.getClient(deviceId);
+    }
+
+    /**
+     * Returns the device request timeout driver property, or a default value
+     * if the property is not present or cannot be parsed.
+     *
+     * @return timeout value
+     */
+    private int getDeviceRequestTimeout() {
+        final String timeout = handler().driver()
+                .getProperty(DEVICE_REQ_TIMEOUT);
+        if (timeout == null) {
+            return DEFAULT_DEVICE_REQ_TIMEOUT;
+        } else {
+            try {
+                return Integer.parseInt(timeout);
+            } catch (NumberFormatException e) {
+                log.error("{} driver property '{}' is not a number, using default value {}",
+                        DEVICE_REQ_TIMEOUT, timeout, DEFAULT_DEVICE_REQ_TIMEOUT);
+                return DEFAULT_DEVICE_REQ_TIMEOUT;
+            }
+        }
+    }
+
+    /**
+     * Convenience method to get the result of a completable future while
+     * setting a timeout and checking for exceptions.
+     *
+     * @param future        completable future
+     * @param opDescription operation description to use in log messages. Should
+     *                      be a sentence starting with a verb ending in -ing,
+     *                      e.g. "reading...", "writing...", etc.
+     * @param defaultValue  value to return if operation fails
+     * @param <U>           type of returned value
+     * @return future result or default value
+     */
+    <U> U getFutureWithDeadline(CompletableFuture<U> future, String opDescription,
+                                U defaultValue) {
+        try {
+            return future.get(getDeviceRequestTimeout(), TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+            log.error("Exception while {} on {}", opDescription, deviceId);
+        } catch (ExecutionException e) {
+            final Throwable cause = e.getCause();
+            if (cause instanceof StatusRuntimeException) {
+                final StatusRuntimeException grpcError = (StatusRuntimeException) cause;
+                log.warn("Error while {} on {}: {}", opDescription, deviceId, grpcError.getMessage());
+            } else {
+                log.error("Exception while {} on {}", opDescription, deviceId, e.getCause());
+            }
+        } catch (TimeoutException e) {
+            log.error("Operation TIMEOUT while {} on {}", opDescription, deviceId);
+        }
+        return defaultValue;
+    }
+}
diff --git a/drivers/gnmi/src/main/java/org/onosproject/drivers/gnmi/GnmiDeviceDescriptionDiscovery.java b/drivers/gnmi/src/main/java/org/onosproject/drivers/gnmi/GnmiDeviceDescriptionDiscovery.java
deleted file mode 100644
index 843231e..0000000
--- a/drivers/gnmi/src/main/java/org/onosproject/drivers/gnmi/GnmiDeviceDescriptionDiscovery.java
+++ /dev/null
@@ -1,310 +0,0 @@
-/*
- * Copyright 2017-present Open Networking Foundation
- *
- * 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.drivers.gnmi;
-
-import com.google.common.collect.ImmutableList;
-import gnmi.gNMIGrpc;
-import io.grpc.ManagedChannel;
-import io.grpc.ManagedChannelBuilder;
-import io.grpc.Status;
-import io.grpc.StatusRuntimeException;
-import io.grpc.netty.NettyChannelBuilder;
-import io.grpc.stub.StreamObserver;
-import org.onosproject.grpc.api.GrpcChannelId;
-import org.onosproject.grpc.api.GrpcController;
-import org.onosproject.net.DefaultAnnotations;
-import org.onosproject.net.DeviceId;
-import org.onosproject.net.Port;
-import org.onosproject.net.PortNumber;
-import org.onosproject.net.device.DefaultPortDescription;
-import org.onosproject.net.device.DeviceDescription;
-import org.onosproject.net.device.DeviceDescriptionDiscovery;
-import org.onosproject.net.device.PortDescription;
-import org.onosproject.net.driver.AbstractHandlerBehaviour;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.concurrent.CompletableFuture;
-import java.util.concurrent.ExecutionException;
-import java.util.concurrent.TimeUnit;
-import java.util.concurrent.TimeoutException;
-
-import static gnmi.Gnmi.Path;
-import static gnmi.Gnmi.PathElem;
-import static gnmi.Gnmi.SubscribeRequest;
-import static gnmi.Gnmi.SubscribeResponse;
-import static gnmi.Gnmi.Subscription;
-import static gnmi.Gnmi.SubscriptionList;
-import static gnmi.Gnmi.Update;
-
-/**
- * Class that discovers the device description and ports of a device that
- * supports the gNMI protocol and Openconfig models.
- */
-public class GnmiDeviceDescriptionDiscovery
-        extends AbstractHandlerBehaviour
-        implements DeviceDescriptionDiscovery {
-
-    private static final int REQUEST_TIMEOUT_SECONDS = 5;
-
-    private static final Logger log = LoggerFactory
-            .getLogger(GnmiDeviceDescriptionDiscovery.class);
-
-    private static final String GNMI_SERVER_ADDR_KEY = "gnmi_ip";
-    private static final String GNMI_SERVER_PORT_KEY = "gnmi_port";
-
-    @Override
-    public DeviceDescription discoverDeviceDetails() {
-        return null;
-    }
-
-    @Override
-    public List<PortDescription> discoverPortDetails() {
-        log.info("Discovering port details on device {}", handler().data().deviceId());
-
-        String serverAddr = this.data().value(GNMI_SERVER_ADDR_KEY);
-        String serverPortString = this.data().value(GNMI_SERVER_PORT_KEY);
-
-        if (serverAddr == null || serverPortString == null ||
-                serverAddr.isEmpty() || serverPortString.isEmpty()) {
-            log.warn("gNMI server information not provided, can't discover ports");
-            return ImmutableList.of();
-        }
-
-        // Get the channel
-        ManagedChannel channel = getChannel(serverAddr, serverPortString);
-
-        if (channel == null) {
-            return ImmutableList.of();
-        }
-
-        // Build the subscribe request
-        SubscribeRequest request = subscribeRequest();
-
-        // New stub
-        gNMIGrpc.gNMIStub gnmiStub = gNMIGrpc.newStub(channel);
-
-        final CompletableFuture<List<PortDescription>>
-                reply = new CompletableFuture<>();
-
-        // Subscribe to the replies
-        StreamObserver<SubscribeRequest> subscribeRequest = gnmiStub
-                .subscribe(new SubscribeResponseObserver(reply));
-        log.debug("Interfaces request {}", request);
-
-        List<PortDescription> ports;
-        try {
-            // Issue the request
-            subscribeRequest.onNext(request);
-            ports = reply.get(REQUEST_TIMEOUT_SECONDS, TimeUnit.SECONDS);
-        } catch (InterruptedException | ExecutionException | TimeoutException
-                | StatusRuntimeException e) {
-            log.warn("Unable to discover ports from {}: {}",
-                    data().deviceId(), e.getMessage());
-            log.debug("{}", e);
-            return ImmutableList.of();
-        } finally {
-            subscribeRequest.onCompleted();
-        }
-
-        return ports;
-    }
-
-    /**
-     * Obtains the ManagedChannel to be used for the communication.
-     *
-     * @return the managed channel
-     */
-    private ManagedChannel getChannel(String serverAddr, String serverPortString) {
-
-        DeviceId deviceId = handler().data().deviceId();
-
-        GrpcController controller = handler().get(GrpcController.class);
-        ManagedChannel channel = null;
-
-        //FIXME can be optimized
-        //getting a channel if exists.
-        ManagedChannel managedChannel = controller
-                .getChannels(handler().data().deviceId()).stream().filter(c -> {
-                    String[] authority = c.authority().split(":");
-                    String host = authority[0];
-                    String port = authority[1];
-                    return host.equals(serverAddr) && port.equals(serverPortString);
-                }).findAny().orElse(null);
-
-        if (managedChannel != null) {
-            log.debug("Reusing Channel");
-            channel = managedChannel;
-        } else {
-            log.debug("Creating Channel");
-            GrpcChannelId newChannelId = GrpcChannelId.of(deviceId, "gnmi");
-
-            ManagedChannelBuilder channelBuilder = NettyChannelBuilder
-                    .forAddress(serverAddr, Integer.valueOf(serverPortString))
-                    .usePlaintext(true);
-
-            try {
-                channel = controller.connectChannel(newChannelId, channelBuilder);
-            } catch (IOException e) {
-                log.warn("Unable to connect to gRPC server of {}: {}",
-                        deviceId, e.getMessage());
-            }
-        }
-        return channel;
-    }
-
-    /**
-     * Creates the subscribe request for the interfaces.
-     *
-     * @return subscribe request
-     */
-    private SubscribeRequest subscribeRequest() {
-        Path path = Path.newBuilder()
-                .addElem(PathElem.newBuilder().setName("interfaces").build())
-                .addElem(PathElem.newBuilder().setName("interface").build())
-                .addElem(PathElem.newBuilder().setName("...").build())
-                .build();
-        Subscription subscription = Subscription.newBuilder().setPath(path).build();
-        SubscriptionList list = SubscriptionList.newBuilder().setMode(SubscriptionList.Mode.ONCE)
-                .addSubscription(subscription).build();
-        return SubscribeRequest.newBuilder().setSubscribe(list).build();
-    }
-
-    /**
-     * Handles messages received from the device on the stream channel.
-     */
-    private final class SubscribeResponseObserver
-            implements StreamObserver<SubscribeResponse> {
-
-        private final CompletableFuture<List<PortDescription>> reply;
-
-        private SubscribeResponseObserver(CompletableFuture<List<PortDescription>> reply) {
-            this.reply = reply;
-        }
-
-        @Override
-        public void onNext(SubscribeResponse message) {
-            Map<String, DefaultPortDescription.Builder> ports = new HashMap<>();
-            Map<String, DefaultAnnotations.Builder> portsAnnotations = new HashMap<>();
-            log.debug("Response {} ", message.getUpdate().toString());
-            message.getUpdate().getUpdateList().forEach(update -> {
-                parseUpdate(ports, portsAnnotations, update);
-            });
-
-            List<PortDescription> portDescriptionList = new ArrayList<>();
-            ports.forEach((k, v) -> {
-//                v.portSpeed(1000L);
-                v.type(Port.Type.COPPER);
-                v.annotations(portsAnnotations.get(k).set("name", k).build());
-                portDescriptionList.add(v.build());
-            });
-
-            reply.complete(portDescriptionList);
-        }
-
-
-        @Override
-        public void onError(Throwable throwable) {
-            log.warn("Error on stream channel for {}: {}",
-                    data().deviceId(), Status.fromThrowable(throwable));
-            log.debug("{}", throwable);
-        }
-
-        @Override
-        public void onCompleted() {
-            log.debug("SubscribeResponseObserver completed");
-        }
-    }
-
-    /**
-     * Parses the update received from the device.
-     *
-     * @param ports            the ports description to build
-     * @param portsAnnotations the ports annotations list to populate
-     * @param update           the update received
-     */
-    private void parseUpdate(Map<String, DefaultPortDescription.Builder> ports,
-                             Map<String, DefaultAnnotations.Builder> portsAnnotations,
-                             Update update) {
-
-        //FIXME crude parsing, can be done via object (de)serialization
-        if (update.getPath().getElemList().size() > 3) {
-            String name = update.getPath().getElem(3).getName();
-            String portId = update.getPath().getElem(1).getKeyMap().get("name");
-            if (!ports.containsKey(portId)) {
-                int number = Character.getNumericValue(portId.charAt(portId.length() - 1));
-                PortNumber portNumber = PortNumber.portNumber(number, portId);
-                ports.put(portId, DefaultPortDescription.builder()
-                        .withPortNumber(portNumber));
-            }
-            if (name.equals("enabled")) {
-                DefaultPortDescription.Builder builder = ports.get(portId);
-                builder = builder.isEnabled(update.getVal().getBoolVal());
-                ports.put(portId, builder);
-            } else if (name.equals("state")) {
-                String speedName = update.getPath().getElem(4).getName();
-                if (speedName.equals("negotiated-port-speed")) {
-                    DefaultPortDescription.Builder builder = ports.get(portId);
-                    long speed = parsePortSpeed(update.getVal().getStringVal());
-                    builder = builder.portSpeed(speed);
-                    ports.put(portId, builder);
-                }
-            } else if (!name.equals("ifindex")) {
-                if (!portsAnnotations.containsKey(portId)) {
-                    portsAnnotations.put(portId, DefaultAnnotations.builder()
-                            .set(name, update.getVal().toByteString()
-                                    .toString(Charset.defaultCharset()).trim()));
-                } else {
-                    DefaultAnnotations.Builder builder = portsAnnotations.get(portId);
-                    builder = builder.set(name, update.getVal().toByteString().
-                            toString(Charset.defaultCharset()).trim());
-                    portsAnnotations.put(portId, builder);
-                }
-            }
-        }
-    }
-
-    private long parsePortSpeed(String speed) {
-        log.debug("Speed from config {}", speed);
-        switch (speed) {
-            case "SPEED_10MB":
-                return 10;
-            case "SPEED_100MB":
-                return 10;
-            case "SPEED_1GB":
-                return 1000;
-            case "SPEED_10GB":
-                return 10000;
-            case "SPEED_25GB":
-                return 25000;
-            case "SPEED_40GB":
-                return 40000;
-            case "SPEED_50GB":
-                return 50000;
-            case "SPEED_100GB":
-                return 100000;
-            default:
-                return 1000;
-        }
-    }
-}
diff --git a/drivers/gnmi/src/main/java/org/onosproject/drivers/gnmi/GnmiHandshaker.java b/drivers/gnmi/src/main/java/org/onosproject/drivers/gnmi/GnmiHandshaker.java
new file mode 100644
index 0000000..c443460
--- /dev/null
+++ b/drivers/gnmi/src/main/java/org/onosproject/drivers/gnmi/GnmiHandshaker.java
@@ -0,0 +1,99 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.drivers.gnmi;
+
+import org.onosproject.gnmi.api.GnmiClient;
+import org.onosproject.gnmi.api.GnmiController;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.MastershipRole;
+import org.onosproject.net.device.DeviceHandshaker;
+
+import java.util.concurrent.CompletableFuture;
+
+/**
+ * Implementation of DeviceHandshaker for gNMI.
+ */
+public class GnmiHandshaker extends AbstractGnmiHandlerBehaviour implements DeviceHandshaker {
+
+    @Override
+    public CompletableFuture<Boolean> isReachable() {
+        return CompletableFuture
+                // gNMI requires a client to be created to
+                // check for reachability.
+                .supplyAsync(super::createClient)
+                .thenApplyAsync(client -> {
+                    if (client == null) {
+                        return false;
+                    }
+                    return handler()
+                            .get(GnmiController.class)
+                            .isReachable(handler().data().deviceId());
+                });
+    }
+
+    @Override
+    public void roleChanged(MastershipRole newRole) {
+        throw new UnsupportedOperationException("Mastership operation not supported");
+    }
+
+    @Override
+    public MastershipRole getRole() {
+        throw new UnsupportedOperationException("Mastership operation not supported");
+    }
+
+    @Override
+    public CompletableFuture<Boolean> connect() {
+        return CompletableFuture
+                .supplyAsync(super::createClient)
+                .thenComposeAsync(client -> {
+                    if (client == null) {
+                        return CompletableFuture.completedFuture(false);
+                    }
+                    return CompletableFuture.completedFuture(true);
+                });
+    }
+
+    @Override
+    public boolean isConnected() {
+        final GnmiController controller = handler().get(GnmiController.class);
+        final DeviceId deviceId = handler().data().deviceId();
+        final GnmiClient client = controller.getClient(deviceId);
+
+        if (client == null) {
+            return false;
+        }
+
+        return getFutureWithDeadline(
+                client.isServiceAvailable(),
+                "checking if gNMI service is available", false);
+    }
+
+    @Override
+    public CompletableFuture<Boolean> disconnect() {
+        final GnmiController controller = handler().get(GnmiController.class);
+        final DeviceId deviceId = handler().data().deviceId();
+        final GnmiClient client = controller.getClient(deviceId);
+        if (client == null) {
+            return CompletableFuture.completedFuture(true);
+        }
+        return client.shutdown()
+                .thenApplyAsync(v -> {
+                    controller.removeClient(deviceId);
+                    return true;
+                });
+    }
+}
diff --git a/drivers/gnmi/src/main/java/org/onosproject/drivers/gnmi/OpenConfigGnmiDeviceDescriptionDiscovery.java b/drivers/gnmi/src/main/java/org/onosproject/drivers/gnmi/OpenConfigGnmiDeviceDescriptionDiscovery.java
new file mode 100644
index 0000000..526c333
--- /dev/null
+++ b/drivers/gnmi/src/main/java/org/onosproject/drivers/gnmi/OpenConfigGnmiDeviceDescriptionDiscovery.java
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2017-present Open Networking Foundation
+ *
+ * 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.drivers.gnmi;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import gnmi.Gnmi;
+import gnmi.Gnmi.GetRequest;
+import gnmi.Gnmi.GetResponse;
+import org.onosproject.net.DefaultAnnotations;
+import org.onosproject.net.PortNumber;
+import org.onosproject.net.device.DefaultPortDescription;
+import org.onosproject.net.device.DeviceDescription;
+import org.onosproject.net.device.DeviceDescriptionDiscovery;
+import org.onosproject.net.device.PortDescription;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+
+import static gnmi.Gnmi.Path;
+import static gnmi.Gnmi.PathElem;
+import static gnmi.Gnmi.Update;
+
+/**
+ * Class that discovers the device description and ports of a device that
+ * supports the gNMI protocol and Openconfig models.
+ */
+public class OpenConfigGnmiDeviceDescriptionDiscovery
+        extends AbstractGnmiHandlerBehaviour
+        implements DeviceDescriptionDiscovery {
+
+    private static final Logger log = LoggerFactory
+            .getLogger(OpenConfigGnmiDeviceDescriptionDiscovery.class);
+
+    @Override
+    public DeviceDescription discoverDeviceDetails() {
+        return null;
+    }
+
+    @Override
+    public List<PortDescription> discoverPortDetails() {
+        if (!setupBehaviour()) {
+            return Collections.emptyList();
+        }
+        log.debug("Discovering port details on device {}", handler().data().deviceId());
+
+        final GetResponse response = getFutureWithDeadline(
+                client.get(buildPortStateRequest()),
+                "getting port details", GetResponse.getDefaultInstance());
+
+        final Map<String, DefaultPortDescription.Builder> ports = Maps.newHashMap();
+        final Map<String, DefaultAnnotations.Builder> annotations = Maps.newHashMap();
+
+        // Creates port descriptions with port name and port number
+        response.getNotificationList()
+                .stream()
+                .flatMap(notification -> notification.getUpdateList().stream())
+                .forEach(update -> {
+                    // /interfaces/interface[name=ifName]/state/...
+                    final String ifName = update.getPath().getElem(1)
+                            .getKeyMap().get("name");
+                    if (!ports.containsKey(ifName)) {
+                        ports.put(ifName, DefaultPortDescription.builder());
+                        annotations.put(ifName, DefaultAnnotations.builder());
+                    }
+                    final DefaultPortDescription.Builder builder = ports.get(ifName);
+                    final DefaultAnnotations.Builder annotationsBuilder = annotations.get(ifName);
+                    parseInterfaceInfo(update, ifName, builder, annotationsBuilder);
+                });
+
+        final List<PortDescription> portDescriptionList = Lists.newArrayList();
+        ports.forEach((key, value) -> {
+            DefaultAnnotations annotation = annotations.get(key).build();
+            portDescriptionList.add(value.annotations(annotation).build());
+        });
+        return portDescriptionList;
+    }
+
+    private GetRequest buildPortStateRequest() {
+        Path path = Path.newBuilder()
+                .addElem(PathElem.newBuilder().setName("interfaces").build())
+                .addElem(PathElem.newBuilder().setName("interface").putKey("name", "...").build())
+                .addElem(PathElem.newBuilder().setName("state").build())
+                .build();
+        return GetRequest.newBuilder()
+                .addPath(path)
+                .setType(GetRequest.DataType.ALL)
+                .setEncoding(Gnmi.Encoding.PROTO)
+                .build();
+    }
+
+    /**
+     * Parses the interface information.
+     *
+     * @param update the update received
+     */
+    private void parseInterfaceInfo(Update update,
+                                    String ifName,
+                                    DefaultPortDescription.Builder builder,
+                                    DefaultAnnotations.Builder annotationsBuilder) {
+
+
+        final Path path = update.getPath();
+        final List<PathElem> elems = path.getElemList();
+        final Gnmi.TypedValue val = update.getVal();
+        if (elems.size() == 4) {
+            // /interfaces/interface/state/ifindex
+            // /interfaces/interface/state/oper-status
+            final String pathElemName = elems.get(3).getName();
+            switch (pathElemName) {
+                case "ifindex": // port number
+                    builder.withPortNumber(PortNumber.portNumber(val.getUintVal(), ifName));
+                    return;
+                case "oper-status":
+                    builder.isEnabled(parseOperStatus(val.getStringVal()));
+                    return;
+                default:
+                    break;
+            }
+        } else if (elems.size() == 5) {
+            // /interfaces/interface/ethernet/config/port-speed
+            final String pathElemName = elems.get(4).getName();
+            if (pathElemName.equals("port-speed")) {
+                builder.portSpeed(parsePortSpeed(val.getStringVal()));
+                return;
+            }
+        }
+        log.debug("Unknown path when parsing interface info: {}", path);
+    }
+
+    private boolean parseOperStatus(String operStatus) {
+        switch (operStatus) {
+            case "UP":
+                return true;
+            case "DOWN":
+            default:
+                return false;
+        }
+    }
+
+    private long parsePortSpeed(String speed) {
+        log.debug("Speed from config {}", speed);
+        switch (speed) {
+            case "SPEED_10MB":
+                return 10;
+            case "SPEED_100MB":
+                return 100;
+            case "SPEED_1GB":
+                return 1000;
+            case "SPEED_10GB":
+                return 10000;
+            case "SPEED_25GB":
+                return 25000;
+            case "SPEED_40GB":
+                return 40000;
+            case "SPEED_50GB":
+                return 50000;
+            case "SPEED_100GB":
+                return 100000;
+            default:
+                log.warn("Unrecognized port speed string '{}'", speed);
+                return 1000;
+        }
+    }
+}
diff --git a/drivers/gnmi/src/main/resources/gnmi-drivers.xml b/drivers/gnmi/src/main/resources/gnmi-drivers.xml
index 3744781..70c0b20 100644
--- a/drivers/gnmi/src/main/resources/gnmi-drivers.xml
+++ b/drivers/gnmi/src/main/resources/gnmi-drivers.xml
@@ -17,7 +17,9 @@
 <drivers>
     <driver name="gnmi" manufacturer="gnmi" hwVersion="master" swVersion="master">
         <behaviour api="org.onosproject.net.device.DeviceDescriptionDiscovery"
-                   impl="org.onosproject.drivers.gnmi.GnmiDeviceDescriptionDiscovery"/>
+                   impl="org.onosproject.drivers.gnmi.OpenConfigGnmiDeviceDescriptionDiscovery"/>
+        <behaviour api="org.onosproject.net.device.DeviceHandshaker"
+                   impl="org.onosproject.drivers.gnmi.GnmiHandshaker"/>
     </driver>
 </drivers>
 
diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/AbstractP4RuntimeHandlerBehaviour.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/AbstractP4RuntimeHandlerBehaviour.java
index 3f6c9ad..7f9c8c6 100644
--- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/AbstractP4RuntimeHandlerBehaviour.java
+++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/AbstractP4RuntimeHandlerBehaviour.java
@@ -27,6 +27,7 @@
 import org.onosproject.net.pi.service.PiPipeconfService;
 import org.onosproject.net.pi.service.PiTranslationService;
 import org.onosproject.p4runtime.api.P4RuntimeClient;
+import org.onosproject.p4runtime.api.P4RuntimeClientKey;
 import org.onosproject.p4runtime.api.P4RuntimeController;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -47,9 +48,9 @@
     private static final String DEVICE_REQ_TIMEOUT = "deviceRequestTimeout";
     private static final int DEFAULT_DEVICE_REQ_TIMEOUT = 60;
 
-    public static final String P4RUNTIME_SERVER_ADDR_KEY = "p4runtime_ip";
-    public static final String P4RUNTIME_SERVER_PORT_KEY = "p4runtime_port";
-    public static final String P4RUNTIME_DEVICE_ID_KEY = "p4runtime_deviceId";
+    private static final String P4RUNTIME_SERVER_ADDR_KEY = "p4runtime_ip";
+    private static final String P4RUNTIME_SERVER_PORT_KEY = "p4runtime_port";
+    private static final String P4RUNTIME_DEVICE_ID_KEY = "p4runtime_deviceId";
 
     protected final Logger log = LoggerFactory.getLogger(getClass());
 
@@ -60,7 +61,7 @@
     protected P4RuntimeController controller;
     protected PiPipeconf pipeconf;
     protected P4RuntimeClient client;
-    protected PiTranslationService piTranslationService;
+    protected PiTranslationService translationService;
 
     /**
      * Initializes this behaviour attributes. Returns true if the operation was
@@ -101,7 +102,7 @@
         }
         pipeconf = piPipeconfService.getPipeconf(pipeconfId).get();
 
-        piTranslationService = handler().get(PiTranslationService.class);
+        translationService = handler().get(PiTranslationService.class);
 
         return true;
     }
@@ -157,7 +158,9 @@
             return null;
         }
 
-        if (!controller.createClient(deviceId, serverAddr, serverPort, p4DeviceId)) {
+        final P4RuntimeClientKey clientKey = new P4RuntimeClientKey(
+                deviceId, serverAddr, serverPort, p4DeviceId);
+        if (!controller.createClient(clientKey)) {
             log.warn("Unable to create client for {}, aborting operation", deviceId);
             return null;
         }
@@ -173,7 +176,7 @@
      * @param defaultVal default value
      * @return boolean
      */
-    protected boolean driverBoolProperty(String propName, boolean defaultVal) {
+    boolean driverBoolProperty(String propName, boolean defaultVal) {
         checkNotNull(propName);
         if (handler().driver().getProperty(propName) == null) {
             return defaultVal;
diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeActionGroupProgrammable.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeActionGroupProgrammable.java
index f0d035b..070207f 100644
--- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeActionGroupProgrammable.java
+++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeActionGroupProgrammable.java
@@ -96,7 +96,7 @@
         groupMirror = this.handler().get(P4RuntimeGroupMirror.class);
         memberMirror = this.handler().get(P4RuntimeActionProfileMemberMirror.class);
         groupStore = handler().get(GroupStore.class);
-        groupTranslator = piTranslationService.groupTranslator();
+        groupTranslator = translationService.groupTranslator();
         return true;
     }
 
diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeFlowRuleProgrammable.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeFlowRuleProgrammable.java
index 5a233ef..693353f 100644
--- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeFlowRuleProgrammable.java
+++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeFlowRuleProgrammable.java
@@ -118,7 +118,7 @@
 
         pipelineModel = pipeconf.pipelineModel();
         tableMirror = handler().get(P4RuntimeTableMirror.class);
-        translator = piTranslationService.flowRuleTranslator();
+        translator = translationService.flowRuleTranslator();
         return true;
     }
 
diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeMeterProgrammable.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeMeterProgrammable.java
index 39ed84d..f2dff80 100644
--- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeMeterProgrammable.java
+++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeMeterProgrammable.java
@@ -74,7 +74,7 @@
             return false;
         }
 
-        translator = piTranslationService.meterTranslator();
+        translator = translationService.meterTranslator();
         meterMirror = handler().get(P4RuntimeMeterMirror.class);
         pipelineModel = pipeconf.pipelineModel();
         return true;
diff --git a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeMulticastGroupProgrammable.java b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeMulticastGroupProgrammable.java
index a5c3538..ecdda08 100644
--- a/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeMulticastGroupProgrammable.java
+++ b/drivers/p4runtime/src/main/java/org/onosproject/drivers/p4runtime/P4RuntimeMulticastGroupProgrammable.java
@@ -66,7 +66,7 @@
         }
         mcGroupMirror = this.handler().get(P4RuntimeMulticastGroupMirror.class);
         groupStore = handler().get(GroupStore.class);
-        mcGroupTranslator = piTranslationService.multicastGroupTranslator();
+        mcGroupTranslator = translationService.multicastGroupTranslator();
         return true;
     }
 
diff --git a/drivers/stratum/BUILD b/drivers/stratum/BUILD
new file mode 100644
index 0000000..41db9f1
--- /dev/null
+++ b/drivers/stratum/BUILD
@@ -0,0 +1,25 @@
+COMPILE_DEPS = CORE_DEPS + KRYO + JACKSON + [
+    "@io_grpc_grpc_java//core",
+    "//drivers/p4runtime:onos-drivers-p4runtime",
+    "//drivers/gnmi:onos-drivers-gnmi",
+    "//pipelines/basic:onos-pipelines-basic",
+]
+
+osgi_jar(
+    resources = glob(["src/main/resources/**"]),
+    resources_root = "src/main/resources",
+    deps = COMPILE_DEPS,
+)
+
+onos_app(
+    app_name = "org.onosproject.drivers.stratum",
+    category = "Drivers",
+    description = "Adds support for Stratum-based devices",
+    required_apps = [
+        "org.onosproject.generaldeviceprovider",
+        "org.onosproject.drivers.gnmi",
+        "org.onosproject.drivers.p4runtime",
+    ],
+    title = "Stratum Drivers",
+    url = "http://onosproject.org",
+)
diff --git a/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/StratumDriversLoader.java b/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/StratumDriversLoader.java
new file mode 100644
index 0000000..d022dd4
--- /dev/null
+++ b/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/StratumDriversLoader.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.drivers.stratum;
+
+import org.apache.felix.scr.annotations.Component;
+import org.onosproject.net.driver.AbstractDriverLoader;
+
+/**
+ * Loader for Stratum Switch device drivers.
+ */
+@Component(immediate = true)
+public class StratumDriversLoader extends AbstractDriverLoader {
+
+    public StratumDriversLoader() {
+        super("/stratum-drivers.xml");
+    }
+}
diff --git a/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/StratumHandshaker.java b/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/StratumHandshaker.java
new file mode 100644
index 0000000..4e169a5
--- /dev/null
+++ b/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/StratumHandshaker.java
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.drivers.stratum;
+
+import io.grpc.StatusRuntimeException;
+import org.onosproject.drivers.gnmi.GnmiHandshaker;
+import org.onosproject.drivers.p4runtime.P4RuntimeHandshaker;
+import org.onosproject.net.DeviceId;
+import org.onosproject.net.MastershipRole;
+import org.onosproject.net.device.DeviceAgentListener;
+import org.onosproject.net.device.DeviceHandshaker;
+import org.onosproject.net.driver.AbstractHandlerBehaviour;
+import org.onosproject.net.driver.DriverData;
+import org.onosproject.net.driver.DriverHandler;
+import org.onosproject.net.provider.ProviderId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.TimeoutException;
+
+/**
+ * Implementation of DeviceHandshaker for Stratum device.
+ */
+public class StratumHandshaker extends AbstractHandlerBehaviour implements DeviceHandshaker {
+
+    private static final Logger log = LoggerFactory.getLogger(StratumHandshaker.class);
+    private static final int DEFAULT_DEVICE_REQ_TIMEOUT = 10;
+
+    private P4RuntimeHandshaker p4RuntimeHandshaker;
+    private GnmiHandshaker gnmiHandshaker;
+    private DeviceId deviceId;
+
+    public StratumHandshaker() {
+        p4RuntimeHandshaker = new P4RuntimeHandshaker();
+        gnmiHandshaker = new GnmiHandshaker();
+    }
+
+    @Override
+    public void setHandler(DriverHandler handler) {
+        super.setHandler(handler);
+        p4RuntimeHandshaker.setHandler(handler);
+        gnmiHandshaker.setHandler(handler);
+    }
+
+    @Override
+    public void setData(DriverData data) {
+        super.setData(data);
+        p4RuntimeHandshaker.setData(data);
+        gnmiHandshaker.setData(data);
+        deviceId = data.deviceId();
+    }
+
+    @Override
+    public CompletableFuture<Boolean> isReachable() {
+        return p4RuntimeHandshaker.isReachable()
+                .thenCombine(gnmiHandshaker.isReachable(), Boolean::logicalAnd);
+    }
+
+    @Override
+    public void roleChanged(MastershipRole newRole) {
+        p4RuntimeHandshaker.roleChanged(newRole);
+        // gNMI doesn't support mastership handling.
+    }
+
+    @Override
+    public MastershipRole getRole() {
+        return p4RuntimeHandshaker.getRole();
+    }
+
+    @Override
+    public void addDeviceAgentListener(ProviderId providerId, DeviceAgentListener listener) {
+        p4RuntimeHandshaker.addDeviceAgentListener(providerId, listener);
+    }
+
+    @Override
+    public void removeDeviceAgentListener(ProviderId providerId) {
+        p4RuntimeHandshaker.removeDeviceAgentListener(providerId);
+    }
+
+    @Override
+    public CompletableFuture<Boolean> connect() {
+        return p4RuntimeHandshaker.connect()
+                .thenCombine(gnmiHandshaker.connect(), Boolean::logicalAnd);
+    }
+
+    @Override
+    public boolean isConnected() {
+        final CompletableFuture<Boolean> p4runtimeConnected =
+                CompletableFuture.supplyAsync(p4RuntimeHandshaker::isConnected);
+        final CompletableFuture<Boolean> gnmiConnected =
+                CompletableFuture.supplyAsync(gnmiHandshaker::isConnected);
+
+        try {
+            return p4runtimeConnected
+                    .thenCombine(gnmiConnected, Boolean::logicalAnd)
+                    .get(DEFAULT_DEVICE_REQ_TIMEOUT, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+            log.error("Exception while checking connectivity on {}", data().deviceId());
+        } catch (ExecutionException e) {
+            final Throwable cause = e.getCause();
+            if (cause instanceof StatusRuntimeException) {
+                final StatusRuntimeException grpcError = (StatusRuntimeException) cause;
+                log.warn("Error while checking connectivity on {}: {}", deviceId, grpcError.getMessage());
+            } else {
+                log.error("Exception while checking connectivity on {}", deviceId, e.getCause());
+            }
+        } catch (TimeoutException e) {
+            log.error("Operation TIMEOUT while checking connectivity on {}", deviceId);
+        }
+        return false;
+    }
+
+    @Override
+    public CompletableFuture<Boolean> disconnect() {
+        return p4RuntimeHandshaker.disconnect()
+                .thenCombine(gnmiHandshaker.disconnect(), Boolean::logicalAnd);
+    }
+}
diff --git a/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/dummy/StratumDummyPipelineProgrammable.java b/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/dummy/StratumDummyPipelineProgrammable.java
new file mode 100644
index 0000000..e07e3b3
--- /dev/null
+++ b/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/dummy/StratumDummyPipelineProgrammable.java
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.drivers.stratum.dummy;
+
+import org.onosproject.drivers.p4runtime.AbstractP4RuntimePipelineProgrammable;
+import org.onosproject.net.behaviour.PiPipelineProgrammable;
+import org.onosproject.net.pi.model.PiPipeconf;
+import org.onosproject.pipelines.basic.PipeconfLoader;
+
+import java.nio.ByteBuffer;
+import java.util.Optional;
+
+/**
+ * Implementation of the PiPipelineProgrammable behavior for Dummy Stratum Switch.
+ */
+public class StratumDummyPipelineProgrammable
+        extends AbstractP4RuntimePipelineProgrammable
+        implements PiPipelineProgrammable {
+
+    @Override
+    public ByteBuffer createDeviceDataBuffer(PiPipeconf pipeconf) {
+        // No pipeline binary needed
+        return ByteBuffer.allocate(1);
+    }
+
+    @Override
+    public Optional<PiPipeconf> getDefaultPipeconf() {
+        return Optional.of(PipeconfLoader.BASIC_PIPECONF);
+    }
+}
diff --git a/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/dummy/package-info.java b/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/dummy/package-info.java
new file mode 100644
index 0000000..7633706
--- /dev/null
+++ b/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/dummy/package-info.java
@@ -0,0 +1,21 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+/**
+ * Behaviours for Dummy Stratum Device.
+ */
+
+package org.onosproject.drivers.stratum.dummy;
diff --git a/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/package-info.java b/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/package-info.java
new file mode 100644
index 0000000..145022a
--- /dev/null
+++ b/drivers/stratum/src/main/java/org/onosproject/drivers/stratum/package-info.java
@@ -0,0 +1,20 @@
+/*
+ * Copyright 2018-present Open Networking Foundation
+ *
+ * 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.
+ */
+
+/**
+ * Driver for Stratum devices.
+ */
+package org.onosproject.drivers.stratum;
diff --git a/drivers/stratum/src/main/resources/stratum-drivers.xml b/drivers/stratum/src/main/resources/stratum-drivers.xml
new file mode 100644
index 0000000..83fea1d
--- /dev/null
+++ b/drivers/stratum/src/main/resources/stratum-drivers.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ Copyright 2017-present Open Networking Foundation
+  ~
+  ~ 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="stratum" manufacturer="Open Networking Foundation"
+            hwVersion="master" swVersion="Stratum" extends="p4runtime,gnmi">
+        <behaviour api="org.onosproject.net.device.DeviceHandshaker"
+                   impl="org.onosproject.drivers.stratum.StratumHandshaker"/>
+    </driver>
+
+    <driver name="stratum-dummy" manufacturer="Open Networking Foundation"
+            hwVersion="Dummy" swVersion="Stratum" extends="stratum">
+        <behaviour api="org.onosproject.net.behaviour.PiPipelineProgrammable"
+                   impl="org.onosproject.drivers.stratum.dummy.StratumDummyPipelineProgrammable"/>
+        <property name="tableReadFromMirror">true</property>
+        <property name="actionGroupReadFromMirror">true</property>
+    </driver>
+</drivers>
+