From 3c2553b0552ae2dd48c5de0e47d17196d0916f8d Mon Sep 17 00:00:00 2001 From: Edward Hope-Morley Date: Thu, 24 Aug 2017 12:32:38 +0100 Subject: [PATCH] Add deprecation notice for prevent-arp-spoofing Config option will have no effect for >= Ocata. Also adds log WARNING. Change-Id: I06b78152a9e42e5411d6a426073641ce474573ff Closes-Bug: 1691080 --- config.yaml | 4 ++++ hooks/neutron_ovs_context.py | 18 ++++++++++++++++-- hooks/neutron_ovs_utils.py | 4 +--- unit_tests/test_neutron_ovs_context.py | 12 ++++++++++-- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/config.yaml b/config.yaml index 5afc2490..1b03780d 100644 --- a/config.yaml +++ b/config.yaml @@ -142,6 +142,10 @@ options: . Only supported in OpenStack Liberty or newer, which has the required minimum version of Open vSwitch. + . + NOTE: this feature is deprecated and removed in Openstack >= Ocata. As of + that point the only way to disable protection will be via the port + security extension (see LP 1691080 for info). enable-dpdk: type: boolean default: false diff --git a/hooks/neutron_ovs_context.py b/hooks/neutron_ovs_context.py index 8d5df6b1..0b03de4d 100644 --- a/hooks/neutron_ovs_context.py +++ b/hooks/neutron_ovs_context.py @@ -18,6 +18,8 @@ import uuid from pci import PCINetDevices from charmhelpers.core.hookenv import ( config, + log, + WARNING, relation_get, relation_ids, related_units, @@ -29,8 +31,12 @@ from charmhelpers.core.host import ( lsb_release, ) from charmhelpers.contrib.openstack import context -from charmhelpers.contrib.openstack.utils import get_host_ip -from charmhelpers.contrib.openstack.utils import config_flags_parser +from charmhelpers.contrib.openstack.utils import ( + config_flags_parser, + get_host_ip, + os_release, + CompareOpenStackReleases, +) from charmhelpers.contrib.network.ip import get_address_in_network from charmhelpers.contrib.openstack.context import ( OSContextGenerator, @@ -123,6 +129,14 @@ class OVSPluginContext(context.NeutronContext): ovs_ctxt['use_syslog'] = conf['use-syslog'] ovs_ctxt['verbose'] = conf['verbose'] ovs_ctxt['debug'] = conf['debug'] + + cmp_release = CompareOpenStackReleases( + os_release('neutron-common', base='icehouse')) + if conf['prevent-arp-spoofing'] and cmp_release >= 'ocata': + log("prevent-arp-spoofing is True yet this feature is deprecated " + "and no longer has any effect in your version of Openstack", + WARNING) + ovs_ctxt['prevent_arp_spoofing'] = conf['prevent-arp-spoofing'] ovs_ctxt['enable_dpdk'] = conf['enable-dpdk'] diff --git a/hooks/neutron_ovs_utils.py b/hooks/neutron_ovs_utils.py index 0fece95b..1c5e0735 100644 --- a/hooks/neutron_ovs_utils.py +++ b/hooks/neutron_ovs_utils.py @@ -35,11 +35,9 @@ from charmhelpers.contrib.openstack.utils import ( os_application_version_set, remote_restart, CompareOpenStackReleases, -) -from collections import OrderedDict -from charmhelpers.contrib.openstack.utils import ( os_release, ) +from collections import OrderedDict import neutron_ovs_context from charmhelpers.contrib.network.ovs import ( add_bridge, diff --git a/unit_tests/test_neutron_ovs_context.py b/unit_tests/test_neutron_ovs_context.py index d54a8bcf..a72d6a77 100644 --- a/unit_tests/test_neutron_ovs_context.py +++ b/unit_tests/test_neutron_ovs_context.py @@ -96,6 +96,8 @@ class OVSPluginContextTest(CharmTestCase): {'em1': 'br-d2'} ) + @patch.object(charmhelpers.contrib.openstack.utils, + 'get_os_codename_package') @patch.object(charmhelpers.contrib.openstack.context, 'config', lambda *args: None) @patch.object(charmhelpers.contrib.openstack.context, 'relation_get') @@ -112,7 +114,8 @@ class OVSPluginContextTest(CharmTestCase): @patch.object(charmhelpers.contrib.openstack.context, 'unit_private_ip') def test_neutroncc_context_api_rel(self, _unit_priv_ip, _npa, _ens_pkgs, _save_ff, _https, _is_clus, _unit_get, - _config, _runits, _rids, _rget): + _config, _runits, _rids, _rget, + _get_os_cdnm_pkg): def mock_npa(plugin, section, manager): if section == "driver": return "neutron.randomdriver" @@ -134,6 +137,7 @@ class OVSPluginContextTest(CharmTestCase): return config + _get_os_cdnm_pkg.return_value = 'ocata' self.maxDiff = None self.config.side_effect = mock_config _npa.side_effect = mock_npa @@ -180,6 +184,8 @@ class OVSPluginContextTest(CharmTestCase): } self.assertEquals(expect, napi_ctxt()) + @patch.object(charmhelpers.contrib.openstack.utils, + 'get_os_codename_package') @patch.object(charmhelpers.contrib.openstack.context, 'relation_get') @patch.object(charmhelpers.contrib.openstack.context, 'relation_ids') @patch.object(charmhelpers.contrib.openstack.context, 'related_units') @@ -198,13 +204,15 @@ class OVSPluginContextTest(CharmTestCase): _https, _is_clus, _unit_get, _config, _runits, - _rids, _rget): + _rids, _rget, + _get_os_cdnm_pkg): def mock_npa(plugin, section, manager): if section == "driver": return "neutron.randomdriver" if section == "config": return "neutron.randomconfig" + _get_os_cdnm_pkg.return_value = 'ocata' _npa.side_effect = mock_npa _config.return_value = 'ovs' _unit_get.return_value = '127.0.0.13'