Enable multiworker setup of contrail-api
PROD-18175
Change-Id: I7188b775c004b3354d032de70eccbce11742b6ba
diff --git a/README.rst b/README.rst
index b308fe2..825b1c0 100644
--- a/README.rst
+++ b/README.rst
@@ -880,6 +880,17 @@
pci: 0000:81:00.1
...
+Increase number of contrail-api workers
+---------------------------------------
+
+.. code-block:: yaml
+
+ opencontrail:
+ ...
+ config:
+ api_workers: 3
+ ...
+
Increase number of alarm-gen workers
------------------------------------
diff --git a/opencontrail/config.sls b/opencontrail/config.sls
index 50e4901..09846e8 100644
--- a/opencontrail/config.sls
+++ b/opencontrail/config.sls
@@ -114,8 +114,11 @@
/etc/contrail/supervisord_config_files/contrail-api.ini:
file.managed:
- - source: salt://opencontrail/files/{{ config.version }}/config/contrail-api.ini
+ - source: salt://opencontrail/files/{{ config.version }}/contrail-api.ini
+ - template: jinja
- makedirs: true
+ - watch_in:
+ - service: opencontrail_config_services
/etc/init.d/contrail-api:
file.managed:
diff --git a/opencontrail/files/2.2/config/contrail-api.ini b/opencontrail/files/2.2/contrail-api.ini
similarity index 86%
rename from opencontrail/files/2.2/config/contrail-api.ini
rename to opencontrail/files/2.2/contrail-api.ini
index 673529c..fd05496 100644
--- a/opencontrail/files/2.2/config/contrail-api.ini
+++ b/opencontrail/files/2.2/contrail-api.ini
@@ -1,4 +1,4 @@
-
+{%- from "opencontrail/map.jinja" import config with context -%}
[program:contrail-api]
command=/usr/bin/contrail-api --conf_file /etc/contrail/contrail-api.conf --conf_file /etc/contrail/contrail-keystone-auth.conf --worker_id %(process_num)s
numprocs=1
diff --git a/opencontrail/files/3.0/config/contrail-api.ini b/opencontrail/files/3.0/config/contrail-api.ini
deleted file mode 100644
index 673529c..0000000
--- a/opencontrail/files/3.0/config/contrail-api.ini
+++ /dev/null
@@ -1,14 +0,0 @@
-
-[program:contrail-api]
-command=/usr/bin/contrail-api --conf_file /etc/contrail/contrail-api.conf --conf_file /etc/contrail/contrail-keystone-auth.conf --worker_id %(process_num)s
-numprocs=1
-process_name=%(process_num)s
-redirect_stderr=true
-stdout_logfile= /var/log/contrail/contrail-api-%(process_num)s-stdout.log
-stderr_logfile=/dev/null
-priority=440
-autostart=true
-killasgroup=true
-stopsignal=KILL
-exitcodes=0
-
diff --git a/opencontrail/files/3.0/contrail-api.ini b/opencontrail/files/3.0/contrail-api.ini
new file mode 100644
index 0000000..4caaeb3
--- /dev/null
+++ b/opencontrail/files/3.0/contrail-api.ini
@@ -0,0 +1,19 @@
+{%- from "opencontrail/map.jinja" import config with context -%}
+[program:contrail-api]
+{%- if config.get('api_workers', 1) < 2 %}
+command=/usr/bin/contrail-api --conf_file /etc/contrail/contrail-api.conf --conf_file /etc/contrail/contrail-keystone-auth.conf --worker_id %(process_num)s
+numprocs=1
+{%- else %}
+command=/usr/bin/contrail-api --conf_file /etc/contrail/contrail-api.conf --conf_file /etc/contrail/contrail-keystone-auth.conf --worker_id %(process_num)s --listen_port 910%(process_num)s --admin_port 819%(process_num)s --http_server_port 828%(process_num)s --log_file /var/log/contrail/contrail-api-%(process_num)s.log
+numprocs={{ config.api_workers }}
+{%- endif %}
+process_name=%(process_num)s
+redirect_stderr=true
+stdout_logfile= /var/log/contrail/contrail-api-%(process_num)s-stdout.log
+stderr_logfile=/dev/null
+priority=440
+autostart=true
+killasgroup=true
+stopsignal=KILL
+exitcodes=0
+
diff --git a/opencontrail/files/4.0/config/contrail-api.ini b/opencontrail/files/4.0/config/contrail-api.ini
deleted file mode 100644
index 673529c..0000000
--- a/opencontrail/files/4.0/config/contrail-api.ini
+++ /dev/null
@@ -1,14 +0,0 @@
-
-[program:contrail-api]
-command=/usr/bin/contrail-api --conf_file /etc/contrail/contrail-api.conf --conf_file /etc/contrail/contrail-keystone-auth.conf --worker_id %(process_num)s
-numprocs=1
-process_name=%(process_num)s
-redirect_stderr=true
-stdout_logfile= /var/log/contrail/contrail-api-%(process_num)s-stdout.log
-stderr_logfile=/dev/null
-priority=440
-autostart=true
-killasgroup=true
-stopsignal=KILL
-exitcodes=0
-
diff --git a/opencontrail/files/4.0/contrail-api.ini b/opencontrail/files/4.0/contrail-api.ini
new file mode 100644
index 0000000..4caaeb3
--- /dev/null
+++ b/opencontrail/files/4.0/contrail-api.ini
@@ -0,0 +1,19 @@
+{%- from "opencontrail/map.jinja" import config with context -%}
+[program:contrail-api]
+{%- if config.get('api_workers', 1) < 2 %}
+command=/usr/bin/contrail-api --conf_file /etc/contrail/contrail-api.conf --conf_file /etc/contrail/contrail-keystone-auth.conf --worker_id %(process_num)s
+numprocs=1
+{%- else %}
+command=/usr/bin/contrail-api --conf_file /etc/contrail/contrail-api.conf --conf_file /etc/contrail/contrail-keystone-auth.conf --worker_id %(process_num)s --listen_port 910%(process_num)s --admin_port 819%(process_num)s --http_server_port 828%(process_num)s --log_file /var/log/contrail/contrail-api-%(process_num)s.log
+numprocs={{ config.api_workers }}
+{%- endif %}
+process_name=%(process_num)s
+redirect_stderr=true
+stdout_logfile= /var/log/contrail/contrail-api-%(process_num)s-stdout.log
+stderr_logfile=/dev/null
+priority=440
+autostart=true
+killasgroup=true
+stopsignal=KILL
+exitcodes=0
+
diff --git a/tests/pillar/control3.sls b/tests/pillar/control3.sls
index 2587f2a..7492795 100644
--- a/tests/pillar/control3.sls
+++ b/tests/pillar/control3.sls
@@ -17,6 +17,7 @@
multi_tenancy: false
aaa_mode: rbac
global_read_only_role: demo
+ api_workers: 3
network:
engine: neutron
host: 127.0.0.1