Adding ability to configure passthrough_whitelist and alias parameters

The patch gets key:value located under nova:compute:sriov:nic_name and
nova:<role>:pci:alias:<alias1>...<aliasN> puts it to nova.conf in appropirate
format for passthrough_whitelist and alias parameters.

Change-Id: I83f505658f9e8d241a9f31b5ddc4ba7089bc51cb
Related-PROD: PROD-23653 (PROD:23653)
diff --git a/README.rst b/README.rst
index 50e90cb..1d4595c 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
@@ -442,6 +470,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
@@ -561,6 +603,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 48b5ec3..e272b50 100644
--- a/nova/files/pike/nova-compute.conf.Debian
+++ b/nova/files/pike/nova-compute.conf.Debian
@@ -8296,6 +8296,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.
@@ -8362,9 +8367,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 443bcaa..4ceefeb 100644
--- a/nova/files/pike/nova-controller.conf.Debian
+++ b/nova/files/pike/nova-controller.conf.Debian
@@ -8260,6 +8260,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 66705ba..9bb8307 100644
--- a/nova/files/queens/nova-controller.conf.Debian
+++ b/nova/files/queens/nova-controller.conf.Debian
@@ -8080,6 +8080,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.