diff --git a/nova/virt/baremetal/db/sqlalchemy/api.py b/nova/virt/baremetal/db/sqlalchemy/api.py index 2e1b8f2914..88d44e3d30 100644 --- a/nova/virt/baremetal/db/sqlalchemy/api.py +++ b/nova/virt/baremetal/db/sqlalchemy/api.py @@ -397,7 +397,7 @@ def bm_interface_set_vif_uuid(context, if_id, vif_uuid): try: session.add(bm_interface) session.flush() - except db_exc.DBError, e: + except db_exc.DBError as e: # TODO(deva): clean up when db layer raises DuplicateKeyError if str(e).find('IntegrityError') != -1: raise exception.NovaException(_("Baremetal interface %s " diff --git a/nova/virt/baremetal/driver.py b/nova/virt/baremetal/driver.py index 8e5559533c..cd07598bdc 100755 --- a/nova/virt/baremetal/driver.py +++ b/nova/virt/baremetal/driver.py @@ -307,7 +307,7 @@ class BareMetalDriver(driver.ComputeDriver): self._unplug_vifs(instance, network_info) _update_state(context, node, None, baremetal_states.DELETED) - except Exception, e: + except Exception as e: with excutils.save_and_reraise_exception(): try: LOG.error(_("Error from baremetal driver " diff --git a/nova/virt/baremetal/utils.py b/nova/virt/baremetal/utils.py index fa2c059833..b18bfac857 100644 --- a/nova/virt/baremetal/utils.py +++ b/nova/virt/baremetal/utils.py @@ -45,7 +45,7 @@ def inject_into_image(image, key, net, metadata, admin_password, def unlink_without_raise(path): try: os.unlink(path) - except OSError, e: + except OSError as e: if e.errno == errno.ENOENT: return else: @@ -56,7 +56,7 @@ def rmtree_without_raise(path): try: if os.path.isdir(path): shutil.rmtree(path) - except OSError, e: + except OSError as e: LOG.warn(_("Failed to remove dir %(path)s, error: %(e)s") % locals()) @@ -68,7 +68,7 @@ def write_to_file(path, contents): def create_link_without_raise(source, link): try: os.symlink(source, link) - except OSError, e: + except OSError as e: if e.errno == errno.EEXIST: return else: