From 5facde5ed99f45050c457e55622eefb7d4f1e15b Mon Sep 17 00:00:00 2001 From: Adit Sarfaty Date: Wed, 11 Jul 2018 12:11:30 +0300 Subject: [PATCH] NSX|V3 replace deprecated nsxlib apis Depends-on: I887036bad703478247f8c0a47708b0e753ea1dde Change-Id: If651ca52acb8acf8a0eb07f1c7d453a28c387062 --- vmware_nsx/plugins/nsx_v3/plugin.py | 12 ++++++------ .../extensions/test_secgroup_rule_local_ip_prefix.py | 8 ++++---- vmware_nsx/tests/unit/nsx_v3/test_plugin.py | 2 +- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/vmware_nsx/plugins/nsx_v3/plugin.py b/vmware_nsx/plugins/nsx_v3/plugin.py index f5fe3ef9ff..535697ad51 100644 --- a/vmware_nsx/plugins/nsx_v3/plugin.py +++ b/vmware_nsx/plugins/nsx_v3/plugin.py @@ -2888,8 +2888,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, original) nsx_updated = nsx_db.get_nsx_security_group_ids(context.session, updated) - self.nsxlib.ns_group.update_lport( - context, lport_id, nsx_origial, nsx_updated) + self.nsxlib.ns_group.update_lport_nsgroups( + lport_id, nsx_origial, nsx_updated) def base_create_port(self, context, port): neutron_db = super(NsxV3Plugin, self).create_port(context, port) @@ -4751,8 +4751,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, sg_rule['local_ip_prefix'].startswith('0.0.0.0/')): sg_rule['local_ip_prefix'] = None - return self.nsxlib.firewall_section.create_rules( - context, section_id, nsgroup_id, + return self.nsxlib.firewall_section.create_section_rules( + section_id, nsgroup_id, logging_enabled, action, _sg_rules, ruleid_2_remote_nsgroup_map) @@ -4871,8 +4871,8 @@ class NsxV3Plugin(agentschedulers_db.AZDhcpAgentSchedulerDbMixin, try: nsgroup_id, section_id = nsx_db.get_sg_mappings( context.session, id) - self.nsxlib.ns_group.update_on_backend( - context, secgroup_res, nsgroup_id, section_id, + self.nsxlib.ns_group.update_nsgroup_and_section( + secgroup_res, nsgroup_id, section_id, cfg.CONF.nsx_v3.log_security_groups_allowed_traffic) except nsx_lib_exc.ManagerError: with excutils.save_and_reraise_exception(): diff --git a/vmware_nsx/tests/unit/extensions/test_secgroup_rule_local_ip_prefix.py b/vmware_nsx/tests/unit/extensions/test_secgroup_rule_local_ip_prefix.py index b883daf806..51c6c46c21 100644 --- a/vmware_nsx/tests/unit/extensions/test_secgroup_rule_local_ip_prefix.py +++ b/vmware_nsx/tests/unit/extensions/test_secgroup_rule_local_ip_prefix.py @@ -130,7 +130,8 @@ class TestNSXv3ExtendedSGRule(test_nsxv3_plugin.NsxV3PluginTestCaseMixin, 'description': ''}] with mock.patch( - "vmware_nsxlib.v3.security.NsxLibFirewallSection.create_rules", + "vmware_nsxlib.v3.security.NsxLibFirewallSection." + "create_section_rules", side_effect=test_nsxv3_plugin._mock_create_firewall_rules, ) as mock_rule: @@ -138,7 +139,6 @@ class TestNSXv3ExtendedSGRule(test_nsxv3_plugin.NsxV3PluginTestCaseMixin, self).test_create_rule_with_local_ip_prefix() mock_rule.assert_called_with( - mock.ANY, # content mock.ANY, # firewall_section_id mock.ANY, # ns_group_id False, # logging @@ -173,12 +173,12 @@ class TestNSXv3ExtendedSGRule(test_nsxv3_plugin.NsxV3PluginTestCaseMixin, 'description': ''}] with mock.patch( - "vmware_nsxlib.v3.security.NsxLibFirewallSection.create_rules", + "vmware_nsxlib.v3.security.NsxLibFirewallSection." + "create_section_rules", side_effect=test_nsxv3_plugin._mock_create_firewall_rules, ) as mock_rule: self.test_create_rule_with_remote_ip_prefix() mock_rule.assert_called_with( - mock.ANY, # content mock.ANY, # firewall_section_id mock.ANY, # ns_group_id False, # logging diff --git a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py index 9945730530..66b6fe2720 100644 --- a/vmware_nsx/tests/unit/nsx_v3/test_plugin.py +++ b/vmware_nsx/tests/unit/nsx_v3/test_plugin.py @@ -74,7 +74,7 @@ NSX_DHCP_RELAY_SRV = 'dhcp relay srv' def _mock_create_firewall_rules(*args): # NOTE(arosen): the code in the neutron plugin expects the # neutron rule id as the display_name. - rules = args[5] + rules = args[4] return { 'rules': [ {'display_name': rule['id'], 'id': uuidutils.generate_uuid()}