Route mysql connections to dbs02-03

PROD-36526

Change-Id: I5cbcf78c4d3858a7e8285afe13c651e1a03cafcc
diff --git a/defaults/openstack/init.yml b/defaults/openstack/init.yml
index 7370257..6767bde 100644
--- a/defaults/openstack/init.yml
+++ b/defaults/openstack/init.yml
@@ -54,6 +54,7 @@
     cinder_image_conversion_dir_path: /var/tmp/cinder/conversion
     # Nova
     mysql_nova_username: nova
+    mysql_nova_port: 3307
     keystone_nova_username: nova
     nova_memcache_security_enabled: ${_param:openstack_memcache_security_enabled}
     nova_memcache_secret_key: ''
@@ -183,6 +184,7 @@
     keystone_murano_username: murano
     # Neutron
     mysql_neutron_username: neutron
+    mysql_neutron_port: 3308
     keystone_neutron_username: neutron
     neutron_old_version: ${_param:openstack_old_version}
     neutron_version: ${_param:openstack_version}
@@ -261,6 +263,8 @@
     keystone_tacker_username: tacker
     # HAproxy
     haproxy_openstack_web_bind_port: ${_param:horizon_public_port}
+    haproxy_neutron_db_proxy_enabled: True
+    haproxy_nova_db_proxy_enabled: True
     #
     # haproxy_openstack_web_sticks_params is defined for SSL by default
     # if cluster_protocolr HTTP is going to be used then haproxy_openstack_web_sticks_params
diff --git a/haproxy/proxy/listen/openstack/galera/init.yml b/haproxy/proxy/listen/openstack/galera/init.yml
index de937bc..1d7285a 100644
--- a/haproxy/proxy/listen/openstack/galera/init.yml
+++ b/haproxy/proxy/listen/openstack/galera/init.yml
@@ -1,3 +1,6 @@
+classes:
+- system.haproxy.proxy.listen.openstack.galera.mysql_nova_proxy
+- system.haproxy.proxy.listen.openstack.galera.mysql_neutron_proxy
 parameters:
   _param:
     haproxy_params_check: 'check port 9200'
diff --git a/haproxy/proxy/listen/openstack/galera/mysql_neutron_proxy.yml b/haproxy/proxy/listen/openstack/galera/mysql_neutron_proxy.yml
new file mode 100644
index 0000000..6c7b9c2
--- /dev/null
+++ b/haproxy/proxy/listen/openstack/galera/mysql_neutron_proxy.yml
@@ -0,0 +1,34 @@
+parameters:
+  _param:
+    haproxy_params_check: 'check port 9200'
+  haproxy:
+    proxy:
+      timeout:
+        server: 28810s
+        client: 28810s
+      listen:
+        mysql_cluster_neutron_conn:
+          enabled: ${_param:haproxy_neutron_db_proxy_enabled}
+          type: mysql
+          service_name: mysql
+          balance: first
+          binds:
+          - address: ${_param:cluster_vip_address}
+            port: ${_param:mysql_neutron_port}
+          servers:
+          - name: ${_param:cluster_node03_hostname}
+            host: ${_param:cluster_node03_address}
+            port: 3306
+            params: ${_param:haproxy_params_check} inter 20s fastinter 2s downinter 2s rise 3 fall 3 on-marked-down shutdown-sessions
+          - name: ${_param:cluster_node01_hostname}
+            host: ${_param:cluster_node01_address}
+            port: 3306
+            params: backup ${_param:haproxy_params_check} inter 20s fastinter 2s downinter 2s rise 3 fall 3 on-marked-down shutdown-sessions
+          - name: ${_param:cluster_node02_hostname}
+            host: ${_param:cluster_node02_address}
+            port: 3306
+            params: backup ${_param:haproxy_params_check} inter 20s fastinter 2s downinter 2s rise 3 fall 3 on-marked-down shutdown-sessions
+          health-check:
+            mysql:
+              enabled: False
+
diff --git a/haproxy/proxy/listen/openstack/galera/mysql_nova_proxy.yml b/haproxy/proxy/listen/openstack/galera/mysql_nova_proxy.yml
new file mode 100644
index 0000000..8bc138f
--- /dev/null
+++ b/haproxy/proxy/listen/openstack/galera/mysql_nova_proxy.yml
@@ -0,0 +1,34 @@
+parameters:
+  _param:
+    haproxy_params_check: 'check port 9200'
+  haproxy:
+    proxy:
+      timeout:
+        server: 28810s
+        client: 28810s
+      listen:
+        mysql_cluster_nova_conn:
+          enabled: ${_param:haproxy_nova_db_proxy_enabled}
+          type: mysql
+          service_name: mysql
+          balance: first
+          binds:
+          - address: ${_param:cluster_vip_address}
+            port: ${_param:mysql_nova_port}
+          servers:
+          - name: ${_param:cluster_node02_hostname}
+            host: ${_param:cluster_node02_address}
+            port: 3306
+            params: ${_param:haproxy_params_check} inter 20s fastinter 2s downinter 2s rise 3 fall 3 on-marked-down shutdown-sessions
+          - name: ${_param:cluster_node01_hostname}
+            host: ${_param:cluster_node01_address}
+            port: 3306
+            params: backup ${_param:haproxy_params_check} inter 20s fastinter 2s downinter 2s rise 3 fall 3 on-marked-down shutdown-sessions
+          - name: ${_param:cluster_node03_hostname}
+            host: ${_param:cluster_node03_address}
+            port: 3306
+            params: backup ${_param:haproxy_params_check} inter 20s fastinter 2s downinter 2s rise 3 fall 3 on-marked-down shutdown-sessions
+          health-check:
+            mysql:
+              enabled: False
+
diff --git a/neutron/control/cluster.yml b/neutron/control/cluster.yml
index fe6f464..e9b7ea9 100644
--- a/neutron/control/cluster.yml
+++ b/neutron/control/cluster.yml
@@ -34,6 +34,7 @@
       database:
         user: ${_param:mysql_neutron_username}
         password: ${_param:mysql_neutron_password}
+        port: ${_param:mysql_neutron_port}
         x509:
           enabled: ${_param:openstack_mysql_x509_enabled}
           ca_file: ${_param:mysql_neutron_ssl_ca_file}
diff --git a/nova/compute/cluster.yml b/nova/compute/cluster.yml
index 8a7b362..d6b0251 100644
--- a/nova/compute/cluster.yml
+++ b/nova/compute/cluster.yml
@@ -30,7 +30,7 @@
       database:
         engine: mysql
         host: ${_param:openstack_database_address}
-        port: 3306
+        port: ${_param:mysql_nova_port}
         name: nova
         user: ${_param:mysql_nova_username}
         password: ${_param:mysql_nova_password}
diff --git a/nova/control/cluster.yml b/nova/control/cluster.yml
index 359d0d6..30d759f 100644
--- a/nova/control/cluster.yml
+++ b/nova/control/cluster.yml
@@ -42,7 +42,7 @@
       database:
         engine: mysql
         host: ${_param:openstack_database_address}
-        port: 3306
+        port: ${_param:mysql_nova_port}
         name: nova
         user: ${_param:mysql_nova_username}
         password: ${_param:mysql_nova_password}