Detangling incubator: virtual nets, tunnels, resource labels, oh my

- virtual networking moved to /apps/virtual; with CLI & REST API
- tunnels and labels moved to /apps/tunnel; with CLI & REST API; UI disabled for now
- protobuf/models moved to /core/protobuf/models
- defunct grpc/rpc registry stuff left under /graveyard
- compile dependencies on /incubator moved to respective modules for compilation
- run-time dependencies will need to be re-tested for dependent apps

- /graveyard will be removed in not-too-distant future

Change-Id: I0a0b995c635487edcf95a352f50dd162186b0b39
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java b/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java
index 08311ed..5f153f0 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/TopologyViewMessageHandlerBase.java
@@ -27,8 +27,6 @@
 import org.onosproject.cluster.ControllerNode;
 import org.onosproject.cluster.NodeId;
 import org.onosproject.core.CoreService;
-import org.onosproject.incubator.net.tunnel.OpticalTunnelEndPoint;
-import org.onosproject.incubator.net.tunnel.Tunnel;
 import org.onosproject.net.AnnotationKeys;
 import org.onosproject.net.Annotations;
 import org.onosproject.net.ConnectPoint;
@@ -36,7 +34,6 @@
 import org.onosproject.net.Device;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.EdgeLink;
-import org.onosproject.net.ElementId;
 import org.onosproject.net.Host;
 import org.onosproject.net.HostId;
 import org.onosproject.net.HostLocation;
@@ -60,12 +57,10 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.Collection;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Objects;
-import java.util.Optional;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 
@@ -461,7 +456,6 @@
                 .addProp(TOPOLOGY_SSCS, lion.getSafe(TOPOLOGY_SSCS), topology.clusterCount())
                 .addSeparator()
                 .addProp(INTENTS, lion.getSafe(INTENTS), services.intent().getIntentCount())
-                .addProp(TUNNELS, lion.getSafe(TUNNELS), services.tunnel().tunnelCount())
                 .addProp(FLOWS, lion.getSafe(FLOWS), services.flow().getFlowRuleCount());
     }
 
@@ -548,28 +542,9 @@
         return services.flow().getFlowRuleCount(deviceId);
     }
 
