Merge "Add threshold for nova services alerts"
diff --git a/nova/compute.sls b/nova/compute.sls
index 641305e..07fdfe2 100644
--- a/nova/compute.sls
+++ b/nova/compute.sls
@@ -186,24 +186,68 @@
   pkg.installed:
   - name: ceph-common
 
+{%- if compute.ceph.cinder_secret_uuid is defined and compute.ceph.cinder_volumes_key is defined %}
+
+{%- set cinder_volumes_key = salt['grains.get']("ceph:ceph_keyring:"+compute.ceph.cinder_volumes_key+":key", '') %}
+
+{%- if cinder_volumes_key != '' %}
+
+/etc/secret_cinder.xml:
+  file.managed:
+  - source: salt://nova/files/secret_cinder.xml
+  - template: jinja
+
+ceph_virsh_secret_define_cinder:
+  cmd.run:
+  - name: "virsh secret-define --file /etc/secret_cinder.xml"
+  - unless: "virsh secret-list | grep {{ compute.ceph.cinder_secret_uuid }}"
+  - require:
+    - file: /etc/secret_cinder.xml
+
+ceph_virsh_secret_set_value_cinder:
+  cmd.run:
+  - name: "virsh secret-set-value --secret {{ compute.ceph.cinder_secret_uuid }} --base64 {{ cinder_volumes_key }} "
+  - unless: "virsh secret-get-value {{ compute.ceph.cinder_secret_uuid }} | grep {{ cinder_volumes_key }}"
+  - require:
+    - cmd: ceph_virsh_secret_define_cinder
+
+{% endif %}
+
+{% endif %}
+
 /etc/secret.xml:
   file.managed:
   - source: salt://nova/files/secret.xml
   - template: jinja
 
-ceph_virsh_secret_define:
+ceph_virsh_secret_define_nova:
   cmd.run:
   - name: "virsh secret-define --file /etc/secret.xml"
   - unless: "virsh secret-list | grep {{ compute.ceph.secret_uuid }}"
   - require:
     - file: /etc/secret.xml
 
-ceph_virsh_secret_set_value:
+{%- set client_cinder_key = salt['grains.get']("ceph:ceph_keyring:"+compute.ceph.client_cinder_key+":key", '') %}
+
+{%- if client_cinder_key != '' %}
+
+ceph_virsh_secret_set_value_nova:
+  cmd.run:
+  - name: "virsh secret-set-value --secret {{ compute.ceph.secret_uuid }} --base64 {{ client_cinder_key }} "
+  - unless: "virsh secret-get-value {{ compute.ceph.secret_uuid }} | grep {{ client_cinder_key }}"
+  - require:
+    - cmd: ceph_virsh_secret_define_nova
+
+{% else %}
+
+ceph_virsh_secret_set_value_nova:
   cmd.run:
   - name: "virsh secret-set-value --secret {{ compute.ceph.secret_uuid }} --base64 {{ compute.ceph.client_cinder_key }} "
   - unless: "virsh secret-get-value {{ compute.ceph.secret_uuid }} | grep {{ compute.ceph.client_cinder_key }}"
   - require:
-    - cmd: ceph_virsh_secret_define
+    - cmd: ceph_virsh_secret_define_nova
+
+{% endif %}
 
 {% endif %}
 
diff --git a/nova/files/mitaka/nova-compute.conf.Debian b/nova/files/mitaka/nova-compute.conf.Debian
index bdd636c..232b569 100644
--- a/nova/files/mitaka/nova-compute.conf.Debian
+++ b/nova/files/mitaka/nova-compute.conf.Debian
@@ -122,6 +122,9 @@
 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
+{%- if compute.libvirt.migration_inbound_addr is defined %}
+live_migration_inbound_addr = {{ compute.libvirt.migration_inbound_addr }}
+{%- endif %}
 libvirt_inject_key=True
 inject_key=False
 vif_driver=nova.virt.libvirt.vif.LibvirtGenericVIFDriver
diff --git a/nova/files/newton/nova-compute.conf.Debian b/nova/files/newton/nova-compute.conf.Debian
index fb6fc85..7f950c1 100644
--- a/nova/files/newton/nova-compute.conf.Debian
+++ b/nova/files/newton/nova-compute.conf.Debian
@@ -165,6 +165,9 @@
 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
+{%- if compute.libvirt.migration_inbound_addr is defined %}
+live_migration_inbound_addr = {{ compute.libvirt.migration_inbound_addr }}
+{%- endif %}
 libvirt_inject_key=True
 inject_key=False
 vif_driver=nova.virt.libvirt.vif.LibvirtGenericVIFDriver
diff --git a/nova/files/ocata/nova-compute.conf.Debian b/nova/files/ocata/nova-compute.conf.Debian
index 2e2d276..f7db4c2 100644
--- a/nova/files/ocata/nova-compute.conf.Debian
+++ b/nova/files/ocata/nova-compute.conf.Debian
@@ -6147,6 +6147,9 @@
 # * A valid IP address or hostname, else None.
 #  (string value)
 #live_migration_inbound_addr=<None>
+{%- if compute.libvirt.migration_inbound_addr is defined %}
+live_migration_inbound_addr = {{ compute.libvirt.migration_inbound_addr }}
+{%- endif %}
 
 # DEPRECATED:
 # Live migration target URI to use.
diff --git a/nova/files/secret.xml b/nova/files/secret.xml
index 19e55c8..aacd09e 100644
--- a/nova/files/secret.xml
+++ b/nova/files/secret.xml
@@ -4,4 +4,4 @@
   <usage type='ceph'>
     <name>client.{{ compute.ceph.get('rbd_user', 'cinder') }} secret</name>
   </usage>
-</secret>
+</secret>
\ No newline at end of file
diff --git a/nova/files/secret_cinder.xml b/nova/files/secret_cinder.xml
new file mode 100644
index 0000000..01e4dda
--- /dev/null
+++ b/nova/files/secret_cinder.xml
@@ -0,0 +1,4 @@
+{%- from "nova/map.jinja" import compute with context %}
+<secret ephemeral='no' private='no'>
+  <uuid>{{ compute.ceph.cinder_secret_uuid }}</uuid>
+</secret>