AETHER-233 Move IntProgrammable behavior to core APIs

Before, the behavior interface and other concrete classes used it by
were part of the inbandtelemetry app. To make this behavior available to
third-party apps (such as the fabric-tna pipeconf), we move it to the
core APIs.

In this process, we do some clean-up of the behavior API. For example,
we remove references to network-level semantics (as behaviors should
only abstract device-level ones). That helps in reducing the number of
classes required to maintain in the core.

Change-Id: I3ba24ea93cdfea115cee454d5e921e15ec17eee9
diff --git a/pipelines/basic/BUILD b/pipelines/basic/BUILD
index c5b3136..de5fd3a 100644
--- a/pipelines/basic/BUILD
+++ b/pipelines/basic/BUILD
@@ -2,12 +2,10 @@
     "@minimal_json//jar",
     "//protocols/p4runtime/model:onos-protocols-p4runtime-model",
     "//protocols/p4runtime/api:onos-protocols-p4runtime-api",
-    "//apps/inbandtelemetry/api:onos-apps-inbandtelemetry-api",
 ]
 
 BUNDLES = [
     "//pipelines/basic:onos-pipelines-basic",
-    "//apps/inbandtelemetry/api:onos-apps-inbandtelemetry-api",
 ]
 
 osgi_jar(
diff --git a/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/IntProgrammableImpl.java b/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/IntProgrammableImpl.java
index 9a81e4c..0e8d2cd 100644
--- a/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/IntProgrammableImpl.java
+++ b/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/IntProgrammableImpl.java
@@ -16,15 +16,15 @@
 package org.onosproject.pipelines.basic;
 
 import com.google.common.collect.Sets;
+import org.onosproject.net.behaviour.inbandtelemetry.IntMetadataType;
 import org.osgi.service.component.annotations.Reference;
 import org.osgi.service.component.annotations.ReferenceCardinality;
 import org.onlab.util.ImmutableByteSequence;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
-import org.onosproject.inbandtelemetry.api.IntConfig;
-import org.onosproject.inbandtelemetry.api.IntIntent;
-import org.onosproject.inbandtelemetry.api.IntObjective;
-import org.onosproject.inbandtelemetry.api.IntProgrammable;
+import org.onosproject.net.behaviour.inbandtelemetry.IntDeviceConfig;
+import org.onosproject.net.behaviour.inbandtelemetry.IntObjective;
+import org.onosproject.net.behaviour.inbandtelemetry.IntProgrammable;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.driver.AbstractHandlerBehaviour;
@@ -215,7 +215,7 @@
     }
 
     @Override
-    public boolean setupIntConfig(IntConfig config) {
+    public boolean setupIntConfig(IntDeviceConfig config) {
         return setupIntReportInternal(config);
     }
 
@@ -353,9 +353,9 @@
                 .build();
     }
 
