Merge "Remove obsolete Nova stats alerts" into release/2019.2.0
diff --git a/README.rst b/README.rst
index 8eaa2e2..f89e590 100644
--- a/README.rst
+++ b/README.rst
@@ -718,6 +718,26 @@
       libvirt:
         cpu_model: IvyBridge
 
+RNG (Random Number Generator) device path
+----------------------
+
+The path to an RNG (Random Number Generator) device that will be used
+as the source of entropy on the host.
+The recommended source of entropy is /dev/urandom.
+Permitted options are: /dev/random, /dev/urandom or /dev/hwrng.
+Default: /dev/urandom
+
+.. code-block:: yaml
+
+  nova:
+    controller:
+      libvirt:
+        rng_dev_path: /dev/random
+
+    compute:
+      libvirt:
+        rng_dev_path: /dev/random
+
 
 Nova compute workarounds
 ------------------------
diff --git a/nova/compute.sls b/nova/compute.sls
index 6103c14..697ac1e 100644
--- a/nova/compute.sls
+++ b/nova/compute.sls
@@ -586,4 +586,23 @@
   - name: 'systemd-tmpfiles --create'
 {%- endif %}
 
+{%- if compute.get('libvirt', {}).rng_dev_path is defined and compute.libvirt.rng_dev_path == '/dev/hwrng' %}
+create_hwrng_udev_rule_compute:
+  file.managed:
+    - name: /etc/udev/rules.d/90-hwrng.rules
+    - source: salt://nova/files/90-hwrng.rules
+    - user: root
+    - group: root
+    - mode: 0644
+    - onlyif: test -c /dev/hwrng
+
+trigger_hwrng_udev_compute:
+  cmd.run:
+    - name: udevadm trigger /dev/hwrng
+    - onchanges:
+      - file: /etc/udev/rules.d/90-hwrng.rules
+
+{%- endif %}
+
+
 {%- endif %}
diff --git a/nova/controller.sls b/nova/controller.sls
index 68a9bb4..2b0a669 100644
--- a/nova/controller.sls
+++ b/nova/controller.sls
@@ -486,4 +486,23 @@
 
 {%- endif %}
 
+{%- if controller.get('libvirt', {}).rng_dev_path is defined and controller.libvirt.rng_dev_path == '/dev/hwrng' %}
+create_hwrng_udev_rule_controller:
+  file.managed:
+    - name: /etc/udev/rules.d/90-hwrng.rules
+    - source: salt://nova/files/90-hwrng.rules
+    - user: root
+    - group: root
+    - mode: 0644
+    - onlyif: test -c /dev/hwrng
+
+trigger_hwrng_udev_controller:
+  cmd.run:
+    - name: udevadm trigger /dev/hwrng
+    - onchanges:
+      - file: /etc/udev/rules.d/90-hwrng.rules
+
+{%- endif %}
+
+
 {%- endif %}
diff --git a/nova/files/90-hwrng.rules b/nova/files/90-hwrng.rules
new file mode 100644
index 0000000..b817b2b
--- /dev/null
+++ b/nova/files/90-hwrng.rules
@@ -0,0 +1,2 @@
+SUBSYSTEM=="misc", KERNEL=="hw_random", NAME="hwrng", GROUP="kvm", MODE="0660"
+
diff --git a/nova/files/mitaka/nova-compute.conf.Debian b/nova/files/mitaka/nova-compute.conf.Debian
index b570570..05ec5d1 100644
--- a/nova/files/mitaka/nova-compute.conf.Debian
+++ b/nova/files/mitaka/nova-compute.conf.Debian
@@ -47,6 +47,10 @@
 cpu_allocation_ratio = {{ compute.cpu_allocation_ratio }}
 {%- endif %}
 
+{%- if compute.disk_allocation_ratio is defined %}
+disk_allocation_ratio = {{ compute.disk_allocation_ratio }}
+{%- endif %}
+
 remove_unused_original_minimum_age_seconds=86400
 image_service=nova.image.glance.GlanceImageService
 