+    @Deprecated
     protected int getTunnelCount(DeviceId deviceId) {
-        int count = 0;
-        Collection<Tunnel> tunnels = services.tunnel().queryAllTunnels();
-        for (Tunnel tunnel : tunnels) {
-            //Only OpticalTunnelEndPoint has a device
-            if (!(tunnel.src() instanceof OpticalTunnelEndPoint) ||
-                    !(tunnel.dst() instanceof OpticalTunnelEndPoint)) {
-                continue;
-            }
-
-            Optional<ElementId> srcElementId = ((OpticalTunnelEndPoint) tunnel.src()).elementId();
-            Optional<ElementId> dstElementId = ((OpticalTunnelEndPoint) tunnel.dst()).elementId();
-            if (!srcElementId.isPresent() || !dstElementId.isPresent()) {
-                continue;
-            }
-            DeviceId srcDeviceId = (DeviceId) srcElementId.get();
-            DeviceId dstDeviceId = (DeviceId) dstElementId.get();
-            if (srcDeviceId.equals(deviceId) || dstDeviceId.equals(deviceId)) {
-                count++;
-            }
-        }
-        return count;
+        return 0;
     }
 
     private boolean useDefaultName(String annotName) {
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/TrafficMonitorBase.java b/web/gui/src/main/java/org/onosproject/ui/impl/TrafficMonitorBase.java
index 4296d3b..43c3fdb 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/TrafficMonitorBase.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/TrafficMonitorBase.java
@@ -17,7 +17,7 @@
 
 package org.onosproject.ui.impl;
 
-import org.onosproject.incubator.net.PortStatisticsService.MetricType;
+import org.onosproject.net.statistic.PortStatisticsService.MetricType;
 import org.onosproject.net.DefaultEdgeLink;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.Link;
@@ -36,8 +36,8 @@
 import java.util.Timer;
 import java.util.TimerTask;
 
-import static org.onosproject.incubator.net.PortStatisticsService.MetricType.BYTES;
-import static org.onosproject.incubator.net.PortStatisticsService.MetricType.PACKETS;
+import static org.onosproject.net.statistic.PortStatisticsService.MetricType.BYTES;
+import static org.onosproject.net.statistic.PortStatisticsService.MetricType.PACKETS;
 import static org.onosproject.net.DefaultEdgeLink.createEdgeLinks;
 import static org.onosproject.ui.impl.TrafficMonitorBase.Mode.IDLE;
 
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/TunnelViewMessageHandler.java b/web/gui/src/main/java/org/onosproject/ui/impl/TunnelViewMessageHandler.java
deleted file mode 100644
index e65a385..0000000
--- a/web/gui/src/main/java/org/onosproject/ui/impl/TunnelViewMessageHandler.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
- * Copyright 2015-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.ui.impl;
-
-import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.collect.ImmutableSet;
-import org.onosproject.incubator.net.tunnel.Tunnel;
-import org.onosproject.incubator.net.tunnel.TunnelEndPointFormatter;
-import org.onosproject.incubator.net.tunnel.TunnelService;
-import org.onosproject.ui.RequestHandler;
-import org.onosproject.ui.UiMessageHandler;
-import org.onosproject.ui.table.TableModel;
-import org.onosproject.ui.table.TableRequestHandler;
-import org.onosproject.ui.table.cell.EnumFormatter;
-
-import java.util.Collection;
-
-public class TunnelViewMessageHandler extends UiMessageHandler {
-    private static final String TUNNEL_DATA_REQ = "tunnelDataRequest";
-    private static final String TUNNEL_DATA_RESP = "tunnelDataResponse";
-    private static final String TUNNELS = "tunnels";
-    private static final String ID = "id";
-    private static final String NAME = "name";
-    private static final String ONE = "one";
-    private static final String TWO = "two";
-    private static final String TYPE = "type";
-    private static final String GROUP_ID = "group_id";
-
-    private static final String BANDWIDTH = "bandwidth";
-    private static final String PATH = "path";
-
-
-    private static final String[] COL_IDS = {
-            ID, NAME, ONE, TWO, TYPE, GROUP_ID,
-            BANDWIDTH, PATH
-    };
-
-    @Override
-    protected Collection<RequestHandler> createRequestHandlers() {
-        return ImmutableSet.of(new TunnelDataRequestHandler());
-    }
-
-    private final class TunnelDataRequestHandler extends TableRequestHandler {
-
-        private static final String NO_ROWS_MESSAGE = "No tunnels found";
-
-        public TunnelDataRequestHandler() {
-            super(TUNNEL_DATA_REQ, TUNNEL_DATA_RESP, TUNNELS);
-        }
-
-        @Override
-        protected String[] getColumnIds() {
-            return COL_IDS;
-        }
-
-        @Override
-        protected String noRowsMessage(ObjectNode payload) {
-            return NO_ROWS_MESSAGE;
-        }
-
-        @Override
-        protected TableModel createTableModel() {
-            TableModel tm = super.createTableModel();
-            //TODO add more formater class so that we can get a more readable table
-            tm.setFormatter(ONE, TunnelEndPointFormatter.INSTANCE);
-            tm.setFormatter(TWO, TunnelEndPointFormatter.INSTANCE);
-            tm.setFormatter(TYPE, EnumFormatter.INSTANCE);
-            return tm;
-        }
-
-        @Override
-        protected void populateTable(TableModel tm, ObjectNode payload) {
-            TunnelService ts = get(TunnelService.class);
-            ts.queryAllTunnels().forEach(tunnel -> populateRow(tm.addRow(), tunnel));
-        }
-
-    }
-
-    private void populateRow(TableModel.Row row, Tunnel tunnel) {
-        row.cell(ID, tunnel.tunnelId().id())
-                .cell(NAME, tunnel.tunnelName().value())
-                .cell(ONE, tunnel.src())
-                .cell(TWO, tunnel.dst())
-                .cell(TYPE, tunnel.type())
-                .cell(GROUP_ID, tunnel.groupId().id())
-                .cell(BANDWIDTH, tunnel.annotations().value(BANDWIDTH))
-                .cell(PATH, tunnel.path());
-    }
-}
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java b/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
index c776fb3..e403479 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/UiExtensionManager.java
@@ -210,8 +210,7 @@
 
                 mkView(NETWORK, "link", "nav_links"),
                 mkView(NETWORK, "host", "nav_hosts"),
-                mkView(NETWORK, "intent", "nav_intents"),
-                mkView(NETWORK, "tunnel", "nav_tunnels")
+                mkView(NETWORK, "intent", "nav_intents")
         );
 
         UiMessageHandlerFactory messageHandlerFactory =
