Merge "Add API Performances panels to Prometheus dashboard"
diff --git a/README.rst b/README.rst
index f7102e1..da98313 100644
--- a/README.rst
+++ b/README.rst
@@ -26,6 +26,7 @@
         cpu_allocation_ratio: 8.0
         ram_allocation_ratio: 1.0
         disk_allocation_ratio: 1.0
+        cross_az_attach: false
         workers: 8
         report_interval: 60
         bind:
@@ -157,6 +158,8 @@
         version: juno
         enabled: true
         virtualization: kvm
+        cross_az_attach: false
+        disk_cachemodes: network=writeback,block=none
         availability_zone: availability_zone_01
         aggregates:
         - hosts_with_fc
diff --git a/nova/files/juno/nova-compute.conf.Debian b/nova/files/juno/nova-compute.conf.Debian
index 37fce03..de61288 100644
--- a/nova/files/juno/nova-compute.conf.Debian
+++ b/nova/files/juno/nova-compute.conf.Debian
@@ -154,10 +154,13 @@
 
 [cinder]
 catalog_info=volumev2:cinderv2:internalURL
+{%- if compute.cross_az_attach is defined %}
+cross_az_attach={{ compute.cross_az_attach }}
+{%- endif %}
 
 {%- if compute.upgrade_levels is defined %}
 [upgrade_levels]
 {%- for key, value in compute.upgrade_levels.iteritems() %}
 {{ key }}={{ value }}
 {%- endfor %}
-{%- endif -%}
+{%- endif %}
diff --git a/nova/files/juno/nova-controller.conf.Debian b/nova/files/juno/nova-controller.conf.Debian
index d8eb174..7d4c04e 100644
--- a/nova/files/juno/nova-controller.conf.Debian
+++ b/nova/files/juno/nova-controller.conf.Debian
@@ -154,10 +154,13 @@
 
 [cinder]
 catalog_info=volumev2:cinderv2:internalURL
+{%- if controller.cross_az_attach is defined %}
+cross_az_attach={{ controller.cross_az_attach }}
+{%- endif %}
 
 {%- if controller.upgrade_levels is defined %}
 [upgrade_levels]
 {%- for key, value in controller.upgrade_levels.iteritems() %}
 {{ key }}={{ value }}
 {%- endfor %}
-{%- endif -%}
+{%- endif %}
diff --git a/nova/files/kilo/nova-compute.conf.Debian b/nova/files/kilo/nova-compute.conf.Debian
index f87f5ad..059ae78 100644
--- a/nova/files/kilo/nova-compute.conf.Debian
+++ b/nova/files/kilo/nova-compute.conf.Debian
@@ -183,6 +183,9 @@
 [cinder]
 os_region_name = {{ compute.identity.region }}
 catalog_info=volumev2:cinderv2:internalURL
+{%- if compute.cross_az_attach is defined %}
+cross_az_attach={{ compute.cross_az_attach }}
+{%- endif %}
 
 {%- if compute.get('ceph', {}).ephemeral is defined %}
 [libvirt]
@@ -201,4 +204,4 @@
 {%- for key, value in compute.upgrade_levels.iteritems() %}
 {{ key }}={{ value }}
 {%- endfor %}
-{%- endif -%}
+{%- endif %}
diff --git a/nova/files/kilo/nova-controller.conf.Debian b/nova/files/kilo/nova-controller.conf.Debian
index b57f1ed..228c358 100644
--- a/nova/files/kilo/nova-controller.conf.Debian
+++ b/nova/files/kilo/nova-controller.conf.Debian
@@ -210,10 +210,13 @@
 [cinder]
 os_region_name = {{ controller.identity.region }}
 catalog_info=volumev2:cinderv2:internalURL
+{%- if controller.cross_az_attach is defined %}
+cross_az_attach={{ controller.cross_az_attach }}
+{%- endif %}
 
 {%- if controller.upgrade_levels is defined %}
 [upgrade_levels]
 {%- for key, value in controller.upgrade_levels.iteritems() %}
 {{ key }}={{ value }}
 {%- endfor %}
