Merge "Handle scheduler default filters as sequence"
diff --git a/README.rst b/README.rst
index 220b8eb..4d698c4 100644
--- a/README.rst
+++ b/README.rst
@@ -56,6 +56,13 @@
           user: openstack
           password: pwd
           virtual_host: '/openstack'
+        pci:
+          alias:
+            alias1:
+              device_type: "type-PF"
+              name: "a1"
+              product_id: "154d"
+              vendor_id: "8086"
         network:
           engine: neutron
           host: 127.0.0.1
@@ -156,6 +163,20 @@
         barbican:
           enabled: true
 
+Define aliases for PCI devices:
+.. code-block:: yaml
+
+    nova:
+      controller:
+        ...
+        pci:
+          alias:
+            alias1:
+              device_type: "type-PF"
+              name: "a1"
+              product_id: "154d"
+              vendor_id: "8086"
+
 Enable cells update:
 
 .. note:: Useful when upgrading Openstack. To update cells to test
@@ -290,6 +311,13 @@
           engine: glance
           host: 127.0.0.1
           port: 9292
+        pci:
+          alias:
+            alias1:
+              device_type: "type-PF"
+              name: "a1"
+              product_id: "154d"
+              vendor_id: "8086"
         network:
           engine: neutron
           host: 127.0.0.1
@@ -446,6 +474,20 @@
         barbican:
           enabled: true
 
+Define aliases for PCI devices:
+.. code-block:: yaml
+
+    nova:
+      compute:
+        ...
+        pci:
+          alias:
+            alias1:
+              device_type: "type-PF"
+              name: "a1"
+              product_id: "154d"
+              vendor_id: "8086"
+
 Nova metadata custom bindings:
 
 .. code-block:: yaml
@@ -565,6 +607,9 @@
           devname: eth1
           physical_network: physnet1
 
+.. note:: Parameters located under nova:compute:sriov:<nic_name> are copied to passthrough_whitelist parameter into
+          nova.conf file in appropriate format.
+
 CPU pinning & Hugepages
 -----------------------
 
diff --git a/nova/files/mitaka/nova-compute.conf.Debian b/nova/files/mitaka/nova-compute.conf.Debian
index 0563049..b570570 100644
--- a/nova/files/mitaka/nova-compute.conf.Debian
+++ b/nova/files/mitaka/nova-compute.conf.Debian
@@ -19,9 +19,14 @@
 vif_plugging_timeout=300
 dhcp_domain={{ compute.get('dhcp_domain', 'novalocal') }}
 {%- if compute.get('sriov', false) %}
-{%- for nic_name, sriov in compute.sriov.iteritems() %}
-pci_passthrough_whitelist = {"devname":"{{ sriov.devname }}","physical_network":"{{ sriov.physical_network }}"}
-{%- endfor %}
+  {%- for nic_name, sriov in compute.sriov.iteritems() %}
+pci_passthrough_whitelist = {{ sriov | json }}
+  {%- endfor %}
+{%- endif %}
+{%- if compute.get('pci', {}).get('alias', false) %}
+  {%- for alias_name, alias in compute.pci.alias.iteritems() %}
+pci_alias = {{ alias | json }}
+  {%- endfor %}
 {%- endif %}
 {%- if compute.image.use_cow is defined %}
 use_cow_images = {{ compute.image.use_cow }}
diff --git a/nova/files/mitaka/nova-controller.conf.Debian b/nova/files/mitaka/nova-controller.conf.Debian
index d5c4e65..fb95af9 100644
--- a/nova/files/mitaka/nova-controller.conf.Debian
+++ b/nova/files/mitaka/nova-controller.conf.Debian
@@ -83,6 +83,12 @@
 host={{ controller.host }}
 {%- endif %}
 
+{%- if controller.get('pci', {}).get('alias', false) %}
+  {%- for alias_name, alias in controller.pci.alias.iteritems() %}
+pci_alias = {{ alias | json }}
+  {%- endfor %}
+{%- endif %}
+
 [vnc]
 enabled = true
 novncproxy_host = {{ controller.bind.get('novncproxy_address', '0.0.0.0') }}
diff --git a/nova/files/newton/nova-compute.conf.Debian b/nova/files/newton/nova-compute.conf.Debian
index 7df9f31..2540a43 100644
--- a/nova/files/newton/nova-compute.conf.Debian
+++ b/nova/files/newton/nova-compute.conf.Debian
@@ -21,9 +21,14 @@
 vif_plugging_timeout=300
 dhcp_domain={{ compute.get('dhcp_domain', 'novalocal') }}
 {%- if compute.get('sriov', false) %}
