Merge "Formulas testing revision 2019/10"
diff --git a/octavia/api.sls b/octavia/api.sls
index d02a6cc..b259899 100644
--- a/octavia/api.sls
+++ b/octavia/api.sls
@@ -3,6 +3,9 @@
 {%- if api.enabled %}
 
 include:
+  {%- if pillar.get('apache', {}).get('server', {}).get('site', {}).octavia_api is defined %}
+  - apache
+  {%- endif %}
   - octavia.db.offline_sync
   - octavia._ssl.mysql
   - octavia._ssl.rabbitmq
@@ -42,8 +45,8 @@
     - pkg: octavia_api_packages
 {%- endif %}
 
-
 {%- if not grains.get('noservices', False) %}
+  {%- if pillar.get('apache', {}).get('server', {}).get('site', {}).octavia_api is not defined %}
 octavia_api_services:
   service.running:
   - names: {{ api.services }}
@@ -54,6 +57,42 @@
     - sls: octavia.db.offline_sync
     - sls: octavia._ssl.mysql
     - sls: octavia._ssl.rabbitmq
+  {%- else %}
+{# WA to point WSGI process on actual config file #}
+octavia_conf_symlink:
+  file.symlink:
+    - name: /etc/octavia/octavia.conf
+    - target: /etc/octavia/octavia_api.conf
+    - backupname: /etc/octavia/octavia.conf.backup
+    - force: true
+    - require:
+      - file: /etc/octavia/octavia_api.conf
+
+octavia_api_services:
+  service.dead:
+  - names: {{ api.services }}
+  - enable: false
+  - require:
+    - pkg: octavia_api_packages
+
+octavia_api_apache_conf_file:
+  file.exists:
+  - names:
+    - /etc/apache2/sites-available/wsgi_octavia_api.conf
+  - require:
+    - sls: apache.server.site
+    - pkg: octavia_api_packages
+
+apache_enable_octavia_api_wsgi:
+  apache_site.enabled:
+    - name: wsgi_octavia_api
+    - require:
+      - file: octavia_api_apache_conf_file
+      - service: octavia_api_services
+      - file: octavia_conf_symlink
+    - watch_in:
+      - service: apache_service
+  {%- endif %}
 {%- endif %}
 
 {%- endif %}