-{%- endif -%}
+{%- endif %}
diff --git a/nova/files/liberty/nova-compute.conf.Debian b/nova/files/liberty/nova-compute.conf.Debian
index 3f2074c..90e56ee 100644
--- a/nova/files/liberty/nova-compute.conf.Debian
+++ b/nova/files/liberty/nova-compute.conf.Debian
@@ -198,10 +198,13 @@
 [cinder]
 os_region_name = {{ compute.identity.region }}
 catalog_info=volumev2:cinderv2:internalURL
+{%- if compute.cross_az_attach is defined %}
+cross_az_attach={{ compute.cross_az_attach }}
+{%- endif %}
 
 {%- if compute.get('ceph', {}).ephemeral is defined %}
 [libvirt]
-disk_cachemodes="network=writeback,block=none"
+disk_cachemodes="{{ compute.get('disk_cachemodes', 'network=writeback,block=none') }}"
 cpu_mode=host-passthrough
 virt_type=kvm
 live_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST
@@ -223,4 +226,4 @@
 {%- for key, value in compute.upgrade_levels.iteritems() %}
 {{ key }}={{ value }}
 {%- endfor %}
-{%- endif -%}
+{%- endif %}
diff --git a/nova/files/liberty/nova-controller.conf.Debian b/nova/files/liberty/nova-controller.conf.Debian
index 90764b8..4ceb955 100644
--- a/nova/files/liberty/nova-controller.conf.Debian
+++ b/nova/files/liberty/nova-controller.conf.Debian
@@ -221,6 +221,9 @@
 [cinder]
 os_region_name = {{ controller.identity.region }}
 catalog_info=volumev2:cinderv2:internalURL
+{%- if controller.cross_az_attach is defined %}
+cross_az_attach={{ controller.cross_az_attach }}
+{%- endif %}
 
 [vnc]
 keymap = {{ controller.get('vnc_keymap', 'en-us') }}
@@ -230,4 +233,4 @@
 {%- for key, value in controller.upgrade_levels.iteritems() %}
 {{ key }}={{ value }}
 {%- endfor %}
-{%- endif -%}
+{%- endif %}
diff --git a/nova/files/mitaka/nova-compute.conf.Debian b/nova/files/mitaka/nova-compute.conf.Debian
index 316ab71..e89a442 100644
--- a/nova/files/mitaka/nova-compute.conf.Debian
+++ b/nova/files/mitaka/nova-compute.conf.Debian
@@ -118,7 +118,7 @@
 virt_type = kvm
 inject_partition=-2
 inject_password=False
-disk_cachemodes="network=writeback,block=none"
+disk_cachemodes="{{ compute.get('disk_cachemodes', 'network=writeback,block=none') }}"
 libvirt_inject_password=True
 block_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_NON_SHARED_INC
 live_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST
@@ -195,6 +195,9 @@
 [cinder]
 os_region_name = {{ compute.identity.region }}
 catalog_info=volumev2:cinderv2:internalURL
+{%- if compute.cross_az_attach is defined %}
+cross_az_attach={{ compute.cross_az_attach }}
+{%- endif %}
 
 {%- if compute.workaround is defined %}
 [workarounds]
@@ -206,4 +209,4 @@
 {%- for key, value in compute.upgrade_levels.iteritems() %}
 {{ key }}={{ value }}
 {%- endfor %}
-{%- endif -%}
+{%- endif %}
diff --git a/nova/files/mitaka/nova-controller.conf.Debian b/nova/files/mitaka/nova-controller.conf.Debian
index f44566e..b808ef9 100644
--- a/nova/files/mitaka/nova-controller.conf.Debian
+++ b/nova/files/mitaka/nova-controller.conf.Debian
@@ -205,6 +205,9 @@
 [cinder]
 os_region_name = {{ controller.identity.region }}
 catalog_info=volumev2:cinderv2:internalURL
+{%- if controller.cross_az_attach is defined %}
+cross_az_attach={{ controller.cross_az_attach }}
+{%- endif %}
 
 [vnc]
 keymap = {{ controller.get('vnc_keymap', 'en-us') }}
@@ -260,4 +263,4 @@
 {%- for key, value in controller.upgrade_levels.iteritems() %}
 {{ key }}={{ value }}
 {%- endfor %}
