Ability to set lock_path

PROD-34037

Change-Id: Iff1fde5e8cc9d4405ea03e8e5556568bedb89c50
diff --git a/README.rst b/README.rst
index 1392575..8cebe7e 100644
--- a/README.rst
+++ b/README.rst
@@ -28,6 +28,8 @@
         bind:
           host: 127.0.0.1
           port: 8777
+        concurrency:
+          lock_path: '/var/lib/ceilometer/tmp'
         identity:
           engine: keystone
           host: 127.0.0.1
@@ -181,6 +183,8 @@
         enabled: true
         version: mitaka
         secret: pwd
+        concurrency:
+          lock_path: '/var/lib/ceilometer/tmp'
         identity:
           engine: keystone
           host: 127.0.0.1
diff --git a/ceilometer/agent.sls b/ceilometer/agent.sls
index c17b3b1..d65a3c0 100644
--- a/ceilometer/agent.sls
+++ b/ceilometer/agent.sls
@@ -21,6 +21,20 @@
     - pkg: ceilometer_agent_packages
     - sls: ceilometer._ssl.rabbitmq
 
+{%- if agent.get('concurrency', {}).lock_path is defined %}
+ceilometer_agent_lock_path_{{ agent.concurrency.lock_path }}:
+  file.directory:
+  - name: {{ agent.concurrency.lock_path }}
+  - user: ceilometer
+  - group: ceilometer
+  - mode: 750
+  - makedirs: True
+  - require:
+    - pkg: ceilometer_agent_packages
+  - require_in:
+    - service: ceilometer_agent_services
+{%- endif %}
+
 {%- if agent.get('libvirt',{}).get('ssl',{}).get('enabled', False) == True %}
 add_ceilometer_to_nova_group:
   user.present:
diff --git a/ceilometer/files/pike/ceilometer-agent.conf.Debian b/ceilometer/files/pike/ceilometer-agent.conf.Debian
index 7746745..3d3e9ea 100644
--- a/ceilometer/files/pike/ceilometer-agent.conf.Debian
+++ b/ceilometer/files/pike/ceilometer-agent.conf.Debian
@@ -58,6 +58,22 @@
 
 topics = notifications
 
+[oslo_concurrency]
+
+#
+# From oslo.concurrency
+#
+
+# Enables or disables inter-process locks. (boolean value)
+#disable_process_locking = false
+
+# Directory to use for lock files.  For security, the specified directory
+# should only be writable by the user running the processes that need locking.
+# Defaults to environment variable OSLO_LOCK_PATH. If external locks are used,
+# a lock path must be set. (string value)
+#lock_path = <None>
+lock_path = {{ agent.get('concurrency', {}).get('lock_path', '/var/lib/ceilometer/tmp') }}
+
 [oslo_messaging_rabbit]
 
 {%- if agent.message_queue.get('ssl',{}).get('enabled', False) %}
diff --git a/ceilometer/files/pike/ceilometer-server.conf.Debian b/ceilometer/files/pike/ceilometer-server.conf.Debian
index 5a10a7b..71cc08b 100644
--- a/ceilometer/files/pike/ceilometer-server.conf.Debian
+++ b/ceilometer/files/pike/ceilometer-server.conf.Debian
@@ -187,6 +187,22 @@
 
 topics = notifications
 
+[oslo_concurrency]
+
+#
+# From oslo.concurrency
+#
+
+# Enables or disables inter-process locks. (boolean value)
+#disable_process_locking = false
+
+# Directory to use for lock files.  For security, the specified directory
+# should only be writable by the user running the processes that need locking.
+# Defaults to environment variable OSLO_LOCK_PATH. If external locks are used,
+# a lock path must be set. (string value)
+#lock_path = <None>
+lock_path = {{ server.get('concurrency', {}).get('lock_path', '/var/lib/ceilometer/tmp') }}
+
 [oslo_messaging_rabbit]
 
 {%- if server.message_queue.get('ssl',{}).get('enabled', False) %}
diff --git a/ceilometer/server.sls b/ceilometer/server.sls
index e264f8c..2ff9dd8 100644
--- a/ceilometer/server.sls
+++ b/ceilometer/server.sls
@@ -111,6 +111,20 @@
 
 {%- endif %}
 
+{%- if server.get('concurrency', {}).lock_path is defined %}
+ceilometer_server_lock_path_{{ server.concurrency.lock_path }}:
+  file.directory:
+  - name: {{ server.concurrency.lock_path }}
+  - user: ceilometer
+  - group: ceilometer
+  - mode: 750
+  - makedirs: True
+  - require:
+    - pkg: ceilometer_server_packages
+  - require_in:
+    - service: ceilometer_server_services
+{%- endif %}
+
 {%- if server.version not in ["juno", "kilo", "liberty", "mitaka", "newton", "ocata", "pike"] %}
 {#- Since Queens release `policy.json` is changed to `policy.yaml`. But default option in `oslo_policy` is `policy.json` #}
 /etc/ceilometer/{{ server.get('oslo_policy', {}).get('policy_file', 'policy.json') }}:
diff --git a/ceilometer/upgrade/render_config.sls b/ceilometer/upgrade/render_config.sls
index 88fe5a8..fd45ef2 100644
--- a/ceilometer/upgrade/render_config.sls
+++ b/ceilometer/upgrade/render_config.sls
@@ -5,7 +5,7 @@
     - text: "Running ceilometer.upgrade.render_config"
 
 {%- if server.enabled %}
-{%- set gnocchi_publisher = server.get('publisher', {}).get('gnocchi', {}) %}
+  {%- set gnocchi_publisher = server.get('publisher', {}).get('gnocchi', {}) %}
 
 ceilometer_server_conf:
   file.managed:
@@ -13,12 +13,22 @@
   - source: salt://ceilometer/files/{{ server.version }}/ceilometer-server.conf.{{ grains.os_family }}
   - template: jinja
 
-{%- if gnocchi_publisher.get('create_resources', False) and gnocchi_publisher.get('enabled', False) %}
+  {%- if server.get('concurrency', {}).lock_path is defined %}
+ceilometer_upgrade_server_lock_path_{{ server.concurrency.lock_path }}:
+  file.directory:
+  - name: {{ server.concurrency.lock_path }}
+  - user: ceilometer
+  - group: ceilometer
+  - mode: 750
+  - makedirs: True
+  {%- endif %}
+
+  {%- if gnocchi_publisher.get('create_resources', False) and gnocchi_publisher.get('enabled', False) %}
 ceilometer_server_gnocchi_resources:
   file.managed:
   - name: /etc/ceilometer/gnocchi_resources.yaml
   - source: salt://ceilometer/files/{{ server.version }}/gnocchi_resources.yaml
-{%- endif %}
+  {%- endif %}
 {%- endif %}
 
 {%- if agent.enabled %}
@@ -27,5 +37,15 @@
   - name: /etc/ceilometer/ceilometer.conf
   - source: salt://ceilometer/files/{{ agent.version }}/ceilometer-agent.conf.{{ grains.os_family }}
   - template: jinja
+
+  {%- if agent.get('concurrency', {}).lock_path is defined %}
+ceilometer_upgrade_agent_lock_path_{{ agent.concurrency.lock_path }}:
+  file.directory:
+  - name: {{ agent.concurrency.lock_path }}
+  - user: ceilometer
+  - group: ceilometer
+  - mode: 750
+  - makedirs: True
+  {%- endif %}
 {%- endif %}
 
diff --git a/metadata/service/agent/cluster/common.yml b/metadata/service/agent/cluster/common.yml
index 778dfbe..22b164f 100644
--- a/metadata/service/agent/cluster/common.yml
+++ b/metadata/service/agent/cluster/common.yml
@@ -13,6 +13,8 @@
       enabled: true
       version: ${_param:ceilometer_version}
       secret: ${_param:ceilometer_secret_key}
+      concurrency:
+        lock_path: '/var/lib/ceilometer/tmp'
       identity:
         engine: keystone
         host: ${_param:cluster_vip_address}
diff --git a/metadata/service/agent/single/common.yml b/metadata/service/agent/single/common.yml
index 34739ad..cddc192 100644
--- a/metadata/service/agent/single/common.yml
+++ b/metadata/service/agent/single/common.yml
@@ -13,6 +13,8 @@
       enabled: true
       version: ${_param:ceilometer_version}
       secret: ${_param:ceilometer_secret_key}
+      concurrency:
+        lock_path: '/var/lib/ceilometer/tmp'
       identity:
         engine: keystone
         host: ${_param:cluster_vip_address}
diff --git a/metadata/service/server/cluster/common.yml b/metadata/service/server/cluster/common.yml
index d8ffb2e..f5f698e 100644
--- a/metadata/service/server/cluster/common.yml
+++ b/metadata/service/server/cluster/common.yml
@@ -18,6 +18,8 @@
       bind:
         host: ${_param:cluster_local_address}
         port: 8777
+      concurrency:
+        lock_path: '/var/lib/ceilometer/tmp'
       identity:
         engine: keystone
         host: ${_param:cluster_vip_address}
diff --git a/metadata/service/server/single/common.yml b/metadata/service/server/single/common.yml
index bb60d05..6e04509 100644
--- a/metadata/service/server/single/common.yml
+++ b/metadata/service/server/single/common.yml
@@ -17,6 +17,8 @@
       bind:
         host: ${_param:single_address}
         port: 8777
+      concurrency:
+        lock_path: '/var/lib/ceilometer/tmp'
       identity:
         engine: keystone
         host: ${_param:single_address}