From 7af0ab9ba968da830ce04614558d7bd6880cbb89 Mon Sep 17 00:00:00 2001
From: Vikram Hosakote <vhosakot@cisco.com>
Date: Tue, 22 Mar 2016 02:00:50 +0000
Subject: [PATCH] Make heka collect libvirtd.log in nova_libvirt container

Test results of this patch set are at:
http://paste.openstack.org/show/491382/

Change-Id: I1bc8bdb3180f30dc69af28a35fa057ac801bde0f
Closes-Bug: #1560298
---
 ansible/roles/common/templates/heka-openstack.toml.j2 | 2 +-
 ansible/roles/nova/tasks/start_compute.yml            | 1 +
 ansible/roles/nova/templates/libvirtd.conf.j2         | 2 +-
 docker/nova/nova-libvirt/extend_start.sh              | 7 +++++++
 4 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/ansible/roles/common/templates/heka-openstack.toml.j2 b/ansible/roles/common/templates/heka-openstack.toml.j2
index 9cf3782db..9950edbce 100644
--- a/ansible/roles/common/templates/heka-openstack.toml.j2
+++ b/ansible/roles/common/templates/heka-openstack.toml.j2
@@ -6,6 +6,6 @@ filename = "lua_decoders/os_openstack_log.lua"
 type = "LogstreamerInput"
 decoder = "openstack_log_decoder"
 log_directory = "/var/log/kolla"
-file_match = '(?P<Service>nova|glance|keystone|neutron|cinder|heat|murano|magnum|mistral|manila)/(?P<Program>.*)\.log\.?(?P<Seq>\d*)$'
+file_match = '(?P<Service>nova|glance|keystone|neutron|cinder|heat|murano|magnum|mistral|manila|libvirtd)/(?P<Program>.*)\.log\.?(?P<Seq>\d*)$'
 priority = ["^Seq"]
 differentiator = ["Service", "_", "Program"]
diff --git a/ansible/roles/nova/tasks/start_compute.yml b/ansible/roles/nova/tasks/start_compute.yml
index f88e3aa91..1540f4673 100644
--- a/ansible/roles/nova/tasks/start_compute.yml
+++ b/ansible/roles/nova/tasks/start_compute.yml
@@ -12,6 +12,7 @@
       - "/lib/modules:/lib/modules:ro"
       - "/run/:/run/"
       - "/sys/fs/cgroup:/sys/fs/cgroup"
+      - "kolla_logs:/var/log/kolla/"
       - "libvirtd:/var/lib/libvirt"
       - "nova_compute:/var/lib/nova/"
   when: inventory_hostname in groups['compute']
diff --git a/ansible/roles/nova/templates/libvirtd.conf.j2 b/ansible/roles/nova/templates/libvirtd.conf.j2
index 9b43fc710..de891b8d2 100644
--- a/ansible/roles/nova/templates/libvirtd.conf.j2
+++ b/ansible/roles/nova/templates/libvirtd.conf.j2
@@ -2,5 +2,5 @@ listen_tcp = 1
 auth_tcp = "none"
 ca_file = ""
 log_level = 3
-log_outputs = "3:file:/var/log/libvirt/libvirtd.log"
+log_outputs = "3:file:/var/log/kolla/libvirt/libvirtd.log"
 listen_addr = "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}"
diff --git a/docker/nova/nova-libvirt/extend_start.sh b/docker/nova/nova-libvirt/extend_start.sh
index 20873d8b4..d0cdd4d1c 100644
--- a/docker/nova/nova-libvirt/extend_start.sh
+++ b/docker/nova/nova-libvirt/extend_start.sh
@@ -12,3 +12,10 @@ fi
 if [[ $(lsmod | grep xenfs) ]]; then
     mount -t xenfs xenfs /proc/xen
 fi
+
+if [[ ! -d "/var/log/kolla/libvirt" ]]; then
+    mkdir -p /var/log/kolla/libvirt
+fi
+if [[ $(stat -c %a /var/log/kolla/libvirt) != "755" ]]; then
+    chmod 755 /var/log/kolla/libvirt
+fi
-- 
GitLab