Revert "Feature 11060: Remove POL and PLA modules from OSM helm chart"

This reverts commit 07367db6ef025e4fbb872b32a1f42737d2a563ec.

Change-Id: Ifa86312a16c4841603316f38ee5ffbdb4e6cc39f
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh
index a35396f..9c6ff88 100755
--- a/installers/full_install_osm.sh
+++ b/installers/full_install_osm.sh
@@ -37,6 +37,9 @@
     echo -e "     -S <VCA secret> use VCA/juju secret key"
     echo -e "     -P <VCA pubkey> use VCA/juju public key file"
     echo -e "     -A <VCA apiproxy> use VCA/juju API proxy"
+    echo -e "     --pla:          install the PLA module for placement support"
+    echo -e "     --old-sa:       install old Service Assurance framework (MON, POL); do not install Airflow and Pushgateway"
+    echo -e "     --ng-sa:        install new Service Assurance framework (Airflow, AlertManager and Pushgateway) (enabled by default)"
     echo -e "     -o <COMPONENT>: ONLY installs the specified component (k8s_monitor, ng-sa, k8scluster, docker, deploy-osm)"
     echo -e "     -O <openrc file path/cloud name>: install OSM to an OpenStack infrastructure. <openrc file/cloud name> is required. If a <cloud name> is used, the clouds.yaml file should be under ~/.config/openstack/ or /etc/openstack/"
     echo -e "     -N <openstack public network name/ID>: public network name required to setup OSM to OpenStack"
