VOL-373 support 3 tuple and multiple version numbers for ONOS apps

Change-Id: I2b6487628c2a01ff0d1fc408ddc1a921885197cb
diff --git a/ONOS_DOCKER.md b/ONOS_DOCKER.md
new file mode 100644
index 0000000..42fdc20
--- /dev/null
+++ b/ONOS_DOCKER.md
@@ -0,0 +1,50 @@
+# Building a Local ONOS Docker Image with Control Plane Applications
+
+Included in this area is a `Dockerfile` that can be use to build a Docker
+image of the ONOS application with the local build of the control plane
+applications required to run VOLTHA. This file can be found in
+`<ROOT>/onos-apps/docker/Dockerfile.onos`. To build the image use the following
+commands:
+
+```
+$ cd <ROOT>/onos-apps
+$ docker build -f  docker/Dockerfile.onos -t onos:local .
+```
+
+This will create a Docker image named (tagged) `onos:local`. To run invoke
+an instance of this container the following command can be used:
+
+```
+$ docker run -ti onos:local
+```
+
+This will invoke the container instance in the foreground, which is not
+something that would typically be done in production, but works for a
+simple verification.
+
+Once ONOS is started and initialized the command `apps -s -a` should present
+the following installed and activated applications:
+
+```
+onos> apps -s -a
+*   5 org.onosproject.drivers              1.8.5.SNAPSHOT Default device drivers
+*   6 org.onosproject.optical-model        1.8.5.SNAPSHOT Optical information model
+*  25 org.onosproject.netcfghostprovider   1.8.5.SNAPSHOT Network Config Host Provider
+*  40 org.onosproject.ovsdb-base           1.8.5.SNAPSHOT OVSDB Provider
+*  41 org.onosproject.drivers.ovsdb        1.8.5.SNAPSHOT OVSDB Device Drivers
+*  69 org.onosproject.openflow-base        1.8.5.SNAPSHOT OpenFlow Provider
+*  85 org.onosproject.netcfglinksprovider  1.8.5.SNAPSHOT Network Config Link Provider
+*  86 org.opencord.config                  1.2.0.SNAPSHOT CORD configuration meta application
+*  87 org.opencord.vtn                     1.2.0.SNAPSHOT VTN App
+*  89 org.opencord.dhcpl2relay             1.0.0.SNAPSHOT DHCP Relay Agent App
+*  90 org.opencord.mcast                   1.2.0.SNAPSHOT CORD Multicast application
+*  91 org.opencord.sadis                   1.0.0.SNAPSHOT Subscriber And Device Information App
+*  92 org.opencord.igmpproxy               1.0.0.SNAPSHOT IGMP PROXY APP
+*  93 org.onosproject.olt                  1.2.0.SNAPSHOT Optical Line Terminal App
+*  94 org.opencord.aaa                     1.2.0.SNAPSHOT AAA App
+*  95 org.opencord.igmp                    1.2.0.SNAPSHOT Internet Group Message Protocol
+```
+
+*NOTE: If the command `apps -s -a` is issued before `ONOS` is complete
+initialized errors will be reported to the console. It can take seconds to
+minutes for ONOS to be initialized.*
diff --git a/apps/pom.xml b/apps/pom.xml
index 3d09a8c..30308c4 100644
--- a/apps/pom.xml
+++ b/apps/pom.xml
@@ -33,7 +33,7 @@
     <groupId>org.opencord</groupId>
     <artifactId>cord</artifactId>
     <packaging>pom</packaging>
-    <version>1.2-SNAPSHOT</version>
+    <version>1.2.0-SNAPSHOT</version>
 
     <name>${project.artifactId}</name>
     <description>Open CORD root project</description>
@@ -46,7 +46,8 @@
         <module>mcast</module>
         <module>olt</module>
         <module>sadis</module>
-        <module>vtn</module>
+	<module>vtn</module>
+	<module>dhcpl2relay</module>
     </modules>
 
 <!--