diff --git a/nova/files/newton/nova-compute.conf.Debian b/nova/files/newton/nova-compute.conf.Debian
index 2540a43..c7ef466 100644
--- a/nova/files/newton/nova-compute.conf.Debian
+++ b/nova/files/newton/nova-compute.conf.Debian
@@ -63,6 +63,10 @@
 cpu_allocation_ratio = {{ compute.cpu_allocation_ratio }}
 {%- endif %}
 
+{%- if compute.disk_allocation_ratio is defined %}
+disk_allocation_ratio = {{ compute.disk_allocation_ratio }}
+{%- endif %}
+
 #
 # Defines which physical CPUs (pCPUs) can be used by instance
 # virtual CPUs (vCPUs).
diff --git a/nova/files/ocata/nova-compute.conf.Debian b/nova/files/ocata/nova-compute.conf.Debian
index 3c069ed..f6a77be 100644
--- a/nova/files/ocata/nova-compute.conf.Debian
+++ b/nova/files/ocata/nova-compute.conf.Debian
@@ -610,7 +610,11 @@
 # * Any valid positive integer or float value
 #  (floating point value)
 # Minimum value: 0
+{%- if compute.disk_allocation_ratio is defined %}
+disk_allocation_ratio = {{ compute.disk_allocation_ratio }}
+{%- else  %}
 #disk_allocation_ratio=0.0
+{%- endif %}
 
 #
 # Console proxy host to be used to connect to instances on this host. It is the
diff --git a/nova/files/pike/nova-compute.conf.Debian b/nova/files/pike/nova-compute.conf.Debian
index 67bb430..fdc531d 100644
--- a/nova/files/pike/nova-compute.conf.Debian
+++ b/nova/files/pike/nova-compute.conf.Debian
@@ -618,7 +618,11 @@
 # * Any valid positive integer or float value
 #  (floating point value)
 # Minimum value: 0
+{%- if compute.disk_allocation_ratio is defined %}
+disk_allocation_ratio = {{ compute.disk_allocation_ratio }}
+{%- else  %}
 #disk_allocation_ratio=0.0
+{%- endif %}
 
 #
 # Console proxy host to be used to connect to instances on this host. It is the
@@ -6550,6 +6554,9 @@
 # A path to a device that will be used as source of entropy on the host.
 # Permitted options are: /dev/random or /dev/hwrng (string value)
 #rng_dev_path=<None>
+{%- if compute.get('libvirt', {}).rng_dev_path is defined %}
+rng_dev_path={{ compute.libvirt.rng_dev_path }}
+{%- endif %}
 
 # For qemu or KVM guests, set this option to specify a default machine type per
 # host architecture. You can find a list of supported machine types in your
diff --git a/nova/files/pike/nova-controller.conf.Debian b/nova/files/pike/nova-controller.conf.Debian
index a61c236..3a4a725 100644
--- a/nova/files/pike/nova-controller.conf.Debian
+++ b/nova/files/pike/nova-controller.conf.Debian
@@ -6525,6 +6525,9 @@
 # A path to a device that will be used as source of entropy on the host.
 # Permitted options are: /dev/random or /dev/hwrng (string value)
 #rng_dev_path=<None>
+{%- if controller.get('libvirt', {}).rng_dev_path is defined %}
+rng_dev_path={{ controller.libvirt.rng_dev_path }}
+{%- endif %}
 
 # For qemu or KVM guests, set this option to specify a default machine type per
 # host architecture. You can find a list of supported machine types in your
diff --git a/nova/files/queens/nova-compute.conf.Debian b/nova/files/queens/nova-compute.conf.Debian
index 54dfd87..22ba3f3 100644
--- a/nova/files/queens/nova-compute.conf.Debian
+++ b/nova/files/queens/nova-compute.conf.Debian
@@ -666,7 +666,11 @@
 # * Any valid positive integer or float value
 #  (floating point value)
 # Minimum value: 0
+{%- if compute.disk_allocation_ratio is defined %}
+disk_allocation_ratio = {{ compute.disk_allocation_ratio }}
+{%- else  %}
 #disk_allocation_ratio = 0.0
+{%- endif %}
 
 #
 # Console proxy host to be used to connect to instances on this host.
