Add Aether files and directories from helm-charts

Change-Id: I2edb76ebbf8f1da147f760c0fa4618219c49b6cc
diff --git a/omec/omec-control-plane/templates/bin/_hss-bootstrap.sh.tpl b/omec/omec-control-plane/templates/bin/_hss-bootstrap.sh.tpl
new file mode 100644
index 0000000..ebbddf2
--- /dev/null
+++ b/omec/omec-control-plane/templates/bin/_hss-bootstrap.sh.tpl
@@ -0,0 +1,136 @@
+#!/bin/bash
+#
+# Copyright 2019-present Open Networking Foundation
+# Copyright 2018 Intel Corporation
+#
+# 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.
+
+set -ex
+
+function provision_users() {
+    count=${1}
+    imsi=${2}
+    msisdn=${3}
+    apn=${4}
+    key=${5}
+    opc=${6}
+    sqn=${7}
+    cassandra_ip=${8}
+    mmeidentity=${9}
+    mmerealm=${10}
+
+    for (( i=1; i<=$count; i++ ))
+    do
+        echo "IMSI=$imsi MSISDN=$msisdn"
+        cqlsh $cassandra_ip -e "INSERT INTO vhss.users_imsi (imsi, msisdn, access_restriction, key, opc, mmehost, mmeidentity_idmmeidentity, mmerealm, rand, sqn, subscription_data) VALUES ('$imsi', $msisdn, 41, '$key', '$opc','$mmeidentity', 3, '$mmerealm', '2683b376d1056746de3b254012908e0e', $sqn, '{\"Subscription-Data\":{\"Access-Restriction-Data\":41,\"Subscriber-Status\":0,\"Network-Access-Mode\":2,\"Regional-Subscription-Zone-Code\":[\"0x0123\",\"0x4567\",\"0x89AB\",\"0xCDEF\",\"0x1234\",\"0x5678\",\"0x9ABC\",\"0xDEF0\",\"0x2345\",\"0x6789\"],\"MSISDN\":\"0x$msisdn\",\"AMBR\":{\"Max-Requested-Bandwidth-UL\":50000000,\"Max-Requested-Bandwidth-DL\":100000000},\"APN-Configuration-Profile\":{\"Context-Identifier\":0,\"All-APN-Configurations-Included-Indicator\":0,\"APN-Configuration\":{\"Context-Identifier\":0,\"PDN-Type\":0,\"Served-Party-IP-Address\":[\"0.0.0.0\"],\"Service-Selection\":\"$apn\",\"EPS-Subscribed-QoS-Profile\":{\"QoS-Class-Identifier\":9,\"Allocation-Retention-Priority\":{\"Priority-Level\":15,\"Pre-emption-Capability\":0,\"Pre-emption-Vulnerability\":0}},\"AMBR\":{\"Max-Requested-Bandwidth-UL\":50000000,\"Max-Requested-Bandwidth-DL\":100000000},\"PDN-GW-Allocation-Type\":0,\"MIP6-Agent-Info\":{\"MIP-Home-Agent-Address\":[\"172.26.17.183\"]}}},\"Subscribed-Periodic-RAU-TAU-Timer\":0}}');"
+
+        if [ $? -ne 0 ];then
+           echo -e "oops! Something went wrong adding $imsi to vhss.users_imsi!\n"
+           exit 1
+        fi
+
+        cqlsh $cassandra_ip -e "INSERT INTO vhss.msisdn_imsi (msisdn, imsi) VALUES ($msisdn, '$imsi');"
+        if [ $? -ne 0 ];then
+           echo -e "oops! Something went wrong adding $imsi to vhss.msisdn_imsi!\n"
+           exit 1
+        fi
+
+        echo -e "Added $imsi\n"
+
+        imsi=`expr $imsi + 1`;
+        msisdn=`expr $msisdn + 1`
+    done
+}
+
+function provision_staticusers() {
+    imsi=${1}
+    msisdn=${2}
+    apn=${3}
+    key=${4}
+    opc=${5}
+    sqn=${6}
+    cassandra_ip=${7}
+    mmeidentity=${8}
+    mmerealm=${9}
+    staticAddr=${10}
+
+    echo "IMSI=$imsi MSISDN=$msisdn"
+    cqlsh $cassandra_ip -e "INSERT INTO vhss.users_imsi (imsi, msisdn, access_restriction, key, opc, mmehost, mmeidentity_idmmeidentity, mmerealm, rand, sqn, subscription_data) VALUES ('$imsi', $msisdn, 41, '$key', '$opc','$mmeidentity', 3, '$mmerealm', '2683b376d1056746de3b254012908e0e', $sqn, '{\"Subscription-Data\":{\"Access-Restriction-Data\":41,\"Subscriber-Status\":0,\"Network-Access-Mode\":2,\"Regional-Subscription-Zone-Code\":[\"0x0123\",\"0x4567\",\"0x89AB\",\"0xCDEF\",\"0x1234\",\"0x5678\",\"0x9ABC\",\"0xDEF0\",\"0x2345\",\"0x6789\"],\"MSISDN\":\"0x$msisdn\",\"AMBR\":{\"Max-Requested-Bandwidth-UL\":50000000,\"Max-Requested-Bandwidth-DL\":100000000},\"APN-Configuration-Profile\":{\"Context-Identifier\":0,\"All-APN-Configurations-Included-Indicator\":0,\"APN-Configuration\":{\"Context-Identifier\":0,\"PDN-Type\":0,\"Served-Party-IP-Address\":[\"$staticAddr\"],\"Service-Selection\":\"$apn\",\"EPS-Subscribed-QoS-Profile\":{\"QoS-Class-Identifier\":9,\"Allocation-Retention-Priority\":{\"Priority-Level\":15,\"Pre-emption-Capability\":0,\"Pre-emption-Vulnerability\":0}},\"AMBR\":{\"Max-Requested-Bandwidth-UL\":50000000,\"Max-Requested-Bandwidth-DL\":100000000},\"PDN-GW-Allocation-Type\":0,\"MIP6-Agent-Info\":{\"MIP-Home-Agent-Address\":[\"172.26.17.183\"]}}},\"Subscribed-Periodic-RAU-TAU-Timer\":0}}');"
+
+    cqlsh $cassandra_ip -e "INSERT INTO vhss.msisdn_imsi (msisdn, imsi) VALUES ($msisdn, '$imsi');"
+    echo -e "Added $imsi\n"
+}
+
+function provision_mme() {
+    id=$1
+    isdn=$2
+    host=$3
+    realm=$4
+    uereachability=$5
+    cassandra_ip=$6
+
+    cqlsh $cassandra_ip -e "INSERT INTO vhss.mmeidentity (idmmeidentity, mmeisdn, mmehost, mmerealm, ue_reachability) VALUES ($id, '$isdn', '$host', '$realm', $uereachability);"
+    if [ $? -ne 0 ];then
+       echo -e "oops! Something went wrong adding to vhss.mmeidentity!\n"
+       exit 1
+    fi
+
+    cqlsh $cassandra_ip -e "INSERT INTO vhss.mmeidentity_host (idmmeidentity, mmeisdn, mmehost, mmerealm, ue_reachability) VALUES ($id, '$isdn', '$host', '$realm', $uereachability);"
+    if [ $? -ne 0 ];then
+       echo -e "oops! Something went wrong adding to vhss.mmeidentity_host!\n"
+       exit 1
+    fi
+
+    echo -e "Added mme $id\n"
+}
+
+mme_identity={{ tuple "mme" "identity" . | include "omec-control-plane.diameter_endpoint" }}
+mme_realm={{ tuple "mme" "realm" . | include "omec-control-plane.diameter_endpoint" }}
+
+{{- range .Values.config.hss.bootstrap.users }}
+provision_users \
+    {{ .count }} \
+    {{ .imsiStart }} \
+    {{ .msisdnStart }} \
+    {{ $.Values.config.hss.bootstrap.apn }} \
+    {{ $.Values.config.hss.bootstrap.key }} \
+    {{ $.Values.config.hss.bootstrap.opc }} \
+    {{ $.Values.config.hss.bootstrap.sqn }} \
+    {{ $.Values.config.hss.hssdb }} \
+    $mme_identity \
+    $mme_realm
+{{- end }}
+
+{{- range .Values.config.hss.bootstrap.staticusers }}
+provision_staticusers \
+    {{ .imsi }} \
+    {{ .msisdn }} \
+    {{ $.Values.config.hss.bootstrap.apn }} \
+    {{ $.Values.config.hss.bootstrap.key }} \
+    {{ $.Values.config.hss.bootstrap.opc }} \
+    {{ $.Values.config.hss.bootstrap.sqn }} \
+    {{ $.Values.config.hss.hssdb }} \
+    $mme_identity \
+    $mme_realm \
+    {{ .staticAddr }} 
+{{- end }}
+
+{{- range .Values.config.hss.bootstrap.mmes }}
+provision_mme \
+    {{ .id }} \
+    {{ .isdn }} \
+    $mme_identity \
+    $mme_realm \
+    {{ .unreachability }} \
+    {{ $.Values.config.hss.hssdb }}
+{{- end }}
diff --git a/omec/omec-control-plane/templates/bin/_hss-run.sh.tpl b/omec/omec-control-plane/templates/bin/_hss-run.sh.tpl
new file mode 100644
index 0000000..a391541
--- /dev/null
+++ b/omec/omec-control-plane/templates/bin/_hss-run.sh.tpl
@@ -0,0 +1,34 @@
+#!/bin/bash
+#
+# Copyright 2019-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.
+
+set -ex
+
+{{- if .Values.config.coreDump.enabled }}
+cp /bin/hss /tmp/coredump/
+{{- end }}
+
+CONF_DIR="/opt/c3po/hss/conf"
+LOGS_DIR="/opt/c3po/hss/logs"
+mkdir -p $CONF_DIR $LOGS_DIR
+
+cp /etc/hss/conf/{acl.conf,hss.json,hss.conf,oss.json} $CONF_DIR
+cat $CONF_DIR/{hss.json,hss.conf}
+
+cd $CONF_DIR
+make_certs.sh {{ tuple "hss" "host" . | include "omec-control-plane.diameter_endpoint" }} {{ tuple "hss" "realm" . | include "omec-control-plane.diameter_endpoint" }}
+
+cd ..
+hss -j $CONF_DIR/hss.json
diff --git a/omec/omec-control-plane/templates/bin/_mme-init.sh.tpl b/omec/omec-control-plane/templates/bin/_mme-init.sh.tpl
new file mode 100644
index 0000000..76948b7
--- /dev/null
+++ b/omec/omec-control-plane/templates/bin/_mme-init.sh.tpl
@@ -0,0 +1,59 @@
+#!/bin/sh
+#
+# Copyright 2019-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.
+
+set -ex
+
+cp /opt/mme/config/config.json /opt/mme/config/shared/config.json
+cd /opt/mme/config/shared
+
+# Set local IP address for s1ap and s11 networks to the config
+jq --arg MME_LOCAL_IP "$POD_IP" '.mme.ip_addr=$MME_LOCAL_IP' config.json > config.tmp && mv config.tmp config.json
+jq --arg MME_LOCAL_IP "$POD_IP" '.s1ap.s1ap_local_addr=$MME_LOCAL_IP' config.json > config.tmp && mv config.tmp config.json
+jq --arg MME_LOCAL_IP "$POD_IP" '.s11.egtp_local_addr=$MME_LOCAL_IP' config.json > config.tmp && mv config.tmp config.json
+
+# Set SPGWC address to the config
+# We need to convert service domain name to actual IP address
+# because mme apps does not take domain address - should be fixed in openmme
+SPGWC_ADDR=$(dig +short +search {{ .Values.config.mme.spgwAddr }})
+jq --arg SPGWC_ADDR "$SPGWC_ADDR" '.s11.sgw_addr //= $SPGWC_ADDR' config.json > config.tmp && mv config.tmp config.json
+jq --arg SPGWC_ADDR "$SPGWC_ADDR" '.s11.pgw_addr //= $SPGWC_ADDR' config.json > config.tmp && mv config.tmp config.json
+
+# Add additional redundant keys - should be fixed in openmme
+HSS_TYPE=$(jq -r '.s6a.host_type' config.json)
+HSS_HOST=$(jq -r '.s6a.host' config.json)
+jq --arg HSS_TYPE "$HSS_TYPE" '.s6a.hss_type=$HSS_TYPE' config.json > config.tmp && mv config.tmp config.json
+jq --arg HSS_HOST "$HSS_HOST" '.s6a.host_name=$HSS_HOST' config.json > config.tmp && mv config.tmp config.json
+
+# Copy the final configs for each applications
+cp /opt/mme/config/shared/config.json /opt/mme/config/shared/mme.json
+cp /opt/mme/config/shared/config.json /opt/mme/config/shared/s11.json
+cp /opt/mme/config/shared/config.json /opt/mme/config/shared/s1ap.json
+cp /opt/mme/config/shared/config.json /opt/mme/config/shared/s6a.json
+cp /opt/mme/config/s6a_fd.conf /opt/mme/config/shared/s6a_fd.conf
+cp /opt/mme/config/mme_exporter.json /opt/mme/config/shared/mme_exporter.json
+
+#This multiple copies of config needs some cleanup. For now I want 
+#that after running mme_init config to be present in the target directory
+cp /opt/mme/config/shared/* /openmme/target/conf/
+
+# Generate certs
+MME_IDENTITY={{ tuple "mme" "identity" . | include "omec-control-plane.diameter_endpoint" | quote }};
+DIAMETER_HOST=$(echo $MME_IDENTITY | cut -d'.' -f1)
+DIAMETER_REALM={{ tuple "mme" "realm" . | include "omec-control-plane.diameter_endpoint" | quote }};
+
+cp /openmme/target/conf/make_certs.sh /opt/mme/config/shared/make_certs.sh
+cd /opt/mme/config/shared
+./make_certs.sh $DIAMETER_HOST $DIAMETER_REALM
diff --git a/omec/omec-control-plane/templates/bin/_mme-run.sh.tpl b/omec/omec-control-plane/templates/bin/_mme-run.sh.tpl
new file mode 100644
index 0000000..f1b937c
--- /dev/null
+++ b/omec/omec-control-plane/templates/bin/_mme-run.sh.tpl
@@ -0,0 +1,59 @@
+#!/bin/bash
+#
+# Copyright 2019-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.
+
+APPLICATION=$1
+
+{{- if .Values.config.coreDump.enabled }}
+cp /openmme/target/bin/$APPLICATION /tmp/coredump/
+{{- end }}
+
+# copy config files to openmme target directly
+cp /opt/mme/config/shared/* /openmme/target/conf/
+
+cd /openmme/target
+export LD_LIBRARY_PATH=/usr/local/lib:./lib
+
+case $APPLICATION in
+    "mme-app")
+      echo "Starting mme-app"
+      echo "conf/mme.json"
+      cat conf/mme.json
+      ./bin/mme-app
+      ;;
+    "s1ap-app")
+      echo "Starting s1ap-app"
+      echo "conf/s1ap.json"
+      cat conf/s1ap.json
+      ./bin/s1ap-app
+      ;;
+    "s6a-app")
+      echo "Starting s6a-app"
+      echo "conf/s6a.json"
+      cat conf/s6a.json
+      echo "conf/s6a_fd.conf"
+      cat conf/s6a_fd.conf
+      ./bin/s6a-app
+      ;;
+    "s11-app")
+      echo "Starting s11-app"
+      echo "conf/s11.json"
+      cat conf/s11.json
+      ./bin/s11-app
+      ;;
+    *)
+      echo "invalid app $APPLICATION"
+      ;;
+esac
diff --git a/omec/omec-control-plane/templates/bin/_spgwc-run.sh.tpl b/omec/omec-control-plane/templates/bin/_spgwc-run.sh.tpl
new file mode 100644
index 0000000..9dfa29f
--- /dev/null
+++ b/omec/omec-control-plane/templates/bin/_spgwc-run.sh.tpl
@@ -0,0 +1,30 @@
+#!/bin/bash
+#
+# Copyright 2019-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.
+
+set -xe
+
+{{- if .Values.config.coreDump.enabled }}
+cp /bin/ngic_controlplane /tmp/coredump/
+{{- end }}
+
+mkdir -p /opt/cp/config
+cd /opt/cp/config
+
+cp /etc/cp/config/{adc_rules.cfg,cp_config.cfg,interface.cfg,meter_profile.cfg,pcc_rules.cfg,sdf_rules.cfg,app_config.cfg} .
+sed -i "s/CP_ADDR/$POD_IP/g" interface.cfg
+
+. cp_config.cfg
+ngic_controlplane $EAL_ARGS -- $APP_ARGS