@@ -233,7 +232,6 @@
                         new SettingsViewMessageHandler(),
                         new ClusterViewMessageHandler(),
                         new ProcessorViewMessageHandler(),
-                        new TunnelViewMessageHandler(),
                         new PartitionViewMessageHandler(),
                         new PipeconfViewMessageHandler()
                 );
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2Jsonifier.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2Jsonifier.java
index 4ec61ce..0ef6faf 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2Jsonifier.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/Topo2Jsonifier.java
@@ -26,8 +26,7 @@
 import org.onosproject.cluster.ClusterService;
 import org.onosproject.cluster.ControllerNode;
 import org.onosproject.cluster.NodeId;
-import org.onosproject.incubator.net.PortStatisticsService;
-import org.onosproject.incubator.net.tunnel.TunnelService;
+import org.onosproject.net.statistic.PortStatisticsService;
 import org.onosproject.mastership.MastershipService;
 import org.onosproject.net.Annotated;
 import org.onosproject.net.Annotations;
@@ -128,7 +127,6 @@
     private StatisticService flowStatsService;
     private PortStatisticsService portStatsService;
     private TopologyService topologyService;
-    private TunnelService tunnelService;
     private UiExtensionService uiextService;
     private UiPreferencesService prefService;
 
@@ -160,7 +158,6 @@
         flowStatsService = directory.get(StatisticService.class);
         portStatsService = directory.get(PortStatisticsService.class);
         topologyService = directory.get(TopologyService.class);
-        tunnelService = directory.get(TunnelService.class);
         uiextService = directory.get(UiExtensionService.class);
         prefService = directory.get(UiPreferencesService.class);
     }
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java
index d70ecf6..6f8a706 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/model/UiSharedTopologyModel.java
@@ -22,8 +22,7 @@
 import org.onosproject.cluster.ControllerNode;
 import org.onosproject.cluster.RoleInfo;
 import org.onosproject.event.AbstractListenerManager;
-import org.onosproject.incubator.net.PortStatisticsService;
-import org.onosproject.incubator.net.tunnel.TunnelService;
+import org.onosproject.net.statistic.PortStatisticsService;
 import org.onosproject.mastership.MastershipEvent;
 import org.onosproject.mastership.MastershipListener;
 import org.onosproject.mastership.MastershipService;
@@ -117,8 +116,6 @@
     private PortStatisticsService portStatsService;
     @Reference(cardinality = ReferenceCardinality.MANDATORY)
     private TopologyService topologyService;
-    @Reference(cardinality = ReferenceCardinality.MANDATORY)
-    private TunnelService tunnelService;
 
     private final ClusterEventListener clusterListener =
             new InternalClusterListener();
diff --git a/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/ServicesBundle.java b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/ServicesBundle.java
index 3ae7e90..e58b0f2 100644
--- a/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/ServicesBundle.java
+++ b/web/gui/src/main/java/org/onosproject/ui/impl/topo/util/ServicesBundle.java
@@ -18,8 +18,7 @@
 
 import org.onlab.osgi.ServiceDirectory;
 import org.onosproject.cluster.ClusterService;
-import org.onosproject.incubator.net.PortStatisticsService;
-import org.onosproject.incubator.net.tunnel.TunnelService;
+import org.onosproject.net.statistic.PortStatisticsService;
 import org.onosproject.mastership.MastershipAdminService;
 import org.onosproject.mastership.MastershipService;
 import org.onosproject.net.device.DeviceService;
@@ -45,7 +44,6 @@
     private DriverService driverService;
     private HostService hostService;
     private LinkService linkService;
-    private TunnelService tunnelService;
 
     private MastershipService mastershipService;
     private MastershipAdminService mastershipAdminService;
@@ -70,7 +68,6 @@
         driverService = directory.get(DriverService.class);
         hostService = directory.get(HostService.class);
         linkService = directory.get(LinkService.class);
-        tunnelService = directory.get(TunnelService.class);
 
         mastershipService = directory.get(MastershipService.class);
         mastershipAdminService = directory.get(MastershipAdminService.class);
@@ -135,15 +132,6 @@
     }
 
     /**
-     * Returns a reference to the tunnel service.
-     *
-     * @return tunnel service reference
-     */
-    public TunnelService tunnel() {
-        return tunnelService;
-    }
-
-    /**
      * Returns a reference to the mastership service.
      *
      * @return mastership service reference