From 03b84bc920b5499e1fef23c646268fffa1d859d7 Mon Sep 17 00:00:00 2001
From: Edan David <edand@mellanox.com>
Date: Tue, 8 Nov 2016 10:30:45 -0500
Subject: [PATCH] Deprecate SR-IOV 'physical_device_mappings' config option

The device to physnet validation is made in Nova by pci_whitelist config option.
Therefore it is redundant to validate it in Neutron with physical_device_mappings
config option.

Closes-Bug: #1640220
DocImpact

Change-Id: I5f363347b327212a49a9b78a7164c11d9e457b10
---
 .../plugins/ml2/drivers/mech_sriov/agent/common/config.py  | 5 ++++-
 .../ml2/drivers/mech_sriov/agent/eswitch_manager.py        | 4 ++++
 .../ml2/drivers/mech_sriov/agent/sriov_nic_agent.py        | 2 ++
 ...te-SRIOV-physical_deivce_mappings-67dd3317181eb513.yaml | 7 +++++++
 4 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 releasenotes/notes/deprecate-SRIOV-physical_deivce_mappings-67dd3317181eb513.yaml

diff --git a/neutron/plugins/ml2/drivers/mech_sriov/agent/common/config.py b/neutron/plugins/ml2/drivers/mech_sriov/agent/common/config.py
index 1173d8a9aa2..edfeb29d09e 100644
--- a/neutron/plugins/ml2/drivers/mech_sriov/agent/common/config.py
+++ b/neutron/plugins/ml2/drivers/mech_sriov/agent/common/config.py
@@ -70,7 +70,10 @@ sriov_nic_opts = [
                        "function to be used for VLAN networks. All physical "
                        "networks listed in network_vlan_ranges on the server "
                        "should have mappings to appropriate interfaces on "
-                       "each agent.")),
+                       "each agent. "
+                       "DEPRECATED: This option is deprecated in the Ocata "
+                       "release and will be removed in the Pike release."),
+                deprecated_for_removal=True),
     cfg.ListOpt('exclude_devices',
                 default=DEFAULT_EXCLUDE_DEVICES,
                 help=_("Comma-separated list of "
diff --git a/neutron/plugins/ml2/drivers/mech_sriov/agent/eswitch_manager.py b/neutron/plugins/ml2/drivers/mech_sriov/agent/eswitch_manager.py
index 8ee070a479e..0f3fe766503 100644
--- a/neutron/plugins/ml2/drivers/mech_sriov/agent/eswitch_manager.py
+++ b/neutron/plugins/ml2/drivers/mech_sriov/agent/eswitch_manager.py
@@ -347,6 +347,8 @@ class ESwitchManager(object):
             embedded_switch.set_device_spoofcheck(pci_slot,
                                                   enabled)
 
+    # Note(edan): discover_devices method will be removed
+    # with 'physical_device_mappings'
     def discover_devices(self, device_mappings, exclude_devices):
         """Discover which Virtual functions to manage.
 
@@ -361,6 +363,8 @@ class ESwitchManager(object):
                 self._create_emb_switch(phys_net, dev_name,
                                         exclude_devices.get(dev_name, set()))
 
+    # Note(edan): phys_net param will be removed with
+    # 'physical_device_mappings' config option.
     def _create_emb_switch(self, phys_net, dev_name, exclude_devices):
         embedded_switch = EmbSwitch(phys_net, dev_name, exclude_devices)
         self.emb_switches_map.setdefault(phys_net, []).append(embedded_switch)
diff --git a/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py b/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py
index 7e02f755b90..17a805ae42f 100644
--- a/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py
+++ b/neutron/plugins/ml2/drivers/mech_sriov/agent/sriov_nic_agent.py
@@ -191,6 +191,8 @@ class SriovNicSwitchAgent(object):
         mgr.initialize(connection, 'sriov')
         return mgr
 
+    # Note(edan): setup_eswitch_mgr method will be removed
+    # with 'physical_device_mappings' config option
     def setup_eswitch_mgr(self, device_mappings, exclude_devices=None):
         exclude_devices = exclude_devices or {}
         self.eswitch_mgr = esm.ESwitchManager()
diff --git a/releasenotes/notes/deprecate-SRIOV-physical_deivce_mappings-67dd3317181eb513.yaml b/releasenotes/notes/deprecate-SRIOV-physical_deivce_mappings-67dd3317181eb513.yaml
new file mode 100644
index 00000000000..7d4ad6f1c0a
--- /dev/null
+++ b/releasenotes/notes/deprecate-SRIOV-physical_deivce_mappings-67dd3317181eb513.yaml
@@ -0,0 +1,7 @@
+---
+deprecations:
+  - The 'physical_device_mappings' option is deprecated
+    and will be removed in Pike. The PCI device validation
+    is made in Nova with the 'pci_whitelist' config option.
+    Therefore it is redundant to validate it in Neutron
+    with physical_device_mappings.