From bff0c02417ca8dbcc07300e96ddfd44b27a1e802 Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Tue, 19 Feb 2019 12:18:33 +0200 Subject: [PATCH] NSX|V3+P: allow removing qos policy from a port Change-Id: I20b53ffa0a467d65f2324ade79b038f076bd241a --- vmware_nsx/plugins/common_v3/plugin.py | 2 +- vmware_nsx/tests/unit/nsx_p/test_plugin.py | 5 +++++ vmware_nsx/tests/unit/nsx_v3/test_plugin.py | 5 +++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/vmware_nsx/plugins/common_v3/plugin.py b/vmware_nsx/plugins/common_v3/plugin.py index 08845e363b..06340f5af1 100644 --- a/vmware_nsx/plugins/common_v3/plugin.py +++ b/vmware_nsx/plugins/common_v3/plugin.py @@ -683,7 +683,7 @@ class NsxPluginV3Base(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, is_new_compute = updated_compute and not orig_compute qos_policy_id = None - if validators.is_attr_set(updated_port.get(qos_consts.QOS_POLICY_ID)): + if qos_consts.QOS_POLICY_ID in updated_port: qos_policy_id = updated_port[qos_consts.QOS_POLICY_ID] elif original_port: # Look for the original QoS policy of this port diff --git a/vmware_nsx/tests/unit/nsx_p/test_plugin.py b/vmware_nsx/tests/unit/nsx_p/test_plugin.py index 52fbb609b5..8b52b0b14d 100644 --- a/vmware_nsx/tests/unit/nsx_p/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_p/test_plugin.py @@ -778,6 +778,11 @@ class NsxPTestPorts(test_db_base_plugin_v2.TestPortsV2, res = self.plugin.get_port(self.ctx, port['id']) self.assertEqual(policy_id, res['qos_policy_id']) + # now remove the qos from the port + data['port']['qos_policy_id'] = None + res = self.plugin.update_port(self.ctx, port['id'], data) + self.assertIsNone(res['qos_policy_id']) + def test_create_ext_port_with_qos_fail(self): with self._create_l3_ext_network() as network: with self.subnet(network=network, cidr='10.0.0.0/24', diff --git a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py index a41eaa3ca6..59fe34158e 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py @@ -1116,6 +1116,11 @@ class TestPortsV2(test_plugin.TestPortsV2, NsxV3PluginTestCaseMixin, res = self.plugin.get_port(self.ctx, port['id']) self.assertEqual(policy_id, res['qos_policy_id']) + # now remove the qos from the port + data['port']['qos_policy_id'] = None + res = self.plugin.update_port(self.ctx, port['id'], data) + self.assertIsNone(res['qos_policy_id']) + def test_create_ext_port_with_qos_fail(self): with self._create_l3_ext_network() as network: with self.subnet(network=network, cidr='10.0.0.0/24'),\