Fixes for problems with starting and stopping apps in a minimal system

- Missing app dependencies
- Incorrect provider registrations
- Fatal execeptions thrown when external resources are not present

Change-Id: I3fdcf0666c88a47f399a722a9ab549d1104ff40e
diff --git a/apps/castor/BUILD b/apps/castor/BUILD
index 38b93ce..546453b 100644
--- a/apps/castor/BUILD
+++ b/apps/castor/BUILD
@@ -28,7 +28,10 @@
     category = "Utility",
     description = "Castor application",
     included_bundles = BUNDLES,
-    required_apps = ["org.onosproject.intentsynchronizer"],
+    required_apps = [
+        "org.onosproject.intentsynchronizer",
+        "org.onosproject.route-service",
+    ],
     title = "Castor",
     url = "http://onosproject.org",
 )
diff --git a/apps/dhcp/app/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java b/apps/dhcp/app/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java
index 6480e2b..51312e8 100644
--- a/apps/dhcp/app/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java
+++ b/apps/dhcp/app/src/main/java/org/onosproject/dhcp/impl/DhcpManager.java
@@ -104,7 +104,7 @@
 )
 public class DhcpManager implements DhcpService {
 
-    private static final ProviderId PID = new ProviderId("of", "org.onosproject.dhcp", true);
+    private static final ProviderId PID = new ProviderId("of", "org.onosproject.dhcp");
 
     private final Logger log = LoggerFactory.getLogger(getClass());
 
diff --git a/apps/gangliametrics/BUILD b/apps/gangliametrics/BUILD
index b76c08c..85402ba 100644
--- a/apps/gangliametrics/BUILD
+++ b/apps/gangliametrics/BUILD
@@ -4,7 +4,7 @@
     "@remotetea_oncrpc//jar",
 ]
 
-EXCLUDED_BUNDLES = [
+INCLUDED_BUNDLES = [
     "@gmetric4j//jar",
     "@metrics_ganglia//jar",
     "@remotetea_oncrpc//jar",
@@ -17,7 +17,7 @@
 onos_app(
     category = "Monitoring",
     description = "Performance metric service reporter",
-    excluded_bundles = EXCLUDED_BUNDLES,
+    included_bundles = INCLUDED_BUNDLES,
     title = "Ganglia Report and Query",
     url = "http://onosproject.org",
 )
diff --git a/apps/l3vpn/BUILD b/apps/l3vpn/BUILD
index 1c4b585..8e670a4 100644
--- a/apps/l3vpn/BUILD
+++ b/apps/l3vpn/BUILD
@@ -24,6 +24,8 @@
     "org.onosproject.models.common",
     "org.onosproject.models.l3vpn",
     "org.onosproject.bgpcep",
+    "org.onosproject.pcep",
+    "org.onosproject.bgp",
 ]
 
 osgi_jar_with_tests(
diff --git a/apps/rabbitmq/src/main/java/org/onosproject/rabbitmq/impl/MQSender.java b/apps/rabbitmq/src/main/java/org/onosproject/rabbitmq/impl/MQSender.java
index 0b22178..3058557 100644
--- a/apps/rabbitmq/src/main/java/org/onosproject/rabbitmq/impl/MQSender.java
+++ b/apps/rabbitmq/src/main/java/org/onosproject/rabbitmq/impl/MQSender.java
@@ -106,7 +106,7 @@
             channel.queueDeclare(this.queueName, true, false, false, null);
             channel.queueBind(queueName, exchangeName, routingKey);
         } catch (Exception e) {
-            log.error(E_CREATE_CHAN, e);
+            log.warn(E_CREATE_CHAN, e.getMessage());
         }
     }
 
diff --git a/apps/routing/cpr/BUILD b/apps/routing/cpr/BUILD
index 468a283..17a3696 100644
--- a/apps/routing/cpr/BUILD
+++ b/apps/routing/cpr/BUILD
@@ -18,11 +18,16 @@
     "//apps/routing-api:onos-apps-routing-api",
 ]
 
+APPS = [
+    "org.onosproject.route-service",
+]
+
 onos_app(
     app_name = "org.onosproject.cpr",
     category = "Traffic Engineering",
     description = "Redirects routing control traffic to a control plane",
     included_bundles = BUNDLES,
+    required_apps = APPS,
     title = "Control Plane Redirect",
     url = "http://onosproject.org",
 )
diff --git a/apps/simplefabric/BUILD b/apps/simplefabric/BUILD
index 3fabae0..358adcd 100644
--- a/apps/simplefabric/BUILD
+++ b/apps/simplefabric/BUILD
@@ -11,6 +11,7 @@
         "org.onosproject.openflow-base",
         "org.onosproject.lldpprovider",
         "org.onosproject.hostprovider",
+        "org.onosproject.route-service",
     ],
     title = "SONA SimpleFabric",
     url = "http://onosproject.org",
