Merge "Added parameter for horizon package"
diff --git a/README.rst b/README.rst
index 27511bd..a486264 100644
--- a/README.rst
+++ b/README.rst
@@ -11,25 +11,14 @@
 Packaged version of horizon
 ---------------------------
 
-One horizon on server
-
-Simplest horizon setup with managed cloud-archive repo on ubuntu 12.04
+Simplest horizon setup
 
 .. code-block:: yaml
 
-    linux:
-      system:
-        name: horizon
-        repo:
-         - cloudarchive-havana:
-            enabled: true
-            source: 'deb http://ubuntu-cloud.archive.canonical.com/ubuntu precise-updates/havana main'
-            pgpcheck: 0
     horizon:
       server:
-        manage_repo: true
         enabled: true
-        secret_key: MEGASECRET
+        secret_key: secret
         host:
           name: cloud.lab.cz
         cache:
@@ -121,21 +110,13 @@
         sensu_api:
           host: localhost
           port: 4567
-        plugins:
-        - name: monitoring
-          app: horizon_monitoring
-          source:
-            type: git
-            address: git@repo1.robotice.cz:django/horizon-monitoring.git
-            rev: develop
-        - name: api-mask
-          app: api_mask
-          mask_url: 'custom-url.cz'
-          mask_protocol: 'http'
-          source:
-            type: git
-            address: git@repo1.robotice.cz:django/horizon-api-mask.git
-            rev: develop
+        plugin:
+          monitoring:
+            app: horizon_monitoring
+            source:
+              type: git
+              address: git@repo1.robotice.cz:django/horizon-monitoring.git
+              rev: develop
 
 Sensu multi API
 
@@ -153,6 +134,24 @@
             host: anotherhost
             port: 4567
 
+Horizon setup with jenkins plugin
+
+.. code-block:: yaml
+
+    horizon:
+      server:
+        enabled: true
+        version: juno
+        jenkins_api:
+          url: https://localhost:8080
+          user: admin
+          password: pwd
+        plugin:
+          jenkins:
+            app: horizon_jenkins
+            source:
+              type: pkg
+
 Horizon setup with billometer plugin
 
 .. code-block:: yaml
@@ -165,13 +164,13 @@
           host: localhost
           port: 9753
           api_version: 1
-        plugins:
-        - name: billing
-          app: horizon_billing
-          source:
-            type: git
-            address: git@repo1.robotice.cz:django/horizon-billing.git
-            rev: develop
+        plugin:
+          billing:
+            app: horizon_billing
+            source:
+              type: git
+              address: git@repo1.robotice.cz:django/horizon-billing.git
+              rev: develop
 
 Horizon setup with contrail plugin
 
@@ -181,14 +180,14 @@
       server:
         enabled: true
         version: icehouse
-        plugins:
-        - name: contrail
-          app: contrail_openstack_dashboard
-          override: true
-          source:
-            type: git
-            address: git@repo1.robotice.cz:django/horizon-contrail.git
-            rev: develop
+        plugin:
+          contrail:
+            app: contrail_openstack_dashboard
+            override: true
+            source:
+              type: git
+              address: git@repo1.robotice.cz:django/horizon-contrail.git
+              rev: develop
 
 Horizon setup with sentry log handler
 
@@ -338,7 +337,7 @@
         enabled: true
         app:
           openstack_dashboard_overrride:
-            secret_key: MEGASECRET1
+            secret_key: password
             dashboards:
               settings:
                 enabled: true
@@ -358,12 +357,3 @@
 
 * https://github.com/openstack/horizon
 * http://dijks.wordpress.com/2012/07/06/how-to-change-screen-resolution-of-novnc-client-in-openstack-essex-dashboard-nova-horizon/
