Recover missing pipeconf-merged driver at component activation

needed to support rebooting ONOS nodes

Change-Id: I44d34c649750ffc3d6b0205ee02c8c88391f1f8a
(cherry picked from commit ccee77a024c14c3cef68457028ea71edc0555f54)
diff --git a/core/net/src/main/java/org/onosproject/net/driver/impl/DriverManager.java b/core/net/src/main/java/org/onosproject/net/driver/impl/DriverManager.java
index f2ece6b..f098c75 100644
--- a/core/net/src/main/java/org/onosproject/net/driver/impl/DriverManager.java
+++ b/core/net/src/main/java/org/onosproject/net/driver/impl/DriverManager.java
@@ -120,21 +120,14 @@
 
         Driver driver;
 
-        // Primary source of driver configuration is the network config.
+        // Special processing for devices with pipeconf.
         if (pipeconfService.ofDevice(deviceId).isPresent()) {
-            // Device has pipeconf associated, look for merged driver.
-            // Implementation of PiPipeconfService is expected to look for a
-            // base driver in network config.
-            PiPipeconfId pipeconfId = pipeconfService.ofDevice(deviceId).get();
-            String mergedDriver = pipeconfService.getMergedDriver(deviceId, pipeconfId);
-            driver = mergedDriver != null ? lookupDriver(mergedDriver) : null;
-            if (driver != null) {
-                return driver;
-            } else {
-                log.error("Merged driver for {} with pipeconf {} not found, falling back.",
-                          deviceId, pipeconfId);
-            }
+            // No fallback for pipeconf merged drivers. Returns null if driver
+            // does not exist.
+            return getPipeconfMergedDriver(deviceId);
         }
+
+        // Primary source of driver configuration is the network config.
         BasicDeviceConfig cfg = networkConfigService.getConfig(deviceId, BasicDeviceConfig.class);
         driver = lookupDriver(cfg != null ? cfg.driver() : null);
         if (driver != null) {
@@ -155,6 +148,28 @@
                               NO_DRIVER);
     }
 
+    private Driver getPipeconfMergedDriver(DeviceId deviceId) {
+        PiPipeconfId pipeconfId = pipeconfService.ofDevice(deviceId).orElse(null);
+        if (pipeconfId == null) {
+            log.warn("Missing pipeconf for {}, cannot produce a pipeconf merged driver",
+                      deviceId);
+            return null;
+        }
+        String mergedDriverName = pipeconfService.getMergedDriver(deviceId, pipeconfId);
+        if (mergedDriverName == null) {
+            log.warn("Unable to get pipeconf merged driver for {} and {}",
+                     deviceId, pipeconfId);
+            return null;
+        }
+        try {
+            return getDriver(mergedDriverName);
+        } catch (ItemNotFoundException e) {
+            log.warn("Specified pipeconf merged driver {} for {} not found",
+                     mergedDriverName, deviceId);
+            return null;
+        }
+    }
+
     private Driver lookupDriver(String driverName) {
         if (driverName != null) {
             try {