@@ -242,10 +245,13 @@
     fi
     [ -n "$OSM_VCA_APIPROXY" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set lcm.config.OSMLCM_VCA_APIPROXY=${OSM_VCA_APIPROXY}"
 
-    OSM_HELM_OPTS="${OSM_HELM_OPTS} --set airflow.defaultAirflowRepository=${DOCKER_REGISTRY_URL}${DOCKER_USER}/airflow"
-    [ ! "$OSM_DOCKER_TAG" == "testing-daily" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set-string airflow.defaultAirflowTag=${OSM_DOCKER_TAG}"
-    OSM_HELM_OPTS="${OSM_HELM_OPTS} --set airflow.ingress.web.hosts[0].name=airflow.${OSM_K8S_EXTERNAL_IP}.nip.io"
-
+    if [ -n "${INSTALL_NGSA}" ]; then
+        OSM_HELM_OPTS="${OSM_HELM_OPTS} --set airflow.defaultAirflowRepository=${DOCKER_REGISTRY_URL}${DOCKER_USER}/airflow"
+        [ ! "$OSM_DOCKER_TAG" == "testing-daily" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set-string airflow.defaultAirflowTag=${OSM_DOCKER_TAG}"
+        OSM_HELM_OPTS="${OSM_HELM_OPTS} --set airflow.ingress.web.hosts[0].name=airflow.${OSM_K8S_EXTERNAL_IP}.nip.io"
+    else
+        OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.oldServiceAssurance=true --set airflow.enabled=false"
+    fi
     if [ -n "${OSM_BEHIND_PROXY}" ]; then
         OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.behindHttpProxy=true"
         [ -n "${HTTP_PROXY}" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.httpProxy.HTTP_PROXY=\"${HTTP_PROXY}\""
@@ -271,6 +277,15 @@
     [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
 }
 
+function install_osm_ngsa_service() {
+    [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
+    NGSA_OPTS="-i ${OSM_K8S_EXTERNAL_IP} -d ${OSM_HELM_WORK_DIR} -D ${OSM_DEVOPS} -s ${OSM_NAMESPACE} -t ${OSM_DOCKER_TAG} -U ${DOCKER_USER} ${DEBUG_INSTALL}"
+    [ -n "${DOCKER_REGISTRY_URL}" ] && NGSA_OPTS="${NGSA_OPTS} -r ${DOCKER_REGISTRY_URL}"
+    $OSM_DEVOPS/installers/install_ngsa.sh ${NGSA_OPTS} || \
+    FATAL_TRACK install_osm_ngsa_service "install_ngsa.sh failed"
+    [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
+}
+
 function add_local_k8scluster() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
     # OSM_HOSTNAME=$(kubectl get --namespace osm -o jsonpath="{.spec.rules[0].host}" ingress nbi-ingress)
@@ -539,7 +554,7 @@
     fi
     track mgmtcluster mgmt_and_aux_cluster_ok
 
-    # Deploy OSM (OSM helm chart)
+    # Deploy OSM (mongodb, OSM helm chart, NGSA)
     echo "Deploying OSM in the K8s cluster ..."
     deploy_osm
 
@@ -655,11 +670,14 @@
     echo "INSTALL_JUJU=$INSTALL_JUJU"
     echo "INSTALL_K8S_MONITOR=$INSTALL_K8S_MONITOR"
     echo "INSTALL_LXD=$INSTALL_LXD"
+    echo "INSTALL_NGSA=$INSTALL_NGSA"
     echo "INSTALL_DOCKER=$INSTALL_DOCKER"
     echo "INSTALL_ONLY=$INSTALL_ONLY"
     echo "INSTALL_ONLY_DEPLOY_OSM=$INSTALL_ONLY_DEPLOY_OSM"
     echo "INSTALL_ONLY_DOCKER_CE=$INSTALL_ONLY_DOCKER_CE"
     echo "INSTALL_ONLY_K8S_CLUSTER=$INSTALL_ONLY_K8S_CLUSTER"
+    echo "INSTALL_ONLY_NGSA=$INSTALL_ONLY_NGSA"
+    echo "INSTALL_PLA=$INSTALL_PLA"
     echo "INSTALL_TO_OPENSTACK=$INSTALL_TO_OPENSTACK"
     echo "INSTALL_VIMEMU=$INSTALL_VIMEMU"
     echo "OPENSTACK_PUBLIC_NET_NAME=$OPENSTACK_PUBLIC_NET_NAME"
@@ -718,6 +736,8 @@
 RELEASE="testing-daily"
 REPOSITORY="testing"
 INSTALL_K8S_MONITOR=""
+INSTALL_NGSA="y"
+INSTALL_PLA=""
 INSTALL_VIMEMU=""
 LXD_REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/lxd"
 LXD_REPOSITORY_PATH=""
@@ -733,6 +753,7 @@
 INSTALL_ONLY_DEPLOY_OSM=""
 INSTALL_ONLY_DOCKER_CE=""
 INSTALL_ONLY_K8S_CLUSTER=""
+INSTALL_ONLY_NGSA=""
 INSTALL_DOCKER=""
 INSTALL_JUJU=""
 INSTALL_NOHOSTCLIENT=""
@@ -810,6 +831,7 @@
         o)
             INSTALL_ONLY="y"
             [ "${OPTARG}" == "k8s_monitor" ] && INSTALL_K8S_MONITOR="y" && continue
+            [ "${OPTARG}" == "ng-sa" ] && INSTALL_ONLY_NGSA="y" && continue
             [ "${OPTARG}" == "docker" ] && INSTALL_ONLY_DOCKER_CE="y" && continue
             [ "${OPTARG}" == "k8scluster" ] && INSTALL_ONLY_K8S_CLUSTER="y" && continue
             [ "${OPTARG}" == "deploy-osm" ] && INSTALL_ONLY_DEPLOY_OSM="y" && continue
@@ -909,6 +931,9 @@
             [ "${OPTARG}" == "ha" ] && continue
             [ "${OPTARG}" == "tag" ] && continue
             [ "${OPTARG}" == "registry" ] && continue
+            [ "${OPTARG}" == "pla" ] && INSTALL_PLA="y" && continue
+            [ "${OPTARG}" == "old-sa" ] && INSTALL_NGSA="" && continue
+            [ "${OPTARG}" == "ng-sa" ] && INSTALL_NGSA="y" && continue
             [ "${OPTARG}" == "volume" ] && OPENSTACK_ATTACH_VOLUME="true" && continue
             [ "${OPTARG}" == "nocachelxdimages" ] && continue
             [ "${OPTARG}" == "cachelxdimages" ] && INSTALL_CACHELXDIMAGES="--cachelxdimages" && continue
@@ -989,6 +1014,7 @@
         [ -n "$INSTALL_ONLY_K8S_CLUSTER" ] && install_k8s_cluster
         [ -n "$INSTALL_K8S_MONITOR" ] && install_k8s_monitoring
         [ -n "$INSTALL_ONLY_DEPLOY_OSM" ] && deploy_osm
+        [ -n "$INSTALL_ONLY_NGSA" ] && install_osm_ngsa_service
         echo -e "\nDONE" && exit 0
     fi
     # This is where installation starts
diff --git a/installers/helm/osm/templates/airflow/airflow-secret.yaml b/installers/helm/osm/templates/airflow/airflow-secret.yaml
index d373eeb..10c664b 100644
--- a/installers/helm/osm/templates/airflow/airflow-secret.yaml
+++ b/installers/helm/osm/templates/airflow/airflow-secret.yaml
@@ -1,3 +1,4 @@
+{{- if not .Values.global.oldServiceAssurance -}}
 {{- if .Values.airflow.enabled -}}
 #######################################################################################
 # Copyright ETSI Contributors and Others.
@@ -24,4 +25,5 @@
     {{- include "osm.labels" . | nindent 4 }}
 data:
   webserver-secret-key: {{ randAlphaNum 32 | b64enc | quote }}
+{{- end }}
 {{- end }}
\ No newline at end of file
diff --git a/installers/helm/osm/templates/alertmanager/alertmanager-ingress.yaml b/installers/helm/osm/templates/alertmanager/alertmanager-ingress.yaml
index 9479d9c..d8028e8 100644
--- a/installers/helm/osm/templates/alertmanager/alertmanager-ingress.yaml
+++ b/installers/helm/osm/templates/alertmanager/alertmanager-ingress.yaml
@@ -1,3 +1,4 @@
+{{- if not .Values.global.oldServiceAssurance -}}
 {{- if .Values.alertmanager.enabled -}}
 #######################################################################################
 # Copyright ETSI Contributors and Others.
@@ -38,4 +39,5 @@
             name: alertmanager
             port:
               number: 9093
+{{- end }}
 {{- end }}
\ No newline at end of file
diff --git a/installers/helm/osm/templates/mon/mon-deployment.yaml b/installers/helm/osm/templates/mon/mon-deployment.yaml
index 9ec3634..4473ffa 100644
--- a/installers/helm/osm/templates/mon/mon-deployment.yaml
+++ b/installers/helm/osm/templates/mon/mon-deployment.yaml
@@ -57,8 +57,10 @@
             {{- toYaml .Values.global.securityContext | nindent 12 }}
           image: {{ include "osm.mon.image" . }}
           imagePullPolicy: {{ .Values.global.image.pullPolicy }}
+          {{- if not .Values.global.oldServiceAssurance }}
           command: ["/bin/bash"]
           args: ["scripts/dashboarder-start.sh"]
+          {{- end }}
           ports:
             - containerPort: 8662
               protocol: TCP
diff --git a/installers/helm/osm/templates/pla/pla-configmap.yaml b/installers/helm/osm/templates/pla/pla-configmap.yaml
new file mode 100644
index 0000000..be346a0
--- /dev/null
+++ b/installers/helm/osm/templates/pla/pla-configmap.yaml
@@ -0,0 +1,30 @@
+{{- if .Values.global.oldServiceAssurance -}}
+{{- if .Values.pla.enabled -}}
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+#######################################################################################
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ include "osm.fullname" . }}-pla-configmap
+  labels:
+    {{- include "osm.labels" . | nindent 4 }}
+data:
+  OSMPLA_DATABASE_HOST: "mongo"
+  OSMPLA_MESSAGE_HOST: "kafka"
+  OSMPLA_GLOBAL_LOG_LEVEL: {{ .Values.pla.logLevel | default .Values.global.logLevel | default "INFO" }}
+{{- end }}
+{{- end }}
\ No newline at end of file
diff --git a/installers/helm/osm/templates/pla/pla-deployment.yaml b/installers/helm/osm/templates/pla/pla-deployment.yaml
new file mode 100644
index 0000000..cb8d85b
--- /dev/null
+++ b/installers/helm/osm/templates/pla/pla-deployment.yaml
@@ -0,0 +1,88 @@
+{{- if .Values.global.oldServiceAssurance -}}
+{{- if .Values.pla.enabled -}}
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+#######################################################################################
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: pla
+  labels:
+    {{- include "osm.labels" . | nindent 4 }}
+spec:
+  replicas: {{ .Values.pla.replicaCount | default .Values.global.replicaCount }}
+  selector:
+    matchLabels:
+      app.kubernetes.io/component: pla
+      {{- include "osm.selectorLabels" . | nindent 6 }}
+  template:
+    metadata:
+      {{- with .Values.global.podAnnotations }}
+      annotations:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      labels:
+        app.kubernetes.io/component: pla
+        {{- include "osm.selectorLabels" . | nindent 8 }}
+    spec:
+      {{- with .Values.global.imagePullSecrets }}
+      imagePullSecrets:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      serviceAccountName: {{ include "osm.serviceAccountName" . }}
+      securityContext:
+        {{- toYaml .Values.global.podSecurityContext | nindent 8 }}
+      initContainers:
+        - name: kafka-mongo-test
+          image: alpine:latest
+          command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 {{ .Values.global.db.mongo.mongoService }} 27017); do sleep 3; done; exit 0"]
+      containers:
+        - name: pla
+          securityContext:
+            readOnlyRootFilesystem: true
+            allowPrivilegeEscalation: false
+            runAsNonRoot: true
+            {{- toYaml .Values.global.securityContext | nindent 12 }}
+          image: {{ include "osm.pla.image" . }}
+          imagePullPolicy: {{ .Values.global.image.pullPolicy }}
+          resources:
+            limits:
+              memory: 1024Mi
+            requests:
+              memory: 128Mi
+          envFrom:
+            - configMapRef:
+                name: {{ include "osm.fullname" . }}-pla-configmap
+          env:
+          - name: OSMPLA_DATABASE_URI
+            valueFrom:
+              secretKeyRef:
+                name: {{ include "osm.fullname" . }}-secret
+                key: OSM_DATABASE_URI
+      {{- with .Values.global.nodeSelector }}
+      nodeSelector:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      {{- with .Values.global.affinity }}
+      affinity:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      {{- with .Values.global.tolerations }}
+      tolerations:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+{{- end }}
+{{- end }}
\ No newline at end of file
diff --git a/installers/helm/osm/templates/pol/pol-configmap.yaml b/installers/helm/osm/templates/pol/pol-configmap.yaml
new file mode 100644
index 0000000..8d899bc
--- /dev/null
+++ b/installers/helm/osm/templates/pol/pol-configmap.yaml
@@ -0,0 +1,30 @@
+{{- if .Values.global.oldServiceAssurance -}}
+{{- if .Values.pol.enabled -}}
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+#######################################################################################
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: {{ include "osm.fullname" . }}-pol-configmap
+  labels:
+    {{- include "osm.labels" . | nindent 4 }}
+data:
+  OSMPOL_MESSAGE_HOST: "kafka"
+  OSMPOL_MESSAGE_PORT: "9092"
+  OSMPOL_GLOBAL_LOG_LEVEL: {{ .Values.pol.logLevel | default .Values.global.logLevel | default "INFO" }}
+{{- end }}
+{{- end }}
\ No newline at end of file
diff --git a/installers/helm/osm/templates/pol/pol-deployment.yaml b/installers/helm/osm/templates/pol/pol-deployment.yaml
new file mode 100644
index 0000000..313b4a6
--- /dev/null
+++ b/installers/helm/osm/templates/pol/pol-deployment.yaml
@@ -0,0 +1,101 @@
+{{- if .Values.global.oldServiceAssurance -}}
+{{- if .Values.pol.enabled -}}
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# 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.
+#######################################################################################
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: pol
+  labels:
+    {{- include "osm.labels" . | nindent 4 }}
+spec:
+  replicas: {{ .Values.pol.replicaCount | default .Values.global.replicaCount }}
+  selector:
+    matchLabels:
+      app.kubernetes.io/component: pol
+      {{- include "osm.selectorLabels" . | nindent 6 }}
+  template:
+    metadata:
+      {{- with .Values.global.podAnnotations }}
+      annotations:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      labels:
+        app.kubernetes.io/component: pol
+        {{- include "osm.selectorLabels" . | nindent 8 }}
+    spec:
+      {{- with .Values.global.imagePullSecrets }}
+      imagePullSecrets:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      serviceAccountName: {{ include "osm.serviceAccountName" . }}
+      securityContext:
+        {{- toYaml .Values.global.podSecurityContext | nindent 8 }}
+      initContainers:
+        - name: kafka-mongo-test
+          image: alpine:latest
+          command: ["sh", "-c", "until (nc -zvw1 kafka 9092 && nc -zvw1 {{ .Values.global.db.mongo.mongoService }} 27017); do sleep 3; done; exit 0"]
+      containers:
+        - name: pol
+          securityContext:
+            # readOnlyRootFilesystem: true
+            allowPrivilegeEscalation: false
+            runAsNonRoot: true
+            {{- toYaml .Values.global.securityContext | nindent 12 }}
+          image: {{ include "osm.pol.image" . }}
+          imagePullPolicy: {{ .Values.global.image.pullPolicy }}
+          ports:
+            - containerPort: 8662
+              protocol: TCP
+          resources:
+            limits:
+              memory: 1024Mi
+            requests:
+              memory: 128Mi
+          envFrom:
+            - configMapRef:
+                name: {{ include "osm.fullname" . }}-pol-configmap
+          {{- if not .Values.pol.useOsmSecret }}
+            - secretRef:
+                name: {{ .Values.pol.secretName | default "pol-secret" }}
+          {{- else }}
+          env:
+            - name: OSMPOL_DATABASE_COMMONKEY
+              valueFrom:
+                secretKeyRef:
+                  name: {{ include "osm.fullname" . }}-secret
+                  key: OSM_DATABASE_COMMONKEY
+            - name: OSMPOL_DATABASE_URI
+              valueFrom:
+                secretKeyRef:
+                  name: {{ include "osm.fullname" . }}-secret
+                  key: OSM_DATABASE_URI
+          {{- end }}
+      {{- with .Values.global.nodeSelector }}
+      nodeSelector:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      {{- with .Values.global.affinity }}
+      affinity:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+      {{- with .Values.global.tolerations }}
+      tolerations:
+        {{- toYaml . | nindent 8 }}
+      {{- end }}
+{{- end }}
+{{- end }}
\ No newline at end of file
diff --git a/installers/helm/osm/templates/webhook_translator/webhook-translator-configmap.yaml b/installers/helm/osm/templates/webhook_translator/webhook-translator-configmap.yaml
index a266ea7..f446413 100644
--- a/installers/helm/osm/templates/webhook_translator/webhook-translator-configmap.yaml
+++ b/installers/helm/osm/templates/webhook_translator/webhook-translator-configmap.yaml
@@ -1,3 +1,4 @@
+{{- if not .Values.global.oldServiceAssurance -}}
 {{- if .Values.webhookTranslator.enabled -}}
 #######################################################################################
 # Copyright ETSI Contributors and Others.
@@ -24,4 +25,5 @@
 data:
   AIRFLOW_HOST: "airflow-webserver"
   AIRFLOW_PORT: "8080"
+{{- end }}
 {{- end }}
\ No newline at end of file
diff --git a/installers/helm/osm/templates/webhook_translator/webhook-translator-deployment.yaml b/installers/helm/osm/templates/webhook_translator/webhook-translator-deployment.yaml
index 60b2ae8..84a3dba 100644
--- a/installers/helm/osm/templates/webhook_translator/webhook-translator-deployment.yaml
+++ b/installers/helm/osm/templates/webhook_translator/webhook-translator-deployment.yaml
@@ -1,3 +1,4 @@
+{{- if not .Values.global.oldServiceAssurance -}}
 {{- if .Values.webhookTranslator.enabled -}}
 #######################################################################################
 # Copyright ETSI Contributors and Others.
@@ -78,4 +79,5 @@
       tolerations:
         {{- toYaml . | nindent 8 }}
       {{- end }}
+{{- end }}
 {{- end }}
\ No newline at end of file
diff --git a/installers/helm/osm/templates/webhook_translator/webhook-translator-ingress.yaml b/installers/helm/osm/templates/webhook_translator/webhook-translator-ingress.yaml
index d803574..f4e8b64 100644
--- a/installers/helm/osm/templates/webhook_translator/webhook-translator-ingress.yaml
+++ b/installers/helm/osm/templates/webhook_translator/webhook-translator-ingress.yaml
@@ -1,3 +1,4 @@
+{{- if not .Values.global.oldServiceAssurance -}}
 {{- if .Values.webhookTranslator.enabled -}}
 #######################################################################################
 # Copyright ETSI Contributors and Others.
@@ -38,4 +39,5 @@
             name: webhook-translator
             port:
               number: 9998
+{{- end }}
 {{- end }}
\ No newline at end of file
diff --git a/installers/helm/osm/templates/webhook_translator/webhook-translator-secret.yaml b/installers/helm/osm/templates/webhook_translator/webhook-translator-secret.yaml
index 10f9c6e..e11022c 100644
--- a/installers/helm/osm/templates/webhook_translator/webhook-translator-secret.yaml
+++ b/installers/helm/osm/templates/webhook_translator/webhook-translator-secret.yaml
@@ -1,3 +1,4 @@
+{{- if not .Values.global.oldServiceAssurance -}}
 {{- if .Values.webhookTranslator.enabled -}}
 #######################################################################################
 # Copyright ETSI Contributors and Others.
@@ -27,4 +28,5 @@
   AIRFLOW_USER: {{ "admin" | b64enc | quote }}
   # AIRFLOW_PASS: {{ randAlphaNum 32 | b64enc | quote }}
   AIRFLOW_PASS: {{ "admin" | b64enc | quote }}
+{{- end }}
 {{- end }}
\ No newline at end of file
diff --git a/installers/helm/osm/templates/webhook_translator/webhook-translator-service.yaml b/installers/helm/osm/templates/webhook_translator/webhook-translator-service.yaml
index 9db63ee..11d2508 100644
--- a/installers/helm/osm/templates/webhook_translator/webhook-translator-service.yaml
+++ b/installers/helm/osm/templates/webhook_translator/webhook-translator-service.yaml
@@ -1,3 +1,4 @@
+{{- if not .Values.global.oldServiceAssurance -}}
 {{- if .Values.webhookTranslator.enabled -}}
 #######################################################################################
 # Copyright ETSI Contributors and Others.
@@ -33,4 +34,5 @@
   selector:
     app.kubernetes.io/component: webhook-translator
     {{- include "osm.selectorLabels" . | nindent 4 }}
+{{- end }}
 {{- end }}
\ No newline at end of file
diff --git a/installers/helm/osm/values.yaml b/installers/helm/osm/values.yaml
index a046b9a..b1b8b21 100644
--- a/installers/helm/osm/values.yaml
+++ b/installers/helm/osm/values.yaml
@@ -88,6 +88,8 @@
     # HTTPS_PROXY: <HTTPS_PROXY>
     # NO_PROXY: <NO_PROXY>
 
+  oldServiceAssurance: false
+
 airflow:
   enabled: true
   config:
@@ -401,6 +403,26 @@
     # tag: "testing-daily"
   # replicaCount: 1
 
+# pla module is disabled by default unless global.oldServiceAssurance and pla.enabled are set to true
+pla:
+  enabled: false
+  # logLevel: DEBUG
+  image: {}
+    # repository: opensourcemano/pla
+    # tag: "testing-daily"
+  # replicaCount: 1
+
+# pol module is disabled by default unless global.oldServiceAssurance and pol.enabled are set to true
+pol:
+  enabled: true
+  # logLevel: DEBUG
+  image: {}
+    # repository: opensourcemano/pol
+    # tag: "testing-daily"
+  # replicaCount: 1
+  useOsmSecret: true
+  # secretName: "pol-secret"
+
 prometheus:
   enabled: true
   configmapReload:
diff --git a/installers/helm/values/airflow-values.yaml b/installers/helm/values/airflow-values.yaml
new file mode 100644
index 0000000..798648c
--- /dev/null
+++ b/installers/helm/values/airflow-values.yaml
@@ -0,0 +1,86 @@
+#
+#   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.
+#
+---
+config:
+  core:
+    parallelism: 4
+    dag_concurrency: 2
+    max_active_tasks_per_dag: 2
+    worker_concurrency: 2
+    dags_folder: "/home/airflow/.local/lib/python3.10/site-packages/osm_ngsa"
+defaultAirflowRepository: opensourcemano/airflow
+defaultAirflowTag: "testing-daily"
+executor: LocalExecutor
+extraEnv: |
+  - name: AIRFLOW__API__AUTH_BACKENDS
+    value: 'airflow.api.auth.backend.basic_auth'
+  - name: AIRFLOW__LOGGING__LOGGING_LEVEL
+    value: 'INFO'
+  - name: OSMMON_DATABASE_COMMONKEY
+    valueFrom:
+      secretKeyRef:
+        name: osm-secret
+        key: OSM_DATABASE_COMMONKEY
+# extraEnvFrom: |
+#   - secretRef:
+#       name: ngsa-secret
+ingress:
+  web:
+    enabled: True
+    hosts:
+      - name: "localhost"
+    ingressClassName: nginx
+# scheduler:
+#   resources:
+#     requests:
+#       memory: 512Mi
+#       cpu: 250m
+#     limits:
+#       memory: 1Gi
+#       cpu: 500m
+webserverSecretKeySecretName: airflow-webserver-secret
+webserver:
+  resources:
+    requests:
+      memory: 256Mi
+      cpu: 250m
+    limits:
+      memory: 1Gi
+      cpu: 500m
+  service:
+    type: ClusterIP
+    ports:
+      - name: airflow-ui
+        port: "{{ .Values.ports.airflowUI }}"
+        targetPort: "{{ .Values.ports.airflowUI }}"
+workers:
+  persistence:
+    size: 2Gi
+  replicas: 1
+  resources:
+    requests:
+      memory: 512Mi
+      cpu: 250m
+    limits:
+      memory: 1Gi
+      cpu: 500m
+  logGroomerSidecar:
+    retentionDays: 7
+    resources:
+      limits:
+        cpu: 100m
+        memory: 128Mi
+      requests:
+        cpu: 100m
+        memory: 128Mi
diff --git a/installers/install_ngsa.sh b/installers/install_ngsa.sh
new file mode 100755
index 0000000..6931432
--- /dev/null
+++ b/installers/install_ngsa.sh
@@ -0,0 +1,105 @@
+#!/bin/bash
+#
+#   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 +eux
+
+# Helm chart 1.6.0 correspondes to Airflow 2.3.0
+AIRFLOW_HELM_VERSION=1.9.0
+
+# Install Airflow helm chart
+function install_airflow() {
+    [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
+    # copy airflow-values.yaml to the destination folder
+    sudo mkdir -p ${OSM_HELM_WORK_DIR}
+    sudo cp ${OSM_DEVOPS}/installers/helm/values/airflow-values.yaml ${OSM_HELM_WORK_DIR}
+    # update airflow-values.yaml to use the right tag
+    echo "Updating Helm values file helm/values/airflow-values.yaml to use defaultAirflowTag: ${OSM_DOCKER_TAG}"
+    sudo sed -i "s#defaultAirflowTag:.*#defaultAirflowTag: \"${OSM_DOCKER_TAG}\"#g" ${OSM_HELM_WORK_DIR}/airflow-values.yaml
+    echo "Updating Helm values file helm/values/airflow-values.yaml to use defaultAirflowRepository: ${DOCKER_REGISTRY_URL}${DOCKER_USER}/airflow"
+    sudo sed -i "s#defaultAirflowRepository:.*#defaultAirflowRepository: ${DOCKER_REGISTRY_URL}${DOCKER_USER}/airflow#g" ${OSM_HELM_WORK_DIR}/airflow-values.yaml
+    echo "Updating Helm values file helm/values/airflow-values.yaml to set ingress.web.hosts with host \"airflow.${DEFAULT_IP}.nip.io\""
+    sudo sed -i "s#name: \"localhost\"#name: \"airflow.${DEFAULT_IP}.nip.io\"#g" ${OSM_HELM_WORK_DIR}/airflow-values.yaml
+
+    helm repo add apache-airflow https://airflow.apache.org
+    helm repo update
+    helm upgrade airflow apache-airflow/airflow -n ${OSM_NAMESPACE} --create-namespace --install -f ${OSM_HELM_WORK_DIR}/airflow-values.yaml --version ${AIRFLOW_HELM_VERSION} --timeout 10m || FATAL_TRACK ngsa "Failed installing airflow helm chart"
+    [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
+}
+
+# main
+while getopts ":D:d:i:s:t:r:U:-: " o; do
+    case "${o}" in
+        i)
+            DEFAULT_IP="${OPTARG}"
+            ;;
+        D)
+            OSM_DEVOPS="${OPTARG}"
+            ;;
+        d)
+            OSM_HELM_WORK_DIR="${OPTARG}"
+            ;;
+        s)
+            OSM_NAMESPACE="${OPTARG}"
+            ;;
+        t)
+            OSM_DOCKER_TAG="${OPTARG}"
+            ;;
+        r)
+            DOCKER_REGISTRY_URL="${OPTARG}"
+            ;;
+        U)
+            DOCKER_USER="${OPTARG}"
+            ;;
+        -)
+            [ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="y" && continue
+            echo -e "Invalid option: '--$OPTARG'\n" >&2
+            exit 1
+            ;;
+        :)
+            echo "Option -$OPTARG requires an argument" >&2
+            exit 1
+            ;;
+        \?)
+            echo -e "Invalid option: '-$OPTARG'\n" >&2
+            exit 1
+            ;;
+        *)
+            exit 1
+            ;;
+    esac
+done
+
+DEBUG_INSTALL=${DEBUG_INSTALL:-}
+DEFAULT_IP=${DEFAULT_IP:-"127.0.0.1"}
+OSM_DEVOPS=${OSM_DEVOPS:-"/usr/share/osm-devops"}
+OSM_DOCKER_TAG=${OSM_DOCKER_TAG:-"testing-daily"}
+OSM_HELM_WORK_DIR=${OSM_HELM_WORK_DIR:-"/etc/osm/helm"}
+OSM_NAMESPACE=${OSM_NAMESPACE:-"osm"}
+DOCKER_REGISTRY_URL=${DOCKER_REGISTRY_URL:-}
+DOCKER_USER=${DOCKER_USER:-"opensourcemano"}
+echo "DEBUG_INSTALL=$DEBUG_INSTALL"
+echo "DEFAULT_IP=$DEFAULT_IP"
+echo "OSM_DEVOPS=$OSM_DEVOPS"
+echo "OSM_DOCKER_TAG=$OSM_DOCKER_TAG"
+echo "OSM_HELM_WORK_DIR=$OSM_HELM_WORK_DIR"
+echo "OSM_NAMESPACE=$OSM_NAMESPACE"
+echo "DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL"
+echo "DOCKER_USER=$DOCKER_USER"
+
+source $OSM_DEVOPS/common/logging
+source $OSM_DEVOPS/common/track
+
+install_airflow
+track deploy_osm airflow_ok
diff --git a/installers/install_osm.sh b/installers/install_osm.sh
index fa200f0..622ff36 100755
--- a/installers/install_osm.sh
+++ b/installers/install_osm.sh
@@ -41,6 +41,9 @@
     echo -e "     -S <VCA secret> use VCA/juju secret key"
     echo -e "     -P <VCA pubkey> use VCA/juju public key file"
     echo -e "     -A <VCA apiproxy> use VCA/juju API proxy"