-
-
-Things to improve
-=================
-
-* ALLOWED_HOSTS - do not use * - introduce parameters
-* CACHES - configure caching engine - is it not allowed by default?
-* SESSION_ENGINE - change it from signed cookie to something else
-* policy files - look into these files and think of further configuration/parametrisation
diff --git a/horizon/files/horizon_settings/_local_settings.py b/horizon/files/horizon_settings/_local_settings.py
index 8148ddc..00df73e 100644
--- a/horizon/files/horizon_settings/_local_settings.py
+++ b/horizon/files/horizon_settings/_local_settings.py
@@ -76,6 +76,12 @@
 OPENSTACK_CONTROL_NODES = {{ app.control_nodes|python }}
 {%- endif %}
 
+{%- if app.jenkins_api is defined %}
+HORIZON_JENKINS_URL = "{{ app.jenkins_api.url }}"
+HORIZON_JENKINS_USERNAME = "{{ app.jenkins_api.user }}"
+HORIZON_JENKINS_PASSWORD = "{{ app.jenkins_api.password }}"
+{%- endif %}
+
 {%- if app.sensu_api is defined %}
 {%- if app.sensu_api.host is defined %}
 SENSU_HOST = '{{ app.sensu_api.host }}'
diff --git a/horizon/files/openstack-dashboard.conf.Debian b/horizon/files/openstack-dashboard.conf.Debian
index 40942a2..f903c08 100644
--- a/horizon/files/openstack-dashboard.conf.Debian
+++ b/horizon/files/openstack-dashboard.conf.Debian
@@ -1,27 +1,36 @@
 {%- from "horizon/map.jinja" import server with context %}
 
-WSGIScriptAlias / /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
-WSGIDaemonProcess horizon user=horizon group=horizon processes={{ server.wsgi.processes }} threads={{ server.wsgi.threads }}
-WSGIProcessGroup horizon
+<VirtualHost {{ server.get('bind', {}).get('address', '0.0.0.0') }}:{{ server.get('bind', {}).get('port', 80) }}>
+  ServerName {{ server.get('host', {}).get('name', 'openstack-dashboard') }}
 
-Alias /static /usr/share/openstack-dashboard/static
+  WSGIScriptAlias / /usr/share/openstack-dashboard/openstack_dashboard/wsgi/django.wsgi
+  WSGIDaemonProcess horizon user=horizon group=horizon processes={{ server.wsgi.processes }} threads={{ server.wsgi.threads }}
+  WSGIProcessGroup horizon
 
-<Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
-  Order allow,deny
-  Allow from all
-</Directory>
+  Alias /static /usr/share/openstack-dashboard/static
 
-<Directory /usr/share/openstack-dashboard/static>
-  <IfModule mod_expires.c>
-    ExpiresActive On
-    ExpiresDefault "access 6 month"
-  </IfModule>
-  <IfModule mod_deflate.c>
-    SetOutputFilter DEFLATE
-  </IfModule>
+  <Directory /usr/share/openstack-dashboard/openstack_dashboard/wsgi>
+    Order allow,deny
+    Allow from all
+  </Directory>
 
-  Require all granted
-</Directory>
+  <Directory /usr/share/openstack-dashboard/static>
+    <IfModule mod_expires.c>
+      ExpiresActive On
+      ExpiresDefault "access 6 month"
+    </IfModule>
+    <IfModule mod_deflate.c>
+      SetOutputFilter DEFLATE
+    </IfModule>
+
+    Require all granted
+  </Directory>
+  ServerSignature Off
+  LogFormat "{{ server.apache_log_format }}" horizon
+  ErrorLog "{{ server.apache_log_dir }}/{{ server.apache_log_filename }}_error.log"
+  CustomLog "{{ server.apache_log_dir }}/{{ server.apache_log_filename }}_access.log" horizon
+
+</VirtualHost>
 
 {% if server.get('ssl', {}).get('enabled', False) %}
 
@@ -51,6 +60,11 @@
     Order allow,deny
     Allow from all
   </Directory>
+
+  ServerSignature Off
+  LogFormat "{{ server.apache_log_format }}" horizon
+  ErrorLog "{{ server.apache_log_dir }}/{{ server.apache_log_filename }}_error_ssl.log"
+  CustomLog "{{ server.apache_log_dir }}/{{ server.apache_log_filename }}_access_ssl.log" horizon
 </VirtualHost>
 
