NSX|P: Fix port security update for network

Change-Id: Id576ea0bc2e9c3dff1f1ba683ba26f1e30dded44
This commit is contained in:
asarfaty 2020-04-10 17:55:10 +02:00
parent 75cfea2619
commit 9b36336e21
3 changed files with 43 additions and 0 deletions

View File

@ -882,6 +882,9 @@ class NsxPolicyPlugin(nsx_plugin_common.NsxPluginV3Base):
context, network_id, network)
self._extension_manager.process_update_network(context, net_data,
updated_net)
if psec.PORTSECURITY in net_data:
self._process_network_port_security_update(
context, net_data, updated_net)
self._process_l3_update(context, updated_net, network['network'])
self._extend_network_dict_provider(context, updated_net)

View File

@ -568,6 +568,26 @@ class NsxPTestNetworks(test_db_base_plugin_v2.TestNetworksV2,
network['id'], data)
self.assertEqual(policy_id, res['qos_policy_id'])
def test_update_network_port_sec(self):
data = {'network': {
'name': 'psec_net',
'tenant_id': 'some_tenant',
'admin_state_up': True,
'shared': False,
'port_security_enabled': True}}
network = self.plugin.create_network(context.get_admin_context(),
data)
self.assertEqual(True, network['port_security_enabled'])
data = {'network': {
'id': network['id'],
'admin_state_up': True,
'shared': False,
'port_security_enabled': False,
'tenant_id': 'some_tenant'}}
res = self.plugin.update_network(context.get_admin_context(),
network['id'], data)
self.assertEqual(False, res['port_security_enabled'])
class NsxPTestPorts(common_v3.NsxV3TestPorts,
common_v3.NsxV3SubnetMixin,

View File

@ -827,6 +827,26 @@ class TestNetworksV2(test_plugin.TestNetworksV2, NsxV3PluginTestCaseMixin):
self.assertEqual('InvalidInput',
res['NeutronError']['type'])
def test_update_network_port_sec(self):
data = {'network': {
'name': 'psec_net',
'tenant_id': 'some_tenant',
'admin_state_up': True,
'shared': False,
'port_security_enabled': True}}
network = self.plugin.create_network(context.get_admin_context(),
data)
self.assertEqual(True, network['port_security_enabled'])
data = {'network': {
'id': network['id'],
'admin_state_up': True,
'shared': False,
'port_security_enabled': False,
'tenant_id': 'some_tenant'}}
res = self.plugin.update_network(context.get_admin_context(),
network['id'], data)
self.assertEqual(False, res['port_security_enabled'])
class TestSubnetsV2(common_v3.NsxV3TestSubnets, NsxV3PluginTestCaseMixin):