diff --git a/vmware_nsx/shell/admin/plugins/nsxtvd/resources/migrate.py b/vmware_nsx/shell/admin/plugins/nsxtvd/resources/migrate.py index b7e7dcfcd5..a61d6d939a 100644 --- a/vmware_nsx/shell/admin/plugins/nsxtvd/resources/migrate.py +++ b/vmware_nsx/shell/admin/plugins/nsxtvd/resources/migrate.py @@ -12,8 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -import sys - from oslo_config import cfg from oslo_log import log as logging from oslo_serialization import jsonutils @@ -144,8 +142,6 @@ def delete_v_resources(context, objects): try: get_object(context, obj['id']) except exceptions.NotFound: - # prevent logger from logging this exception - sys.exc_clear() continue try: @@ -198,8 +194,7 @@ def create_t_resources(context, objects, ext_net): try: get_object(context, obj['id']) except exceptions.NotFound: - # prevent logger from logging this exception - sys.exc_clear() + pass else: # already exists (this will happen if we rerun from files, # or if the deletion failed) @@ -321,8 +316,7 @@ def create_t_resources(context, objects, ext_net): context, {'security_group_rule': rule_data}) except ext_sg.SecurityGroupRuleExists: # default rules were already created. - # prevent logger from logging this exception - sys.exc_clear() + pass except Exception as e: LOG.error( ">>Failed to create security group %(name)s " @@ -401,7 +395,6 @@ def migrate_v_project_to_t(resource, event, trigger, **kwargs): default="yes") file.close() except Exception: - sys.exc_clear() if from_file: LOG.error("Cannot run from file: files not found") return diff --git a/vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py index b0988d2552..b0c0b0ceda 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/dhcp_binding.py @@ -14,7 +14,6 @@ import pprint -import sys from neutron_lib import context as n_context from oslo_config import cfg @@ -282,8 +281,6 @@ def nsx_recreate_dhcp_edge_by_net_id(net_id): nsxv_manager.vcns.get_edge(edge_id) except exceptions.ResourceNotFound: # No edge on backend - # prevent logger from logging this exception - sys.exc_clear() LOG.info("Edge %s does not exist on the NSX", edge_id) else: LOG.warning("Network %(net_id)s already has a dhcp edge: " diff --git a/vmware_nsx/shell/admin/plugins/nsxv/resources/networks.py b/vmware_nsx/shell/admin/plugins/nsxv/resources/networks.py index cfbd65b763..69c6a565ef 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv/resources/networks.py +++ b/vmware_nsx/shell/admin/plugins/nsxv/resources/networks.py @@ -13,7 +13,6 @@ # under the License. import re -import sys import xml.etree.ElementTree as et from neutron_lib.callbacks import registry @@ -284,7 +283,6 @@ def delete_nsx_portgroups(resource, event, trigger, **kwargs): except Exception as e: LOG.error("Failed to delete portgroup %(pg)s: %(e)s", {'pg': portgroup['moref'], 'e': e}) - sys.exc_clear() else: LOG.info("Successfully deleted portgroup %(pg)s", {'pg': portgroup['moref']}) diff --git a/vmware_nsx/shell/admin/plugins/nsxv3/resources/networks.py b/vmware_nsx/shell/admin/plugins/nsxv3/resources/networks.py index 00deedda48..b72c28582f 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv3/resources/networks.py +++ b/vmware_nsx/shell/admin/plugins/nsxv3/resources/networks.py @@ -12,8 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -import sys - from vmware_nsx.db import db as nsx_db from vmware_nsx.plugins.nsx_v3 import utils as v3_utils from vmware_nsx.shell.admin.plugins.common import constants @@ -100,8 +98,6 @@ def delete_backend_network(resource, event, trigger, **kwargs): try: nsxlib.logical_switch.get(nsx_id, silent=True) except nsx_exc.ResourceNotFound: - # prevent logger from logging this exception - sys.exc_clear() LOG.warning("Backend network %s was not found.", nsx_id) return @@ -118,8 +114,6 @@ def delete_backend_network(resource, event, trigger, **kwargs): try: nsxlib.logical_switch.get(nsx_id, silent=True) except nsx_exc.ResourceNotFound: - # prevent logger from logging this exception - sys.exc_clear() LOG.info("Backend network %s was deleted.", nsx_id) else: LOG.error("Failed to delete backend network %s.", nsx_id) diff --git a/vmware_nsx/shell/admin/plugins/nsxv3/resources/routers.py b/vmware_nsx/shell/admin/plugins/nsxv3/resources/routers.py index 5cba130bc2..e9c601f2d3 100644 --- a/vmware_nsx/shell/admin/plugins/nsxv3/resources/routers.py +++ b/vmware_nsx/shell/admin/plugins/nsxv3/resources/routers.py @@ -12,8 +12,6 @@ # License for the specific language governing permissions and limitations # under the License. -import sys - from neutron.db import db_base_plugin_v2 from neutron.db import l3_db from neutron_lib.callbacks import registry @@ -176,8 +174,6 @@ def delete_backend_router(resource, event, trigger, **kwargs): try: nsxlib.logical_router.get(nsx_id, silent=True) except nsx_exc.ResourceNotFound: - # prevent logger from logging this exception - sys.exc_clear() LOG.warning("Backend router %s was not found.", nsx_id) return @@ -193,8 +189,6 @@ def delete_backend_router(resource, event, trigger, **kwargs): try: nsxlib.logical_router.get(nsx_id, silent=True) except nsx_exc.ResourceNotFound: - # prevent logger from logging this exception - sys.exc_clear() LOG.info("Backend router %s was deleted.", nsx_id) else: LOG.error("Failed to delete backend router %s.", nsx_id)