diff --git a/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngManager.java b/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngManager.java
index 209d11d..4ae5121 100644
--- a/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngManager.java
+++ b/apps/virtualbng/src/main/java/org/onosproject/virtualbng/VbngManager.java
@@ -138,7 +138,7 @@
                             vbngConfigurationService.getXosRestPort());
             map = restClient.getRest();
         } catch (Exception e) {
-            log.error("Could not contact XOS", e);
+            log.warn("Could not contact XOS {}", e.getMessage());
             return;
         }
         if (map == null) {
diff --git a/drivers/flowspec/BUILD b/drivers/flowspec/BUILD
index fd1b1a7..4460a0c 100644
--- a/drivers/flowspec/BUILD
+++ b/drivers/flowspec/BUILD
@@ -14,7 +14,10 @@
     app_name = "org.onosproject.drivers.flowspec",
     category = "Drivers",
     description = "Adds support for devices using flow specs.",
-    required_apps = ["org.onosproject.drivers"],
+    required_apps = [
+        "org.onosproject.drivers",
+        "org.onosproject.flowspec-api",
+    ],
     title = "Generic Flow Spec Drivers",
     url = "http://onosproject.org",
 )
diff --git a/drivers/stratum/BUILD b/drivers/stratum/BUILD
index 41db9f1..c075491 100644
--- a/drivers/stratum/BUILD
+++ b/drivers/stratum/BUILD
@@ -19,6 +19,7 @@
         "org.onosproject.generaldeviceprovider",
         "org.onosproject.drivers.gnmi",
         "org.onosproject.drivers.p4runtime",
+        "org.onosproject.pipelines.basic",
     ],
     title = "Stratum Drivers",
     url = "http://onosproject.org",
diff --git a/providers/bgp/BUILD b/providers/bgp/BUILD
index b996b79..b47739a 100644
--- a/providers/bgp/BUILD
+++ b/providers/bgp/BUILD
@@ -12,7 +12,11 @@
     category = "Provider",
     description = "BGP protocol southbound providers.",
     included_bundles = BUNDLES,
-    required_apps = ["org.onosproject.evpn-route-service"],
+    required_apps = [
+        "org.onosproject.evpn-route-service",
+        "org.onosproject.tunnel",
+        "org.onosproject.pcep-api",
+    ],
     title = "BGP Provider",
     url = "http://onosproject.org",
 )
diff --git a/providers/bgpcep/BUILD b/providers/bgpcep/BUILD
index 1ca61bc..9910827 100644
--- a/providers/bgpcep/BUILD
+++ b/providers/bgpcep/BUILD
@@ -20,6 +20,11 @@
     category = "Provider",
     description = "BGPCEP providers.",
     included_bundles = BUNDLES,
+    required_apps = [
+        "org.onosproject.tunnel",
+        "org.onosproject.bgp",
+        "org.onosproject.pcep-api",
+    ],
     title = "BGPCEP Provider",
     url = "http://onosproject.org",
 )
diff --git a/providers/ovsdb/host/BUILD b/providers/ovsdb/host/BUILD
index 63e86f7..b59626e 100644
--- a/providers/ovsdb/host/BUILD
+++ b/providers/ovsdb/host/BUILD
@@ -11,6 +11,7 @@
     app_name = "org.onosproject.ovsdbhostprovider",
     category = "Provider",
     description = "OVSDB Host provider.",
+    required_apps = ["org.onosproject.ovsdb-base"],
     title = "OVSDB host Provider",
     url = "http://onosproject.org",
 )
diff --git a/providers/pcep/BUILD b/providers/pcep/BUILD
index a0e6254..fa0a676 100644
--- a/providers/pcep/BUILD
+++ b/providers/pcep/BUILD
@@ -16,6 +16,8 @@
     required_apps = [
         "org.onosproject.pcep-api",
         "org.onosproject.optical-model",
+        "org.onosproject.tunnel",
+        "org.onosproject.bgp",
     ],
     title = "PCEP Provider",
     url = "http://onosproject.org",
diff --git a/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/PcepTopologyProvider.java b/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/PcepTopologyProvider.java
index d0f8c1b..26d6968 100644
--- a/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/PcepTopologyProvider.java
+++ b/providers/pcep/topology/src/main/java/org/onosproject/provider/pcep/topology/impl/PcepTopologyProvider.java
@@ -86,7 +86,7 @@
     public PcepTopologyProvider() {
         //In BGP-PCEP app, since both BGP and PCEP topology provider have same scheme
         //so BGP will be primary and PCEP topology provider will be ancillary.
-        super(new ProviderId("l3", "org.onosproject.provider.pcep", true));
+        super(new ProviderId("l3", "org.onosproject.provider.bgp", true));
     }
 
     private static final Logger log = LoggerFactory