-{%- endif -%}
+{%- endif %}
diff --git a/nova/files/newton/nova-compute.conf.Debian b/nova/files/newton/nova-compute.conf.Debian
index ee4525d..d9f5975 100644
--- a/nova/files/newton/nova-compute.conf.Debian
+++ b/nova/files/newton/nova-compute.conf.Debian
@@ -143,7 +143,7 @@
 virt_type = kvm
 inject_partition=-2
 inject_password=False
-disk_cachemodes="network=writeback,block=none"
+disk_cachemodes="{{ compute.get('disk_cachemodes', 'network=writeback,block=none') }}"
 libvirt_inject_password=True
 block_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_NON_SHARED_INC
 live_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST
@@ -207,6 +207,9 @@
 [cinder]
 os_region_name = {{ compute.identity.region }}
 catalog_info=volumev2:cinderv2:internalURL
+{%- if compute.cross_az_attach is defined %}
+cross_az_attach={{ compute.cross_az_attach }}
+{%- endif %}
 
 {%- if compute.ironic is defined %}
 [ironic]
@@ -230,4 +233,4 @@
 {%- for key, value in compute.upgrade_levels.iteritems() %}
 {{ key }}={{ value }}
 {%- endfor %}
-{%- endif -%}
+{%- endif %}
diff --git a/nova/files/newton/nova-controller.conf.Debian b/nova/files/newton/nova-controller.conf.Debian
index 801aab9..77e53eb 100644
--- a/nova/files/newton/nova-controller.conf.Debian
+++ b/nova/files/newton/nova-controller.conf.Debian
@@ -215,6 +215,9 @@
 [cinder]
 os_region_name = {{ controller.identity.region }}
 catalog_info=volumev2:cinderv2:internalURL
+{%- if controller.cross_az_attach is defined %}
+cross_az_attach={{ controller.cross_az_attach }}
+{%- endif %}
 
 [wsgi]
 api_paste_config=/etc/nova/api-paste.ini
@@ -269,4 +272,4 @@
 {%- for key, value in controller.upgrade_levels.iteritems() %}
 {{ key }}={{ value }}
 {%- endfor %}
-{%- endif -%}
+{%- endif %}
diff --git a/nova/files/newton/nova-controller.conf.RedHat b/nova/files/newton/nova-controller.conf.RedHat
index 193d536..3d5263c 100644
--- a/nova/files/newton/nova-controller.conf.RedHat
+++ b/nova/files/newton/nova-controller.conf.RedHat
@@ -210,6 +210,9 @@
 [cinder]
 os_region_name = {{ controller.identity.region }}
 catalog_info=volumev2:cinderv2:internalURL
+{%- if controller.cross_az_attach is defined %}
+cross_az_attach={{ controller.cross_az_attach }}
+{%- endif %}
 
 [wsgi]
 api_paste_config=/etc/nova/api-paste.ini
@@ -219,4 +222,4 @@
 {%- for key, value in controller.upgrade_levels.iteritems() %}
 {{ key }}={{ value }}
 {%- endfor %}
-{%- endif -%}
+{%- endif %}
diff --git a/nova/files/ocata/nova-compute.conf.Debian b/nova/files/ocata/nova-compute.conf.Debian
index 0e21b2e..77d4b50 100644
--- a/nova/files/ocata/nova-compute.conf.Debian
+++ b/nova/files/ocata/nova-compute.conf.Debian
@@ -4119,6 +4119,9 @@
 # By default there is no availability zone restriction on volume attach.
 #  (boolean value)
 #cross_az_attach=true
+{%- if compute.cross_az_attach is defined %}
+cross_az_attach={{ compute.cross_az_attach }}
+{%- endif %}
 
 
 [cloudpipe]
@@ -5899,7 +5902,7 @@
 virt_type = kvm
 inject_partition=-2
 inject_password=True
-disk_cachemodes="network=writeback,block=none"
+disk_cachemodes="{{ compute.get('disk_cachemodes', 'network=writeback,block=none') }}"
 block_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_NON_SHARED_INC
 live_migration_flag=VIR_MIGRATE_UNDEFINE_SOURCE,VIR_MIGRATE_PEER2PEER,VIR_MIGRATE_LIVE,VIR_MIGRATE_PERSIST_DEST
 inject_key=True
@@ -9400,7 +9403,8 @@
 {%- for key, value in compute.upgrade_levels.iteritems() %}
 {{ key }}={{ value }}
 {%- endfor %}