-{%- for nic_name, sriov in compute.sriov.iteritems() %}
-pci_passthrough_whitelist = {"devname":"{{ sriov.devname }}","physical_network":"{{ sriov.physical_network }}"}
-{%- endfor %}
+  {%- for nic_name, sriov in compute.sriov.iteritems() %}
+pci_passthrough_whitelist = {{ sriov | json }}
+  {%- endfor %}
+{%- endif %}
+{%- if compute.get('pci', {}).get('alias', false) %}
+  {%- for alias_name, alias in compute.pci.alias.iteritems() %}
+pci_alias = {{ alias | json }}
+  {%- endfor %}
 {%- endif %}
 {%- if compute.image.use_cow is defined %}
 use_cow_images = {{ compute.image.use_cow }}
diff --git a/nova/files/newton/nova-controller.conf.Debian b/nova/files/newton/nova-controller.conf.Debian
index 124b5d7..0b037df 100644
--- a/nova/files/newton/nova-controller.conf.Debian
+++ b/nova/files/newton/nova-controller.conf.Debian
@@ -105,6 +105,12 @@
 host={{ controller.host }}
 {%- endif %}
 
+{%- if controller.get('pci', {}).get('alias', false) %}
+  {%- for alias_name, alias in controller.pci.alias.iteritems() %}
+pci_alias = {{ alias | json }}
+  {%- endfor %}
+{%- endif %}
+
 [oslo_messaging_rabbit]
 rabbit_use_ssl=true
 
diff --git a/nova/files/ocata/nova-compute.conf.Debian b/nova/files/ocata/nova-compute.conf.Debian
index dacdacb..6632ffc 100644
--- a/nova/files/ocata/nova-compute.conf.Debian
+++ b/nova/files/ocata/nova-compute.conf.Debian
@@ -8247,6 +8247,11 @@
 #  (multi valued)
 # Deprecated group/name - [DEFAULT]/pci_alias
 #alias =
+{%- if compute.get('pci', {}).get('alias', false) %}
+  {%- for alias_name, alias in compute.pci.alias.iteritems() %}
+alias = {{ alias | json }}
+  {%- endfor %}
+{%- endif %}
 
 #
 # White list of PCI devices available to VMs.
@@ -8313,9 +8318,9 @@
 # Deprecated group/name - [DEFAULT]/pci_passthrough_whitelist
 #passthrough_whitelist =
 {%- if compute.get('sriov', false) %}
-{%- for nic_name, sriov in compute.sriov.iteritems() %}
-passthrough_whitelist = {"devname":"{{ sriov.devname }}","physical_network":"{{ sriov.physical_network }}"}
-{%- endfor %}
+  {%- for nic_name, sriov in compute.sriov.iteritems() %}
+passthrough_whitelist = {{ sriov | json }}
+  {%- endfor %}
 {%- endif %}
 
 [placement]
diff --git a/nova/files/ocata/nova-controller.conf.Debian b/nova/files/ocata/nova-controller.conf.Debian
index 6c568f9..06164f4 100644
--- a/nova/files/ocata/nova-controller.conf.Debian
+++ b/nova/files/ocata/nova-controller.conf.Debian
@@ -8228,6 +8228,11 @@
 #  (multi valued)
 # Deprecated group/name - [DEFAULT]/pci_alias
 #alias =
+{%- if controller.get('pci', {}).get('alias', false) %}
+  {%- for alias_name, alias in controller.pci.alias.iteritems() %}
+alias = {{ alias | json }}
+  {%- endfor %}
+{%- endif %}
 
 #
 # White list of PCI devices available to VMs.
diff --git a/nova/files/pike/nova-compute.conf.Debian b/nova/files/pike/nova-compute.conf.Debian
index 7dba92c..d3757e7 100644
--- a/nova/files/pike/nova-compute.conf.Debian
+++ b/nova/files/pike/nova-compute.conf.Debian
@@ -8304,6 +8304,11 @@
 #  (multi valued)
 # Deprecated group/name - [DEFAULT]/pci_alias
 #alias =
+{%- if compute.get('pci', {}).get('alias', false) %}
+  {%- for alias_name, alias in compute.pci.alias.iteritems() %}
+alias = {{ alias | json }}
+  {%- endfor %}
+{%- endif %}
 
 #
 # White list of PCI devices available to VMs.
