diff --git a/vmware_nsx/db/nsxv_db.py b/vmware_nsx/db/nsxv_db.py index ebc7620685..5077a6f5f9 100644 --- a/vmware_nsx/db/nsxv_db.py +++ b/vmware_nsx/db/nsxv_db.py @@ -683,6 +683,11 @@ def get_nsxv_spoofguard_policy_network_mappings(session, filters=None, filters, like_filters).all() +def del_nsxv_spoofguard_binding(session, policy_id): + return (session.query(nsxv_models.NsxvSpoofGuardPolicyNetworkMapping). + filter_by(policy_id=policy_id).delete()) + + def add_nsxv_lbaas_loadbalancer_binding( session, loadbalancer_id, edge_id, edge_fw_rule_id, vip_address): with session.begin(subtransactions=True): diff --git a/vmware_nsx/plugins/nsx_v/plugin.py b/vmware_nsx/plugins/nsx_v/plugin.py index ae7005410e..f4507449c7 100644 --- a/vmware_nsx/plugins/nsx_v/plugin.py +++ b/vmware_nsx/plugins/nsx_v/plugin.py @@ -1763,6 +1763,8 @@ class NsxVPluginV2(addr_pair_db.AllowedAddressPairsMixin, if sg_policy: try: self.nsx_v.vcns.delete_spoofguard_policy(sg_policy) + nsxv_db.del_nsxv_spoofguard_binding(context.session, + sg_policy) except Exception as e: LOG.error('Unable to delete spoofguard policy ' '%(sg_policy)s. Error: %(e)s',