+    echo -e "     --pla:          install the PLA module for placement support"
+    echo -e "     --old-sa:       install old Service Assurance framework (MON, POL); do not install Airflow and Pushgateway"
+    echo -e "     --ng-sa:        install new Service Assurance framework (Airflow, AlertManager and Pushgateway) (enabled by default)"
     echo -e "     -o <COMPONENT>: ONLY installs the specified component (k8s_monitor, ng-sa, k8scluster, docker, deploy-osm)"
     echo -e "     -O <openrc file path/cloud name>: install OSM to an OpenStack infrastructure. <openrc file/cloud name> is required. If a <cloud name> is used, the clouds.yaml file should be under ~/.config/openstack/ or /etc/openstack/"
     echo -e "     -N <openstack public network name/ID>: public network name required to setup OSM to OpenStack"
diff --git a/installers/uninstall_osm.sh b/installers/uninstall_osm.sh
index 1aa9f36..1df64b6 100755
--- a/installers/uninstall_osm.sh
+++ b/installers/uninstall_osm.sh
@@ -60,7 +60,7 @@
     echo "Now osm docker images and volumes will be deleted"
     # TODO: clean-up of images should take into account if other tags were used for specific modules
     newgrp docker << EONG
-for module in ro lcm keystone nbi mon osmclient; do
+for module in ro lcm keystone nbi mon pol pla osmclient; do
     docker image rm ${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module}:${OSM_DOCKER_TAG}
 done
 EONG