@@ -8370,9 +8375,9 @@
 # Deprecated group/name - [DEFAULT]/pci_passthrough_whitelist
 #passthrough_whitelist =
 {%- if compute.get('sriov', false) %}
-{%- for nic_name, sriov in compute.sriov.iteritems() %}
-passthrough_whitelist = {"devname":"{{ sriov.devname }}","physical_network":"{{ sriov.physical_network }}"}
-{%- endfor %}
+  {%- for nic_name, sriov in compute.sriov.iteritems() %}
+passthrough_whitelist = {{ sriov | json }}
+  {%- endfor %}
 {%- endif %}
 
 [placement]
diff --git a/nova/files/pike/nova-controller.conf.Debian b/nova/files/pike/nova-controller.conf.Debian
index de8325b..3a434db 100644
--- a/nova/files/pike/nova-controller.conf.Debian
+++ b/nova/files/pike/nova-controller.conf.Debian
@@ -8268,6 +8268,11 @@
 #  (multi valued)
 # Deprecated group/name - [DEFAULT]/pci_alias
 #alias =
+{%- if controller.get('pci', {}).get('alias', false) %}
+  {%- for alias_name, alias in controller.pci.alias.iteritems() %}
+alias = {{ alias | json }}
+  {%- endfor %}
+{%- endif %}
 
 #
 # White list of PCI devices available to VMs.
diff --git a/nova/files/queens/nova-compute.conf.Debian b/nova/files/queens/nova-compute.conf.Debian
index a18003b..9f5155e 100644
--- a/nova/files/queens/nova-compute.conf.Debian
+++ b/nova/files/queens/nova-compute.conf.Debian
@@ -8218,6 +8218,11 @@
 #  (multi valued)
 # Deprecated group/name - [DEFAULT]/pci_alias
 #alias =
+{%- if compute.get('pci', {}).get('alias', false) %}
+  {%- for alias_name, alias in compute.pci.alias.iteritems() %}
+alias = {{ alias | json }}
+  {%- endfor %}
+{%- endif %}
 
 #
 # White list of PCI devices available to VMs.
@@ -8295,9 +8300,9 @@
 # Deprecated group/name - [DEFAULT]/pci_passthrough_whitelist
 #passthrough_whitelist =
 {%- if compute.get('sriov', false) %}
-{%- for nic_name, sriov in compute.sriov.iteritems() %}
-passthrough_whitelist = {"devname":"{{ sriov.devname }}","physical_network":"{{ sriov.physical_network }}"}
-{%- endfor %}
+  {%- for nic_name, sriov in compute.sriov.iteritems() %}
+passthrough_whitelist = {{ sriov | json }}
+  {%- endfor %}
 {%- endif %}
 
 [placement]
diff --git a/nova/files/queens/nova-controller.conf.Debian b/nova/files/queens/nova-controller.conf.Debian
index a78f6d0..12d1b58 100644
--- a/nova/files/queens/nova-controller.conf.Debian
+++ b/nova/files/queens/nova-controller.conf.Debian
@@ -8081,6 +8081,11 @@
 #  (multi valued)
 # Deprecated group/name - [DEFAULT]/pci_alias
 #alias =
+{%- if controller.get('pci', {}).get('alias', false) %}
+  {%- for alias_name, alias in controller.pci.alias.iteritems() %}
+alias = {{ alias | json }}
+  {%- endfor %}
+{%- endif %}
 
 #
 # White list of PCI devices available to VMs.
diff --git a/nova/map.jinja b/nova/map.jinja
index 7aa4d8b..370f517 100644
--- a/nova/map.jinja
+++ b/nova/map.jinja
@@ -112,7 +112,7 @@
 }, merge=pillar.nova.get('controller', {}), base='BaseDefaults') %}
 
 {% set upgrade = pillar.get('nova', {}).get('upgrade', {}) %}
-{% set pin_level = 'auto' %}
+{% set pin_level = pillar.get('nova', {}).get('upgrade', {}).get('old_release','') %}
 
 {% set upgrade_levels = salt['grains.filter_by']({
     'Debian': {
@@ -285,7 +285,7 @@
 {% set compute = salt["grains.filter_by"](compute_defaults, merge=pillar.nova.get("compute", {}), base='BaseDefaults') %}
 
 {%- if pillar.nova.get('upgrade',{}).get('upgrade_enabled',False) %}
-  {% do compute.update(upgrade_levels) %}
+  {% do compute.update({'upgrade_levels': {'compute': 'auto'}}) %}
   {% do controller.update(upgrade_levels) %}
 {%- endif %}