-{% endif %}
\ No newline at end of file
+{% endif %}
diff --git a/horizon/map.jinja b/horizon/map.jinja
index 1a67d3f..a3a8fe6 100644
--- a/horizon/map.jinja
+++ b/horizon/map.jinja
@@ -11,6 +11,9 @@
         'service': 'apache2',
         'config': '/etc/openstack-dashboard/local_settings.py',
         'apache_config': '/etc/apache2/conf-available/openstack-dashboard.conf',
+        'apache_log_dir': '/var/log/apache2',
+        'apache_log_filename': 'openstack_dashboard',
+        'apache_log_format': '%h %t %m \\"%U%q\\" %H %>s %O %D \\"%{Referer}i\\" \\"%{User-Agent}i\\"',
         'certs_dir': '/etc/ssl/certs',
         'private_dir': '/etc/ssl/private',
         'port_config_file': '/etc/apache2/ports.conf',
@@ -27,6 +30,9 @@
         'service': 'httpd',
         'config': '/etc/openstack-dashboard/local_settings',
         'apache_config': '/etc/httpd/conf.d/openstack-dashboard.conf',
+        'apache_log_dir': '/var/log/httpd',
+        'apache_log_filename': 'openstack_dashboard',
+        'apache_log_format': '%h %t %m \\"%U%q\\" %H %>s %O %D \\"%{Referer}i\\" \\"%{User-Agent}i\\"',
         'certs_dir': '/etc/pki/tls/certs',
         'private_dir': '/etc/pki/tls/private',
         'port_config_file': '/etc/httpd/conf/httpd.conf',
diff --git a/horizon/meta/heka.yml b/horizon/meta/heka.yml
new file mode 100644
index 0000000..100488f
--- /dev/null
+++ b/horizon/meta/heka.yml
@@ -0,0 +1,22 @@
+{%- from "horizon/map.jinja" import server with context %}
+log_collector:
+  decoder:
+    horizon_apache_access:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/lma_apache_access.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      adjust_timezone: true
+      config:
+        type: "log"
+        log_format: '{{ server.apache_log_format }}'
+        user_agent_transform: true
+        payload_keep: true
+  input:
+    horizon_apache_access:
+      engine: logstreamer
+      log_directory: "{{ server.apache_log_dir}}"
+      file_match: '{{ server.apache_log_filename }}_access(?P<Service>.*)\.log\.?(?P<Seq>\d*)'
+      differentiator: [ 'openstack.horizon', 'Service' ]
+      priority: ["^Seq"]
+      decoder: "horizon_apache_access_decoder"
+      splitter: "TokenSplitter"
diff --git a/horizon/server/service.sls b/horizon/server/service.sls
index 344a095..86f0c21 100644
--- a/horizon/server/service.sls
+++ b/horizon/server/service.sls
@@ -49,13 +49,16 @@
     - pkg: horizon_packages
 
 {%- if grains.os_family == 'Debian' %}
-/etc/apache2/conf-enabled/openstack-dashboard.conf:
-  file.symlink:
-    - target: /etc/apache2/conf-available/openstack-dashboard.conf
-
 apache_enable_wsgi:
   apache_module.enable:
     - name: wsgi
+
+enable_horizon_apache_config:
+  apache_conf.enable:
+  - name: openstack-dashboard
+  - require:
+    - file: horizon_apache_config
+    - apache_module: apache_enable_wsgi
 {%- endif %}
 
 horizon_services:
diff --git a/metadata/service/support.yml b/metadata/service/support.yml
index 2ebbaee..4f19089 100644
--- a/metadata/service/support.yml
+++ b/metadata/service/support.yml
@@ -4,7 +4,7 @@
       collectd:
         enabled: false
       heka:
-        enabled: false
+        enabled: true
       sensu:
         enabled: true
       sphinx: