From 65ebba8b1d2562007ea8e210ec026ca191348e1a Mon Sep 17 00:00:00 2001
From: Jeffrey Zhang <zhang.lei.fly@gmail.com>
Date: Mon, 17 Jul 2017 10:02:28 +0800
Subject: [PATCH] Fix wsgi file path and log-file parameter

* use gnocchi-api script for wsgi based on this commit[0].
* logfile is deprecated. Use log-file instead[1].

[0] https://github.com/gnocchixyz/gnocchi/commit/c8717e8b71f044953aec744f44f97abad1a0c08e
[1] https://github.com/gnocchixyz/gnocchi/blob/master/gnocchi/opts.py#L77,L82

Change-Id: I8fbe8425e43d82e0f9601ba6303dd7f24142a2e6
---
 ansible/roles/gnocchi/templates/gnocchi-metricd.json.j2 | 2 +-
 ansible/roles/gnocchi/templates/gnocchi-statsd.json.j2  | 2 +-
 ansible/roles/gnocchi/templates/wsgi-gnocchi.conf.j2    | 5 +++--
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/ansible/roles/gnocchi/templates/gnocchi-metricd.json.j2 b/ansible/roles/gnocchi/templates/gnocchi-metricd.json.j2
index 25e63ac232..2285095816 100644
--- a/ansible/roles/gnocchi/templates/gnocchi-metricd.json.j2
+++ b/ansible/roles/gnocchi/templates/gnocchi-metricd.json.j2
@@ -1,5 +1,5 @@
 {
-    "command": "gnocchi-metricd --logfile /var/log/kolla/gnocchi/gnocchi-metricd.log",
+    "command": "gnocchi-metricd --log-file /var/log/kolla/gnocchi/gnocchi-metricd.log",
     "config_files": [
         {
             "source": "{{ container_config_directory }}/gnocchi.conf",
diff --git a/ansible/roles/gnocchi/templates/gnocchi-statsd.json.j2 b/ansible/roles/gnocchi/templates/gnocchi-statsd.json.j2
index 0fad3b6e14..8613c343db 100644
--- a/ansible/roles/gnocchi/templates/gnocchi-statsd.json.j2
+++ b/ansible/roles/gnocchi/templates/gnocchi-statsd.json.j2
@@ -1,5 +1,5 @@
 {
-    "command": "gnocchi-statsd --logfile /var/log/kolla/gnocchi/gnocchi-statsd.log",
+    "command": "gnocchi-statsd --log-file /var/log/kolla/gnocchi/gnocchi-statsd.log",
     "config_files": [
         {
             "source": "{{ container_config_directory }}/gnocchi.conf",
diff --git a/ansible/roles/gnocchi/templates/wsgi-gnocchi.conf.j2 b/ansible/roles/gnocchi/templates/wsgi-gnocchi.conf.j2
index 59ae05c7f3..3ba0c2ddfd 100644
--- a/ansible/roles/gnocchi/templates/wsgi-gnocchi.conf.j2
+++ b/ansible/roles/gnocchi/templates/wsgi-gnocchi.conf.j2
@@ -1,4 +1,5 @@
 {% set python_path = '/usr/lib/python2.7/site-packages' if kolla_install_type == 'binary' else '/var/lib/kolla/venv/lib/python2.7/site-packages' %}
+{% set wsgi_path = '/usr/bin' if kolla_install_type == 'binary' else '/var/lib/kolla/venv/bin' %}
 Listen {{ api_interface_address }}:{{ gnocchi_api_port }}
 
 <VirtualHost *:{{ gnocchi_api_port }}>
@@ -8,9 +9,9 @@ Listen {{ api_interface_address }}:{{ gnocchi_api_port }}
   WSGIApplicationGroup %{GLOBAL}
   WSGIDaemonProcess gnocchi group=gnocchi processes={{ openstack_service_workers }} threads=1 user=gnocchi python-path={{ python_path }}
   WSGIProcessGroup gnocchi
-  WSGIScriptAlias / "{{ python_path }}/gnocchi/rest/app.wsgi"
+  WSGIScriptAlias / "{{ wsgi_path }}/gnocchi-api"
 
-  <Directory "{{ python_path }}/gnocchi/rest">
+  <Directory "{{ wsgi_path }}">
         Require all granted
   </Directory>