[AAI] Templatize MSB services

Instead of "hardcoding" all services, let's generate them with two
values and shrink a little bit template.
It also simplify the reading of the template.

Issue-ID: OOM-2664
Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com>
Change-Id: I2a5f181fac93f34e074998aeaf82489f8305de1f
diff --git a/kubernetes/aai/components/aai-traversal/templates/deployment.yaml b/kubernetes/aai/components/aai-traversal/templates/deployment.yaml
index ab1cb30..6f5ac82 100644
--- a/kubernetes/aai/components/aai-traversal/templates/deployment.yaml
+++ b/kubernetes/aai/components/aai-traversal/templates/deployment.yaml
@@ -2,6 +2,7 @@
 # Copyright (c) 2017 Amdocs, Bell Canada
 # Modifications Copyright (c) 2018 AT&T
 # Modifications Copyright (c) 2020 Nokia, Orange
+# Modifications Copyright (c) 2021 Orange
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -39,304 +40,34 @@
       name: {{ include "common.name" . }}
       annotations:
         checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}
+      {{- if .Values.global.msbEnabled }}
+        {{ $values := .Values }}
         msb.onap.org/service-info: '[
+        {{- range $api_endpoint := $values.aai_enpoints -}}
+          {{- range $api_version := $values.api_list }}
           {
-              "serviceName": "_aai-generic-query",
-              "version": "v11",
-              "url": "/aai/v11/search/generic-query",
+              "serviceName": "_{{ $api_endpoint.name }}",
+              "version": "v{{ $api_version }}",
+              "url": "/aai/v{{ $api_version }}/{{ $api_endpoint.url }}",
               "protocol": "REST",
               "port": "8446",
               "enable_ssl": true,
               "lb_policy":"ip_hash",
               "visualRange": "1",
-              "path": "/aai/v11/search/generic-query"
+              "path": "/aai/v{{ $api_version }}/{{ $api_endpoint.url }}"
           },
           {
-              "serviceName": "_aai-generic-query",
-              "version": "v12",
-              "url": "/aai/v12/search/generic-query",
+              "serviceName": "{{ $api_endpoint.name }}",
+              "version": "v{{ $api_version }}",
+              "url": "/aai/v{{ $api_version }}/{{ $api_endpoint.url }}",
               "protocol": "REST",
               "port": "8446",
               "enable_ssl": true,
               "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v12/search/generic-query"
+              "visualRange": "1"
           },
