From 6fd74aee8dbb3e52bda5d47e348c11af5e758fa4 Mon Sep 17 00:00:00 2001 From: Roey Chen Date: Thu, 4 Aug 2016 07:13:57 -0700 Subject: [PATCH] NSXv3: Raise the proper exception if nsgroup doesn't exists Change-Id: I0cfb7314d0d1119be3b6217b86bf7f5df23b6b09 --- vmware_nsx/nsxlib/v3/dfw_api.py | 2 +- vmware_nsx/nsxlib/v3/security.py | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/vmware_nsx/nsxlib/v3/dfw_api.py b/vmware_nsx/nsxlib/v3/dfw_api.py index 1fdafd1bd9..6a83f97f72 100644 --- a/vmware_nsx/nsxlib/v3/dfw_api.py +++ b/vmware_nsx/nsxlib/v3/dfw_api.py @@ -143,7 +143,7 @@ def add_nsgroup_member(nsgroup_id, target_type, target_id): members = {'members': [member_expr]} try: return _update_nsgroup_with_members(nsgroup_id, members, ADD_MEMBERS) - except nsx_exc.StaleRevision: + except (nsx_exc.StaleRevision, nsx_exc.ResourceNotFound): raise except nsx_exc.ManagerError: # REVISIT(roeyc): A ManagerError might have been raised for a diff --git a/vmware_nsx/nsxlib/v3/security.py b/vmware_nsx/nsxlib/v3/security.py index eb793892fe..4349b9f05a 100644 --- a/vmware_nsx/nsxlib/v3/security.py +++ b/vmware_nsx/nsxlib/v3/security.py @@ -23,8 +23,9 @@ import uuid from neutron_lib import constants from oslo_config import cfg from oslo_log import log +from oslo_utils import excutils -from vmware_nsx._i18n import _, _LW +from vmware_nsx._i18n import _, _LW, _LE from vmware_nsx.common import exceptions as nsx_exc from vmware_nsx.common import utils from vmware_nsx.db import nsx_models @@ -262,6 +263,9 @@ def update_lport_with_security_groups(context, lport_id, original, updated): firewall.remove_nsgroup_member( nsgroup_id, firewall.LOGICAL_PORT, lport_id) raise nsx_exc.SecurityGroupMaximumCapacityReached(sg_id=sg_id) + except nsx_exc.ResourceNotFound: + with excutils.save_and_reraise_exception(): + LOG.error(_LE("NSGroup %s doesn't exists"), nsgroup_id) for sg_id in removed: nsgroup_id, s = get_sg_mappings(context.session, sg_id) firewall.remove_nsgroup_member(