diff --git a/config/app-install.sh b/config/app-install.sh
new file mode 100644
index 0000000..0523886
--- /dev/null
+++ b/config/app-install.sh
@@ -0,0 +1,23 @@
+#!/bin/bash 
+
+for app in $APPS; do
+    echo "Installing application '$app'"
+    oar=$(find $BUILD_ROOT -path "*/target/*" -name "$app*".oar)
+    if [ "$oar x" == " x" ]; then
+        echo "Required application, $app, not found."
+	continue
+    fi
+    rm -rf $APP_INSTALL_ROOT
+    mkdir -p $APP_INSTALL_ROOT
+    cd $APP_INSTALL_ROOT
+    cp $oar $APP_INSTALL_ROOT
+    jar -xf $APP_INSTALL_ROOT/$(basename $oar)
+    name=$(grep "name=" $APP_INSTALL_ROOT/app.xml | sed 's/<app name="//g;s/".*//g')
+    mkdir -p $APPS_ROOT/$name
+    cp $APP_INSTALL_ROOT/app.xml $APPS_ROOT/$name/app.xml
+    touch $APPS_ROOT/$name/active
+    [ -f $APP_INSTALL_ROOT/app.png ] && cp $APP_INSTALL_ROOT/app.png $APPS_ROOT/$name/app.png
+    cp $APP_INSTALL_ROOT/$(basename $oar) $APPS_ROOT/$name/$name.oar
+    cp -rf $APP_INSTALL_ROOT/m2/* $KARAF_M2
+    rm -rf $APP_INSTALL_ROOT
+done
diff --git a/config/netcfg.json b/config/netcfg.json
new file mode 100644
index 0000000..245c263
--- /dev/null
+++ b/config/netcfg.json
@@ -0,0 +1,127 @@
+{
+  "apps": {
+    "org.opencord.aaa": {
+      "AAA": {
+        "radiusIp": "172.25.0.100",
+	"nasIp": "5.6.7.8",
+        "radiusServerPort": "1812",
+        "radiusSecret": "SECRET",
+	"bindings" : [
+		{
+		 "mac" : "de:ad:be:ef:ba:11",
+		 "s-tag" : 2,
+		 "c-tag" : 2,
+         "nas_port_id" : "location"
+		},
+                {
+         "mac" : "de:ad:be:ef:ca:fe",
+         "s-tag" : 2,
+         "c-tag" : 122,
+         "nas_port_id" : "location"
+        }
+	  ] 
+    }
+ },
+    "org.onosproject.dhcp-relay" : {
+           "dhcprelay" : {
+               "dhcpserverConnectPoint" : "of:00000cafecafecafe/4",
+               "serverip" : "11.11.11.11",
+               "gatewayip" : "9.9.9.9"
+           }
+    }
+  },
+  "devices": {
+    "of:0001000000000001": {
+      "basic": {
+        "driver": "pmc-olt"
+      },
+      "accessDevice": {
+        "uplink": "0",
+        "vlan": "2"
+      }
+    },
+    "of:0001000000000002": {
+      "basic": {
+        "driver": "pmc-olt"
+      },
+      "accessDevice": {
+        "uplink": "0",
+        "vlan": "1001"
+      }
+    },
+    "of:0001000000000003": {
+      "basic": {
+        "driver": "pmc-olt"
+      },
+      "accessDevice": {
+        "uplink": "0",
+        "vlan": "1002"
+      }
+    },
+    "of:0001000000000004": {
+      "basic": {
+        "driver": "pmc-olt"
+      },
+      "accessDevice": {
+        "uplink": "0",
+        "vlan": "1003"
+      }
+    },
+    "of:0001000000000005": {
+      "basic": {
+        "driver": "pmc-olt"
+      },
+      "accessDevice": {
+        "uplink": "0",
+        "vlan": "1004"
+      }
+    },
+    "of:0001000000000006": {
+      "basic": {
+        "driver": "pmc-olt"
+      },
+      "accessDevice": {
+        "uplink": "0",
+        "vlan": "1005"
+      }
+    }
+  },
+  "ports" : { 
+	"of:0000000000000001/2" : {
+           "interfaces" : [
+               {
+                   "name" : "yoyoma1",
+                   "ips"  : [ "10.0.2.1/24" ],
+                   "mac"  : "00:00:00:01:01:00"
+               }
+           ]
+        },
+	"of:00000cafecafecafe/3" : {
+           "interfaces" : [
+               {
+                   "name" : "yoyoma",
+                   "ips"  : [ "10.0.2.2/24" ],
+                   "mac"  : "00:00:00:01:02:00"
+               }
+           ]
+        },"of:00000cafecafecafe/2" : {
+           "interfaces" : [
+               {
+                   "name" : "yoyoma2",
+                   "ips"  : [ "10.0.2.3/24" ],
+                   "mac"  : "00:00:00:01:03:00"
+               }
+           ]
+        },
+	"of:00000cafecafecafe/4" : {
+           "interfaces" : [
+               {
+                   "name" : "yoyoma4",
+                   "ips"  : [ "10.0.2.4/24" ],
+                   "mac"  : "00:00:00:01:04:00"
+               }
+           ]
+        }
+
+  }
+}
diff --git a/docker/Dockerfile.onos b/docker/Dockerfile.onos
new file mode 100644
index 0000000..b81c80a
--- /dev/null
+++ b/docker/Dockerfile.onos
@@ -0,0 +1,60 @@
+FROM onosproject/onos:1.8 as build
+MAINTAINER Open Networking Foundation <info@opennetworking.org>
+
+ENV BUILD_ROOT=/build
+
+COPY apps/ /build
+
+# The ENV settings for ONOS, KARAF_VERSION, KARAF_ROOT, KARAF_M2, and APPS_ROOT
+# must be replicated below to the final image as they are shared between stages
+ENV ONOS=/root/onos
+ENV APPS_ROOT=${ONOS}/apps
+ENV KARAF_VERSION=3.0.5
+ENV KARAF_ROOT=${ONOS}/apache-karaf-${KARAF_VERSION}
+ENV KARAF_M2=${KARAF_ROOT}/system
+ENV APP_INSTALL_ROOT=/expand
+
+# Specify application versions to install
+ENV AAA_VERSION=1.2.0-SNAPSHOT \
+	CONFIG_VERSION=1.2.0-SNAPSHOT \
+	IGMP_VERSION=1.2.0-SNAPSHOT \
+	IGMP_PROXY_VERSION=1.0.0-SNAPSHOT \
+	MCAST_VERSION=1.2.0-SNAPSHOT \
+	OLT_VERSION=1.2.0-SNAPSHOT \
+	SADIS_VERSION=1.0.0-SNAPSHOT \
+	VTN_VERSION=1.2.0-SNAPSHOT \
+	L2_DHCP_RELAY_VERSION=1.0.0-SNAPSHOT
+
+ENV APPS="aaa-${AAA_VERSION} \
+	cord-config-${CONFIG_VERSION} \
+	igmp-${IGMP_VERSION} \
+	mcast-${MCAST_VERSION} \
+	olt-app-${OLT_VERSION} \
+	sadis-app-${SADIS_VERSION} \
+	vtn-${VTN_VERSION} \
+        aaa-${AAA_VERSION} \
+        onos-app-igmpproxy-${IGMP_PROXY_VERSION} \
+	dhcpl2relay-${L2_DHCP_RELAY_VERSION}"
+
+# Install the applications
+COPY config/app-install.sh .
+RUN chmod 755 ./app-install.sh && ./app-install.sh
+
+# Create the final image coping over the installed applications from the build stage
+FROM onosproject/onos:1.8
+
+ENV ONOS=/root/onos
+ENV KARAF_VERSION=3.0.5
+ENV KARAF_ROOT=${ONOS}/apache-karaf-${KARAF_VERSION}
+ENV KARAF_M2=${KARAF_ROOT}/system
+ENV APPS_ROOT=${ONOS}/apps
+
+COPY --from=build ${KARAF_M2}/ ${KARAF_M2}/
+RUN echo "${KARAF_M2} ${APPS_ROOT}"
+COPY --from=build ${APPS_ROOT}/ ${APPS_ROOT}/
+COPY config/netcfg.json $KARAF_ROOT/../config/network-cfg.json
+
+RUN touch $ONOS/apps/org.onosproject.netcfghostprovider/active
+RUN touch $ONOS/apps/org.onosproject.netcfglinksprovider/active
+RUN touch $ONOS/apps/org.onosproject.openflow-base/active
+