-          {
-              "serviceName": "_aai-generic-query",
-              "version": "v13",
-              "url": "/aai/v13/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v13/search/generic-query"
-          },
-          {
-              "serviceName": "_aai-generic-query",
-              "version": "v14",
-              "url": "/aai/v14/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v14/search/generic-query"
-          },
-          {
-              "serviceName": "_aai-generic-query",
-              "version": "v15",
-              "url": "/aai/v15/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v15/search/generic-query"
-          },
-          {
-              "serviceName": "_aai-generic-query",
-              "version": "v16",
-              "url": "/aai/v16/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v16/search/generic-query"
-          },
-          {
-              "serviceName": "_aai-generic-query",
-              "version": "v17",
-              "url": "/aai/v17/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v17/search/generic-query"
-          },
-          {
-              "serviceName": "_aai-generic-query",
-              "version": "v18",
-              "url": "/aai/v18/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v18/search/generic-query"
-          },
-          {
-              "serviceName": "_aai-generic-query",
-              "version": "v19",
-              "url": "/aai/v19/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v19/search/generic-query"
-          },
-          {
-              "serviceName": "_aai-nodes-query",
-              "version": "v11",
-              "url": "/aai/v11/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v11/search/nodes-query"
-          },
-          {
-              "serviceName": "_aai-nodes-query",
-              "version": "v12",
-              "url": "/aai/v12/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v12/search/nodes-query"
-          },
-          {
-              "serviceName": "_aai-nodes-query",
-              "version": "v13",
-              "url": "/aai/v13/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v13/search/nodes-query"
-          },
-          {
-              "serviceName": "_aai-nodes-query",
-              "version": "v14",
-              "url": "/aai/v14/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v14/search/nodes-query"
-          },
-          {
-              "serviceName": "_aai-nodes-query",
-              "version": "v15",
-              "url": "/aai/v15/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v15/search/nodes-query"
-          },
-          {
-              "serviceName": "_aai-nodes-query",
-              "version": "v16",
-              "url": "/aai/v16/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v16/search/nodes-query"
-          },
-          {
-              "serviceName": "_aai-nodes-query",
-              "version": "v17",
-              "url": "/aai/v17/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v17/search/nodes-query"
-          },
-          {
-              "serviceName": "_aai-nodes-query",
-              "version": "v18",
-              "url": "/aai/v18/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v18/search/nodes-query"
-          },
-          {
-              "serviceName": "_aai-nodes-query",
-              "version": "v19",
-              "url": "/aai/v19/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v19/search/nodes-query"
-          },
-          {
-              "serviceName": "_aai-query",
-              "version": "v11",
-              "url": "/aai/v11/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v11/query"
-          },
-          {
-              "serviceName": "_aai-query",
-              "version": "v12",
-              "url": "/aai/v12/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v12/query"
-          },
-          {
-              "serviceName": "_aai-query",
-              "version": "v13",
-              "url": "/aai/v13/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v13/query"
-          },
-          {
-              "serviceName": "_aai-query",
-              "version": "v14",
-              "url": "/aai/v14/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v14/query"
-          },
-          {
-              "serviceName": "_aai-query",
-              "version": "v15",
-              "url": "/aai/v15/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v15/query"
-          },
-          {
-              "serviceName": "_aai-query",
-              "version": "v16",
-              "url": "/aai/v16/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v16/query"
-          },
-          {
-              "serviceName": "_aai-query",
-              "version": "v17",
-              "url": "/aai/v17/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v17/query"
-          },
-          {
-              "serviceName": "_aai-query",
-              "version": "v18",
-              "url": "/aai/v18/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v18/query"
-          },
-          {
-              "serviceName": "_aai-query",
-              "version": "v19",
-              "url": "/aai/v19/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1",
-              "path": "/aai/v19/query"
-          },
+          {{- end }}
+        {{- end }}
           {
               "serviceName": "_aai-named-query",
               "url": "/aai/search",
@@ -348,276 +79,6 @@
               "path": "/aai/search"
           },
           {
-              "serviceName": "aai-generic-query",
-              "version": "v11",
-              "url": "/aai/v11/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-generic-query",
-              "version": "v12",
-              "url": "/aai/v12/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-generic-query",
-              "version": "v13",
-              "url": "/aai/v13/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-generic-query",
-              "version": "v14",
-              "url": "/aai/v14/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-generic-query",
-              "version": "v15",
-              "url": "/aai/v15/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-generic-query",
-              "version": "v16",
-              "url": "/aai/v16/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-generic-query",
-              "version": "v17",
-              "url": "/aai/v17/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-generic-query",
-              "version": "v18",
-              "url": "/aai/v18/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-generic-query",
-              "version": "v19",
-              "url": "/aai/v19/search/generic-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-nodes-query",
-              "version": "v11",
-              "url": "/aai/v11/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-nodes-query",
-              "version": "v12",
-              "url": "/aai/v12/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-nodes-query",
-              "version": "v13",
-              "url": "/aai/v13/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-nodes-query",
-              "version": "v14",
-              "url": "/aai/v14/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-nodes-query",
-              "version": "v15",
-              "url": "/aai/v15/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-nodes-query",
-              "version": "v16",
-              "url": "/aai/v16/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-nodes-query",
-              "version": "v17",
-              "url": "/aai/v17/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-nodes-query",
-              "version": "v18",
-              "url": "/aai/v18/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-nodes-query",
-              "version": "v19",
-              "url": "/aai/v19/search/nodes-query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-query",
-              "version": "v11",
-              "url": "/aai/v11/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-query",
-              "version": "v12",
-              "url": "/aai/v12/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-query",
-              "version": "v13",
-              "url": "/aai/v13/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-query",
-              "version": "v14",
-              "url": "/aai/v14/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-query",
-              "version": "v15",
-              "url": "/aai/v15/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-query",
-              "version": "v16",
-              "url": "/aai/v16/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-query",
-              "version": "v17",
-              "url": "/aai/v17/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-query",
-              "version": "v18",
-              "url": "/aai/v18/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
-              "serviceName": "aai-query",
-              "version": "v19",
-              "url": "/aai/v19/query",
-              "protocol": "REST",
-              "port": "8446",
-              "enable_ssl": true,
-              "lb_policy":"ip_hash",
-              "visualRange": "1"
-          },
-          {
               "serviceName": "aai-named-query",
               "url": "/aai/search",
               "protocol": "REST",
@@ -627,6 +88,7 @@
               "visualRange": "1"
           }
           ]'
+      {{- end }}
     spec:
       hostname: aai-traversal
     {{ if .Values.global.initContainers.enabled }}
@@ -653,7 +115,7 @@
         {{- end }}
         - --container-name
         - aai-schema-service
-      {{  end  }}
+      {{ end }}
         env:
         - name: NAMESPACE
           valueFrom: