From 3168f541e79b5106d89c7e95b07fa213819a2b07 Mon Sep 17 00:00:00 2001
From: Sean Dague <sdague@linux.vnet.ibm.com>
Date: Mon, 14 Oct 2013 06:58:30 -0400
Subject: [PATCH] switch over to os-loganalyze on logs.o.o

this is the switch over for os-loganalyze on logs(-dev).o.o. It
direct deploys from git to the environment. It will bring with it
support for keystone, console logs, and being smarter about when
level filtering is applied.

While I would still like the have a tick / tock CD environment to
deploy to dev then to prod on a stable branch, there are enough
fixes in os-loganalyze over the old htmlify script that it's worth
deploying to master now, then work on CD next.

Change-Id: Iaa0c1993128032842b0d6ee496b0047fb65cb6a8
---
 modules/openstack_project/manifests/static.pp    | 16 ++++++++++++++++
 .../templates/logs-dev.vhost.erb                 |  5 +++--
 .../openstack_project/templates/logs.vhost.erb   |  5 +++--
 3 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/modules/openstack_project/manifests/static.pp b/modules/openstack_project/manifests/static.pp
index 95f6cc784a..8a3dc8eaf1 100644
--- a/modules/openstack_project/manifests/static.pp
+++ b/modules/openstack_project/manifests/static.pp
@@ -106,6 +106,22 @@ class openstack_project::static (
     require => File['/srv/static/logs'],
   }
 
+  vcsrepo { '/opt/os-loganalyze':
+    ensure   => latest,
+    provider => git,
+    revision => 'master',
+    source   => 'https://git.openstack.org/openstack-infra/os-loganalyze',
+  }
+
+  exec { 'install_os-loganalyze':
+    command     => 'python setup.py install',
+    cwd         => '/opt/os-loganalyze',
+    path        => '/bin:/usr/bin',
+    refreshonly => true,
+    subscribe   => Vcsrepo['/opt/os-loganalyze'],
+  }
+
+  # NOTE(sdague): soon to be deprecated
   file { '/usr/local/bin/htmlify-screen-log.py':
     ensure  => present,
     owner   => 'root',
diff --git a/modules/openstack_project/templates/logs-dev.vhost.erb b/modules/openstack_project/templates/logs-dev.vhost.erb
index 727f76e3c8..5fd8221dd0 100644
--- a/modules/openstack_project/templates/logs-dev.vhost.erb
+++ b/modules/openstack_project/templates/logs-dev.vhost.erb
@@ -58,9 +58,10 @@ NameVirtualHost <%= vhost_name %>:<%= port %>
   </Directory>
 
   RewriteEngine On
-  # rewrite all txt.gz files to map to our internal htmlify wsgi app
+  # rewrite all txt.gz & html.gz files to map to our internal htmlify wsgi app
   RewriteRule ^/(.*\.txt\.gz)$ /htmlify/$1 [QSA,L,PT]
-  WSGIScriptAlias /htmlify /usr/local/bin/htmlify-screen-log.py
+  RewriteRule ^/(.*\.html\.gz)$ /htmlify/$1 [QSA,L,PT]
+  WSGIScriptAlias /htmlify /usr/local/lib/python2.7/dist-packages/os_loganalyze/wsgi.py
 
   ErrorLog /var/log/apache2/<%= name %>_error.log
   LogLevel warn
diff --git a/modules/openstack_project/templates/logs.vhost.erb b/modules/openstack_project/templates/logs.vhost.erb
index 727f76e3c8..5fd8221dd0 100644
--- a/modules/openstack_project/templates/logs.vhost.erb
+++ b/modules/openstack_project/templates/logs.vhost.erb
@@ -58,9 +58,10 @@ NameVirtualHost <%= vhost_name %>:<%= port %>
   </Directory>
 
   RewriteEngine On
-  # rewrite all txt.gz files to map to our internal htmlify wsgi app
+  # rewrite all txt.gz & html.gz files to map to our internal htmlify wsgi app
   RewriteRule ^/(.*\.txt\.gz)$ /htmlify/$1 [QSA,L,PT]
-  WSGIScriptAlias /htmlify /usr/local/bin/htmlify-screen-log.py
+  RewriteRule ^/(.*\.html\.gz)$ /htmlify/$1 [QSA,L,PT]
+  WSGIScriptAlias /htmlify /usr/local/lib/python2.7/dist-packages/os_loganalyze/wsgi.py
 
   ErrorLog /var/log/apache2/<%= name %>_error.log
   LogLevel warn