-    private int buildInstructionBitmap(Set<IntIntent.IntMetadataType> metadataTypes) {
+    private int buildInstructionBitmap(Set<IntMetadataType> metadataTypes) {
         int instBitmap = 0;
-        for (IntIntent.IntMetadataType metadataType : metadataTypes) {
+        for (IntMetadataType metadataType : metadataTypes) {
             switch (metadataType) {
                 case SWITCH_ID:
                     instBitmap |= (1 << 15);
@@ -430,7 +430,7 @@
         }
     }
 
-    private boolean setupIntReportInternal(IntConfig cfg) {
+    private boolean setupIntReportInternal(IntDeviceConfig cfg) {
         if (!setupBehaviour()) {
             return false;
         }
@@ -446,7 +446,7 @@
         }
     }
 
-    private FlowRule buildReportEntry(IntConfig cfg) {
+    private FlowRule buildReportEntry(IntDeviceConfig cfg) {
         TrafficSelector selector = DefaultTrafficSelector.builder()
                 .matchPi(PiCriterion.builder().matchExact(
                         IntConstants.HDR_INT_IS_VALID, (byte) 0x01)
diff --git a/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/PipeconfLoader.java b/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/PipeconfLoader.java
index 02dcd29..1ba5957 100644
--- a/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/PipeconfLoader.java
+++ b/pipelines/basic/src/main/java/org/onosproject/pipelines/basic/PipeconfLoader.java
@@ -18,7 +18,7 @@
 
 import com.google.common.collect.ImmutableList;
 import org.onosproject.core.CoreService;
-import org.onosproject.inbandtelemetry.api.IntProgrammable;
+import org.onosproject.net.behaviour.inbandtelemetry.IntProgrammable;
 import org.onosproject.net.behaviour.Pipeliner;
 import org.onosproject.net.device.PortStatisticsDiscovery;
 import org.onosproject.net.pi.model.DefaultPiPipeconf;
diff --git a/pipelines/fabric/BUILD b/pipelines/fabric/BUILD
index 41ecec5..19a74d2 100644
--- a/pipelines/fabric/BUILD
+++ b/pipelines/fabric/BUILD
@@ -1,7 +1,6 @@
 BUNDLES = [
     "//pipelines/fabric/api:onos-pipelines-fabric-api",
     "//pipelines/fabric/impl:onos-pipelines-fabric-impl",
-    "//apps/inbandtelemetry/api:onos-apps-inbandtelemetry-api",
 ]
 
 onos_app(
diff --git a/pipelines/fabric/impl/BUILD b/pipelines/fabric/impl/BUILD
index 3e8824d..e5c214b 100644
--- a/pipelines/fabric/impl/BUILD
+++ b/pipelines/fabric/impl/BUILD
@@ -5,7 +5,6 @@
     "//providers/general/device:onos-providers-general-device",
     "//pipelines/basic:onos-pipelines-basic",
     "//core/store/serializers:onos-core-serializers",
-    "//apps/inbandtelemetry/api:onos-apps-inbandtelemetry-api",
     "//drivers/p4runtime:onos-drivers-p4runtime",
 ]
 
diff --git a/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/FabricPipeconfManager.java b/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/FabricPipeconfManager.java
index f366e99..d8af395 100644
--- a/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/FabricPipeconfManager.java
+++ b/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/FabricPipeconfManager.java
@@ -16,7 +16,7 @@
 
 package org.onosproject.pipelines.fabric.impl;
 
-import org.onosproject.inbandtelemetry.api.IntProgrammable;
+import org.onosproject.net.behaviour.inbandtelemetry.IntProgrammable;
 
 import org.onosproject.net.behaviour.BngProgrammable;
 import org.onosproject.net.behaviour.Pipeliner;
diff --git a/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricIntProgrammable.java b/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricIntProgrammable.java
index 6edbfd7..7f9e35e 100644
--- a/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricIntProgrammable.java
+++ b/pipelines/fabric/impl/src/main/java/org/onosproject/pipelines/fabric/impl/behaviour/FabricIntProgrammable.java
@@ -18,10 +18,10 @@
 import com.google.common.collect.Sets;
 import org.onosproject.core.ApplicationId;
 import org.onosproject.core.CoreService;
-import org.onosproject.inbandtelemetry.api.IntConfig;
-import org.onosproject.inbandtelemetry.api.IntIntent;
-import org.onosproject.inbandtelemetry.api.IntObjective;
-import org.onosproject.inbandtelemetry.api.IntProgrammable;
+import org.onosproject.net.behaviour.inbandtelemetry.IntMetadataType;
+import org.onosproject.net.behaviour.inbandtelemetry.IntDeviceConfig;
+import org.onosproject.net.behaviour.inbandtelemetry.IntObjective;
+import org.onosproject.net.behaviour.inbandtelemetry.IntProgrammable;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.PortNumber;
 import org.onosproject.net.config.NetworkConfigService;
@@ -259,7 +259,7 @@
     }
 
     @Override
-    public boolean setupIntConfig(IntConfig config) {
+    public boolean setupIntConfig(IntDeviceConfig config) {
 
         if (!setupBehaviour()) {
             return false;
@@ -368,9 +368,9 @@
                 .build();
     }
 
-    private int buildInstructionBitmap(Set<IntIntent.IntMetadataType> metadataTypes) {
+    private int buildInstructionBitmap(Set<IntMetadataType> metadataTypes) {
         int instBitmap = 0;
-        for (IntIntent.IntMetadataType metadataType : metadataTypes) {
+        for (IntMetadataType metadataType : metadataTypes) {
             switch (metadataType) {
                 case SWITCH_ID:
                     instBitmap |= (1 << 15);
@@ -442,7 +442,7 @@
         }
     }
 
-    private boolean setupIntReportInternal(IntConfig cfg) {
+    private boolean setupIntReportInternal(IntDeviceConfig cfg) {
         // Report not fully supported yet.
         return true;
         // FlowRule reportRule = buildReportEntry(cfg, PKT_INSTANCE_TYPE_INGRESS_CLONE);
@@ -456,7 +456,7 @@
         // }
     }
 
-    private FlowRule buildReportEntry(IntConfig cfg, int type) {
+    private FlowRule buildReportEntry(IntDeviceConfig cfg, int type) {
 
         if (!setupBehaviour()) {
             return null;