@@ -119,6 +119,7 @@
 RELEASE="ReleaseTEN"
 REPOSITORY="stable"
 INSTALL_VIMEMU=""
+INSTALL_PLA=""
 LXD_REPOSITORY_BASE="https://osm-download.etsi.org/repository/osm/lxd"
 LXD_REPOSITORY_PATH=""
 INSTALL_LIGHTWEIGHT="y"
@@ -227,6 +228,8 @@
             [ "${OPTARG}" == "LCM" ] && TO_REBUILD="$TO_REBUILD LCM" && continue
             [ "${OPTARG}" == "RO" ] && TO_REBUILD="$TO_REBUILD RO" && continue
             [ "${OPTARG}" == "MON" ] && TO_REBUILD="$TO_REBUILD MON" && continue
+            [ "${OPTARG}" == "POL" ] && TO_REBUILD="$TO_REBUILD POL" && continue
+            [ "${OPTARG}" == "PLA" ] && TO_REBUILD="$TO_REBUILD PLA" && continue
             [ "${OPTARG}" == "osmclient" ] && TO_REBUILD="$TO_REBUILD osmclient" && continue
             [ "${OPTARG}" == "KAFKA" ] && TO_REBUILD="$TO_REBUILD KAFKA" && continue
             [ "${OPTARG}" == "MONGO" ] && TO_REBUILD="$TO_REBUILD MONGO" && continue
@@ -307,6 +310,7 @@
             [ "${OPTARG}" == "ha" ] && continue
             [ "${OPTARG}" == "tag" ] && continue
             [ "${OPTARG}" == "registry" ] && continue
+            [ "${OPTARG}" == "pla" ] && INSTALL_PLA="y" && continue
             [ "${OPTARG}" == "volume" ] && OPENSTACK_ATTACH_VOLUME="true" && continue
             [ "${OPTARG}" == "nocachelxdimages" ] && continue
             [ "${OPTARG}" == "cachelxdimages" ] && INSTALL_CACHELXDIMAGES="--cachelxdimages" && continue