-{%- endif -%}#
+{%- endif %}
+#
 # upgrade_levels options are used to set version cap for RPC
 # messages sent between different nova services.
 #
diff --git a/nova/files/ocata/nova-controller.conf.Debian b/nova/files/ocata/nova-controller.conf.Debian
index 78ce62b..7a8126a 100644
--- a/nova/files/ocata/nova-controller.conf.Debian
+++ b/nova/files/ocata/nova-controller.conf.Debian
@@ -4103,7 +4103,9 @@
 # By default there is no availability zone restriction on volume attach.
 #  (boolean value)
 #cross_az_attach=true
-
+{%- if controller.cross_az_attach is defined %}
+cross_az_attach={{ controller.cross_az_attach }}
+{%- endif %}
 
 [cloudpipe]
 
@@ -9399,7 +9401,7 @@
 {%- for key, value in controller.upgrade_levels.iteritems() %}
 {{ key }}={{ value }}
 {%- endfor %}
-{%- endif -%}
+{%- endif %}
 #
 # upgrade_levels options are used to set version cap for RPC
 # messages sent between different nova services.
diff --git a/nova/files/ocata/nova-placement-api.conf b/nova/files/ocata/nova-placement-api.conf
index 02e88cc..e7cde11 100644
--- a/nova/files/ocata/nova-placement-api.conf
+++ b/nova/files/ocata/nova-placement-api.conf
@@ -14,7 +14,7 @@
     </IfVersion>
 
     ErrorLog /var/log/apache2/nova_placement_error.log
-    CustomLog /var/log/apache2/nova_placement_access.log combined
+    CustomLog /var/log/apache2/nova_placement_access.log "%v:%p %h %l %u %t \"%r\" %>s %D %O \"%{Referer}i\" \"%{User-Agent}i\""
 
     <Directory /usr/bin>
         <IfVersion >= 2.4>
diff --git a/nova/meta/heka.yml b/nova/meta/heka.yml
index 6121039..2ff45c8 100644
--- a/nova/meta/heka.yml
+++ b/nova/meta/heka.yml
@@ -1,3 +1,5 @@
+{% from "nova/map.jinja" import controller with context %}
+{%- set apache_wsgi = controller.get('enabled') and controller.version not in ('juno', 'kilo', 'liberty', 'mitaka', 'newton') %}
 log_collector:
   decoder:
     nova:
@@ -11,6 +13,16 @@
       module_file: /usr/share/lma_collector/decoders/libvirt_log.lua
       module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
     {%- endif %}
+    {%- if apache_wsgi %}
+    nova_placement_wsgi:
+      engine: sandbox
+      module_file: /usr/share/lma_collector/decoders/apache_wsgi_log.lua
+      module_dir: /usr/share/lma_collector/common;/usr/share/heka/lua_modules
+      config:
+        logger: openstack.nova_placement
+        apache_log_pattern: >-
+          %v:%p %h %l %u %t \"%r\" %>s %D %O \"%{Referer}i\" \"%{User-Agent}i\"
+    {%- endif %}
   splitter:
     nova:
       engine: token
@@ -33,6 +45,16 @@
       decoder: "libvirt_decoder"
       splitter: "TokenSplitter"
     {%- endif %}
+    {%- if apache_wsgi %}
+    nova_placement_wsgi_log:
+      engine: logstreamer
+      log_directory: "/var/log/apache2"
+      file_match: 'nova_placement_access\.log'
+      differentiator: ['nova-placement-wsgi']
+      priority: ["^Seq"]
+      decoder: "nova_placement_wsgi_decoder"
+      splitter: "TokenSplitter"
+    {%- endif %}
 metric_collector:
   trigger:
     nova_logs_error:
diff --git a/tests/pillar/compute_cluster.sls b/tests/pillar/compute_cluster.sls
index 1a3335f..2bcd9b4 100644
--- a/tests/pillar/compute_cluster.sls
+++ b/tests/pillar/compute_cluster.sls
@@ -7,6 +7,7 @@
       mount_points:
       - path: /mnt/hugepages_1GB
     virtualization: kvm
+    disk_cachemodes: network=writeback,block=none
     heal_instance_info_cache_interval: 60
     vncproxy_url: openstack:6080
     report_interval: 60