[MARIADB][SO] Connect MariaDB Galera via master node

To avoid "lock" situations all clients of the mariadb-galera
cluster should use the "primary" service, which connects
to the master node.
This service is provided by the mariadb-operator.
Additionally for SO the bugfix for "local" DB configuration
is fixed.
Additionally missing readiness checks added to so-cnfm-lcm and
so-etsi-nfvo-ns-lcm to wait for the DB job to complete

Issue-ID: OOM-3261
Issue-ID: OOM-2697

Change-Id: I3d44f8b6d84d112c0271bfccebc4fa533c4e6aff
Signed-off-by: Andreas Geissler <andreas-geissler@telekom.de>
diff --git a/kubernetes/common/common/templates/_mariadb.tpl b/kubernetes/common/common/templates/_mariadb.tpl
index 7492f71..a2d4117 100644
--- a/kubernetes/common/common/templates/_mariadb.tpl
+++ b/kubernetes/common/common/templates/_mariadb.tpl
@@ -74,14 +74,14 @@
 */}}
 {{- define "common.mariadbService" -}}
   {{- if .Values.global.mariadbGalera.localCluster -}}
-  {{-   if .Values.global.mariadbGalera.useOperator }}
+  {{-   if and .Values.global.mariadbGalera.useOperator  (index .Values "mariadb-galera" "mariadbOperator" "galera" "enabled") }}
     {{- printf "%s-primary" (index .Values "mariadb-galera" "nameOverride") -}}
   {{-   else }}
     {{- index .Values "mariadb-galera" "nameOverride" -}}
   {{-   end }}
   {{- else -}}
-  {{-   if .Values.global.mariadbGalera.useOperator }}
-    {{- printf "%s-primary" (.Values.global.mariadbGalera.service) -}}
+  {{-   if and .Values.global.mariadbGalera.useOperator }}
+    {{- printf "%s-primary" (.Values.global.mariadbGalera.service) }}
   {{-   else }}
     {{- .Values.global.mariadbGalera.service -}}
   {{-   end }}
diff --git a/kubernetes/common/network-name-gen/values.yaml b/kubernetes/common/network-name-gen/values.yaml
index 2ab9b93..e028e39 100644
--- a/kubernetes/common/network-name-gen/values.yaml
+++ b/kubernetes/common/network-name-gen/values.yaml
@@ -25,6 +25,8 @@
   pullPolicy: IfNotPresent
 
   mariadbGalera: &mariadbGalera
+    # flag to enable the DB creation via mariadb-operator
+    useOperator: true
     #This flag allows SO to instantiate its own mariadb-galera cluster
     #When changing it to "true", also set "globalCluster: false"
     #as the dependency check will not work otherwise (Chart.yaml)