Stop using sys.exc_clear as it is not supported in python3

Change-Id: Ic0a37116e31fb41919bc2d84d9d609127a97a3c1
This commit is contained in:
asarfaty 2020-05-11 11:25:04 +02:00 committed by Adit Sarfaty
parent 2699a05875
commit c10c03d192
5 changed files with 2 additions and 26 deletions

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import sys
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from oslo_serialization import jsonutils from oslo_serialization import jsonutils
@ -144,8 +142,6 @@ def delete_v_resources(context, objects):
try: try:
get_object(context, obj['id']) get_object(context, obj['id'])
except exceptions.NotFound: except exceptions.NotFound:
# prevent logger from logging this exception
sys.exc_clear()
continue continue
try: try:
@ -198,8 +194,7 @@ def create_t_resources(context, objects, ext_net):
try: try:
get_object(context, obj['id']) get_object(context, obj['id'])
except exceptions.NotFound: except exceptions.NotFound:
# prevent logger from logging this exception pass
sys.exc_clear()
else: else:
# already exists (this will happen if we rerun from files, # already exists (this will happen if we rerun from files,
# or if the deletion failed) # or if the deletion failed)
@ -321,8 +316,7 @@ def create_t_resources(context, objects, ext_net):
context, {'security_group_rule': rule_data}) context, {'security_group_rule': rule_data})
except ext_sg.SecurityGroupRuleExists: except ext_sg.SecurityGroupRuleExists:
# default rules were already created. # default rules were already created.
# prevent logger from logging this exception pass
sys.exc_clear()
except Exception as e: except Exception as e:
LOG.error( LOG.error(
">>Failed to create security group %(name)s " ">>Failed to create security group %(name)s "
@ -401,7 +395,6 @@ def migrate_v_project_to_t(resource, event, trigger, **kwargs):
default="yes") default="yes")
file.close() file.close()
except Exception: except Exception:
sys.exc_clear()
if from_file: if from_file:
LOG.error("Cannot run from file: files not found") LOG.error("Cannot run from file: files not found")
return return

View File

@ -14,7 +14,6 @@
import pprint import pprint
import sys
from neutron_lib import context as n_context from neutron_lib import context as n_context
from oslo_config import cfg 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) nsxv_manager.vcns.get_edge(edge_id)
except exceptions.ResourceNotFound: except exceptions.ResourceNotFound:
# No edge on backend # 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) LOG.info("Edge %s does not exist on the NSX", edge_id)
else: else:
LOG.warning("Network %(net_id)s already has a dhcp edge: " LOG.warning("Network %(net_id)s already has a dhcp edge: "

View File

@ -13,7 +13,6 @@
# under the License. # under the License.
import re import re
import sys
import xml.etree.ElementTree as et import xml.etree.ElementTree as et
from neutron_lib.callbacks import registry from neutron_lib.callbacks import registry
@ -284,7 +283,6 @@ def delete_nsx_portgroups(resource, event, trigger, **kwargs):
except Exception as e: except Exception as e:
LOG.error("Failed to delete portgroup %(pg)s: %(e)s", LOG.error("Failed to delete portgroup %(pg)s: %(e)s",
{'pg': portgroup['moref'], 'e': e}) {'pg': portgroup['moref'], 'e': e})
sys.exc_clear()
else: else:
LOG.info("Successfully deleted portgroup %(pg)s", LOG.info("Successfully deleted portgroup %(pg)s",
{'pg': portgroup['moref']}) {'pg': portgroup['moref']})

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import sys
from vmware_nsx.db import db as nsx_db from vmware_nsx.db import db as nsx_db
from vmware_nsx.plugins.nsx_v3 import utils as v3_utils from vmware_nsx.plugins.nsx_v3 import utils as v3_utils
from vmware_nsx.shell.admin.plugins.common import constants from vmware_nsx.shell.admin.plugins.common import constants
@ -100,8 +98,6 @@ def delete_backend_network(resource, event, trigger, **kwargs):
try: try:
nsxlib.logical_switch.get(nsx_id, silent=True) nsxlib.logical_switch.get(nsx_id, silent=True)
except nsx_exc.ResourceNotFound: except nsx_exc.ResourceNotFound:
# prevent logger from logging this exception
sys.exc_clear()
LOG.warning("Backend network %s was not found.", nsx_id) LOG.warning("Backend network %s was not found.", nsx_id)
return return
@ -118,8 +114,6 @@ def delete_backend_network(resource, event, trigger, **kwargs):
try: try:
nsxlib.logical_switch.get(nsx_id, silent=True) nsxlib.logical_switch.get(nsx_id, silent=True)
except nsx_exc.ResourceNotFound: except nsx_exc.ResourceNotFound:
# prevent logger from logging this exception
sys.exc_clear()
LOG.info("Backend network %s was deleted.", nsx_id) LOG.info("Backend network %s was deleted.", nsx_id)
else: else:
LOG.error("Failed to delete backend network %s.", nsx_id) LOG.error("Failed to delete backend network %s.", nsx_id)

View File

@ -12,8 +12,6 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
import sys
from neutron.db import db_base_plugin_v2 from neutron.db import db_base_plugin_v2
from neutron.db import l3_db from neutron.db import l3_db
from neutron_lib.callbacks import registry from neutron_lib.callbacks import registry
@ -176,8 +174,6 @@ def delete_backend_router(resource, event, trigger, **kwargs):
try: try:
nsxlib.logical_router.get(nsx_id, silent=True) nsxlib.logical_router.get(nsx_id, silent=True)
except nsx_exc.ResourceNotFound: except nsx_exc.ResourceNotFound:
# prevent logger from logging this exception
sys.exc_clear()
LOG.warning("Backend router %s was not found.", nsx_id) LOG.warning("Backend router %s was not found.", nsx_id)
return return
@ -193,8 +189,6 @@ def delete_backend_router(resource, event, trigger, **kwargs):
try: try:
nsxlib.logical_router.get(nsx_id, silent=True) nsxlib.logical_router.get(nsx_id, silent=True)
except nsx_exc.ResourceNotFound: except nsx_exc.ResourceNotFound:
# prevent logger from logging this exception
sys.exc_clear()
LOG.info("Backend router %s was deleted.", nsx_id) LOG.info("Backend router %s was deleted.", nsx_id)
else: else:
LOG.error("Failed to delete backend router %s.", nsx_id) LOG.error("Failed to delete backend router %s.", nsx_id)