@@ -7144,6 +7148,9 @@
 # host. Permitted options are: /dev/random or /dev/hwrng (string
 # value)
 #rng_dev_path = <None>
+{%- if compute.get('libvirt', {}).rng_dev_path is defined %}
+rng_dev_path={{ compute.libvirt.rng_dev_path }}
+{%- endif %}
 
 # For qemu or KVM guests, set this option to specify a default machine
 # type per host architecture. You can find a list of supported machine
diff --git a/nova/files/queens/nova-controller.conf.Debian b/nova/files/queens/nova-controller.conf.Debian
index fbf978b..7ccaf52 100644
--- a/nova/files/queens/nova-controller.conf.Debian
+++ b/nova/files/queens/nova-controller.conf.Debian
@@ -655,7 +655,11 @@
 # * Any valid positive integer or float value
 #  (floating point value)
 # Minimum value: 0
+{%- if controller.disk_allocation_ratio is defined %}
+disk_allocation_ratio = {{ controller.disk_allocation_ratio }}
+{%- else  %}
 #disk_allocation_ratio = 0.0
+{%- endif %}
 
 #
 # Console proxy host to be used to connect to instances on this host.
@@ -6991,6 +6995,9 @@
 # host. Permitted options are: /dev/random or /dev/hwrng (string
 # value)
 #rng_dev_path = <None>
+{%- if controller.get('libvirt', {}).rng_dev_path is defined %}
+rng_dev_path={{ controller.libvirt.rng_dev_path }}
+{%- endif %}
 
 # For qemu or KVM guests, set this option to specify a default machine
 # type per host architecture. You can find a list of supported machine
diff --git a/nova/meta/prometheus.yml b/nova/meta/prometheus.yml
index fbebd2d..f3e12ee 100644
--- a/nova/meta/prometheus.yml
+++ b/nova/meta/prometheus.yml
@@ -4,8 +4,7 @@
 {%- set is_compute = compute.get('enabled', False) %}
 
 {%- if is_controller or is_compute %}
-{%- if is_compute and
-       exporters is defined %}
+{%- if is_compute and exporters is defined and compute.get('compute_driver', 'libvirt.LibvirtDriver') == 'libvirt.LibvirtDriver' %}
 {%- set packages = exporters.get('libvirt', {}).get('packages', ('libvirt-exporter', )) %}
   {%- load_yaml as new_exporters_cfg %}
 exporters:
@@ -157,7 +156,7 @@
         summary: "High number of errors in Nova logs"
         description: "The average rate of errors in Nova logs on the {{ $labels.host }} node is more than 0.2 error messages per second (as measured over the last 5 minutes)."
 {%- endraw %}
-{%- if is_compute and exporters is defined %}
+{%- if is_compute and exporters is defined and compute.get('compute_driver', 'libvirt.LibvirtDriver') == 'libvirt.LibvirtDriver'%}
 {%- raw %}
     LibvirtDown:
       if: >-
diff --git a/tests/pillar/compute_cluster.sls b/tests/pillar/compute_cluster.sls
index 4988c0b..e6124f2 100644
--- a/tests/pillar/compute_cluster.sls
+++ b/tests/pillar/compute_cluster.sls
@@ -13,6 +13,9 @@
     vnc_keymap: en-gb
     resume_guests_state_on_host_boot: True
     preallocate_images: space
+    cpu_allocation_ratio: 16.0
+    ram_allocation_ratio: 1.5
+    disk_allocation_ratio: 1.0
     bind:
       vnc_address: 127.0.0.1
       vnc_port: 6080
diff --git a/tests/pillar/compute_single.sls b/tests/pillar/compute_single.sls
index c2b740a..99e4aff 100644
--- a/tests/pillar/compute_single.sls
+++ b/tests/pillar/compute_single.sls
@@ -8,6 +8,9 @@
     resume_guests_state_on_host_boot: False
     preallocate_images: space
     cpu_mode: custom
+    cpu_allocation_ratio: 16.0
+    ram_allocation_ratio: 1.5
+    disk_allocation_ratio: 1.0
     libvirt:
       cpu_model: IvyBridge
     bind: