Merge "Improve Python 3.x compatibility"
This commit is contained in:
commit
d9c4623870
@ -655,11 +655,11 @@ class DhcpLeaseRelay(object):
|
||||
ip_address = str(netaddr.IPAddress(data['ip_address']))
|
||||
lease_remaining = int(data['lease_remaining'])
|
||||
self.callback(network_id, ip_address, lease_remaining)
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
LOG.warn(_('Unable to parse lease relay msg to dict.'))
|
||||
LOG.warn(_('Exception value: %s'), e)
|
||||
LOG.warn(_('Message representation: %s'), repr(msg))
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
LOG.exception(_('Unable update lease. Exception'))
|
||||
|
||||
def start(self):
|
||||
|
@ -64,7 +64,7 @@ class OVSBridge:
|
||||
full_args = ["ovs-vsctl", "--timeout=2"] + args
|
||||
try:
|
||||
return utils.execute(full_args, root_helper=self.root_helper)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
LOG.error(_("Unable to execute %(cmd)s. Exception: %(exception)s"),
|
||||
{'cmd': full_args, 'exception': e})
|
||||
|
||||
@ -93,7 +93,7 @@ class OVSBridge:
|
||||
full_args = ["ovs-ofctl", cmd, self.br_name] + args
|
||||
try:
|
||||
return utils.execute(full_args, root_helper=self.root_helper)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
LOG.error(_("Unable to execute %(cmd)s. Exception: %(exception)s"),
|
||||
{'cmd': full_args, 'exception': e})
|
||||
|
||||
@ -215,7 +215,7 @@ class OVSBridge:
|
||||
"param-key=nicira-iface-id", "uuid=%s" % xs_vif_uuid]
|
||||
try:
|
||||
return utils.execute(args, root_helper=self.root_helper).strip()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
LOG.error(_("Unable to execute %(cmd)s. Exception: %(exception)s"),
|
||||
{'cmd': args, 'exception': e})
|
||||
|
||||
@ -270,7 +270,7 @@ class OVSBridge:
|
||||
port_name = match.group('port_name')
|
||||
ofport = int(match.group('ofport'))
|
||||
return VifPort(port_name, ofport, vif_id, vif_mac, self)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
LOG.info(_("Unable to parse regex results. Exception: %s"), e)
|
||||
return
|
||||
|
||||
@ -297,6 +297,6 @@ def get_bridges(root_helper):
|
||||
args = ["ovs-vsctl", "--timeout=2", "list-br"]
|
||||
try:
|
||||
return utils.execute(args, root_helper=root_helper).strip().split("\n")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
LOG.exception(_("Unable to retrieve bridges. Exception: %s"), e)
|
||||
return []
|
||||
|
@ -86,7 +86,7 @@ class MySQLPingListener(object):
|
||||
def checkout(self, dbapi_con, con_record, con_proxy):
|
||||
try:
|
||||
dbapi_con.cursor().execute('select 1')
|
||||
except dbapi_con.OperationalError, ex:
|
||||
except dbapi_con.OperationalError as ex:
|
||||
if ex.args[0] in (2006, 2013, 2014, 2045, 2055):
|
||||
LOG.warn(_('Got mysql server has gone away: %s'), ex)
|
||||
raise DisconnectionError(_("Database server went away"))
|
||||
|
@ -51,7 +51,7 @@ CONF.register_opts(_quota_opts, 'QUOTAS')
|
||||
def do_alembic_command(config, cmd, *args, **kwargs):
|
||||
try:
|
||||
getattr(alembic_command, cmd)(config, *args, **kwargs)
|
||||
except alembic_util.CommandError, e:
|
||||
except alembic_util.CommandError as e:
|
||||
alembic_util.err(str(e))
|
||||
|
||||
|
||||
|
@ -282,7 +282,7 @@ class InternalContext(object):
|
||||
except greenlet.GreenletExit:
|
||||
# ignore these since they are just from shutdowns
|
||||
pass
|
||||
except rpc_common.ClientException, e:
|
||||
except rpc_common.ClientException as e:
|
||||
LOG.debug(_("Expected exception during message handling (%s)") %
|
||||
e._exc_info[1])
|
||||
return {'exc':
|
||||
|
@ -42,7 +42,7 @@ class NexusDB(object):
|
||||
bind_dict["port-id"] = str(bind.port_id)
|
||||
bind_dict["vlan-id"] = str(bind.vlan_id)
|
||||
bindings.append(bind_dict)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to get all bindings: %s" % str(exc))
|
||||
return bindings
|
||||
|
||||
@ -56,7 +56,7 @@ class NexusDB(object):
|
||||
bind_dict["port-id"] = str(bind.port_id)
|
||||
bind_dict["vlan-id"] = str(bind.vlan_id)
|
||||
binding.append(bind_dict)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to get all bindings: %s" % str(exc))
|
||||
return binding
|
||||
|
||||
@ -69,7 +69,7 @@ class NexusDB(object):
|
||||
bind_dict["port-id"] = str(res.port_id)
|
||||
bind_dict["vlan-id"] = str(res.vlan_id)
|
||||
return bind_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to create nexus binding: %s" % str(exc))
|
||||
|
||||
def delete_nexusportbinding(self, vlan_id):
|
||||
@ -83,7 +83,7 @@ class NexusDB(object):
|
||||
bind_dict["port-id"] = res.port_id
|
||||
bindings.append(bind_dict)
|
||||
return bindings
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
raise Exception("Failed to delete nexus port binding: %s"
|
||||
% str(exc))
|
||||
|
||||
@ -96,7 +96,7 @@ class NexusDB(object):
|
||||
bind_dict["port-id"] = str(res.port_id)
|
||||
bind_dict["vlan-id"] = str(res.vlan_id)
|
||||
return bind_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
raise Exception("Failed to update nexus port binding vnic: %s"
|
||||
% str(exc))
|
||||
|
||||
@ -115,7 +115,7 @@ class L2networkDB(object):
|
||||
vlan_dict["vlan-name"] = vlan_bind.vlan_name
|
||||
vlan_dict["net-id"] = str(vlan_bind.network_id)
|
||||
vlans.append(vlan_dict)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to get all vlan bindings: %s" % str(exc))
|
||||
return vlans
|
||||
|
||||
@ -131,7 +131,7 @@ class L2networkDB(object):
|
||||
vlan_dict["vlan-name"] = vlan_bind.vlan_name
|
||||
vlan_dict["net-id"] = str(vlan_bind.network_id)
|
||||
vlan.append(vlan_dict)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to get vlan binding: %s" % str(exc))
|
||||
return vlan
|
||||
|
||||
@ -145,7 +145,7 @@ class L2networkDB(object):
|
||||
vlan_dict["vlan-name"] = res.vlan_name
|
||||
vlan_dict["net-id"] = str(res.network_id)
|
||||
return vlan_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to create vlan binding: %s" % str(exc))
|
||||
|
||||
def delete_vlan_binding(self, network_id):
|
||||
@ -156,7 +156,7 @@ class L2networkDB(object):
|
||||
vlan_dict = {}
|
||||
vlan_dict["vlan-id"] = str(res.vlan_id)
|
||||
return vlan_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
raise Exception("Failed to delete vlan binding: %s" % str(exc))
|
||||
|
||||
def update_vlan_binding(self, network_id, vlan_id, vlan_name):
|
||||
@ -170,7 +170,7 @@ class L2networkDB(object):
|
||||
vlan_dict["vlan-name"] = res.vlan_name
|
||||
vlan_dict["net-id"] = str(res.network_id)
|
||||
return vlan_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
raise Exception("Failed to update vlan binding: %s" % str(exc))
|
||||
|
||||
|
||||
@ -187,7 +187,7 @@ class QuantumDB(object):
|
||||
net_dict["net-id"] = str(net.uuid)
|
||||
net_dict["net-name"] = net.name
|
||||
nets.append(net_dict)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to get all networks: %s" % str(exc))
|
||||
return nets
|
||||
|
||||
@ -202,7 +202,7 @@ class QuantumDB(object):
|
||||
net_dict["net-id"] = str(net.uuid)
|
||||
net_dict["net-name"] = net.name
|
||||
net.append(net_dict)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to get network: %s" % str(exc))
|
||||
return net
|
||||
|
||||
@ -216,7 +216,7 @@ class QuantumDB(object):
|
||||
net_dict["net-id"] = str(res.uuid)
|
||||
net_dict["net-name"] = res.name
|
||||
return net_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to create network: %s" % str(exc))
|
||||
|
||||
def delete_network(self, net_id):
|
||||
@ -227,7 +227,7 @@ class QuantumDB(object):
|
||||
net_dict = {}
|
||||
net_dict["net-id"] = str(net.uuid)
|
||||
return net_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
raise Exception("Failed to delete port: %s" % str(exc))
|
||||
|
||||
def update_network(self, tenant_id, net_id, **kwargs):
|
||||
@ -239,7 +239,7 @@ class QuantumDB(object):
|
||||
net_dict["net-id"] = str(net.uuid)
|
||||
net_dict["net-name"] = net.name
|
||||
return net_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
raise Exception("Failed to update network: %s" % str(exc))
|
||||
|
||||
def get_all_ports(self, net_id):
|
||||
@ -256,7 +256,7 @@ class QuantumDB(object):
|
||||
port_dict["net"] = port.network
|
||||
ports.append(port_dict)
|
||||
return ports
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to get all ports: %s" % str(exc))
|
||||
|
||||
def get_port(self, net_id, port_id):
|
||||
@ -272,7 +272,7 @@ class QuantumDB(object):
|
||||
port_dict["state"] = port.state
|
||||
port_list.append(port_dict)
|
||||
return port_list
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to get port: %s" % str(exc))
|
||||
|
||||
def create_port(self, net_id):
|
||||
@ -286,7 +286,7 @@ class QuantumDB(object):
|
||||
port_dict["int-id"] = port.interface_id
|
||||
port_dict["state"] = port.state
|
||||
return port_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to create port: %s" % str(exc))
|
||||
|
||||
def delete_port(self, net_id, port_id):
|
||||
@ -297,7 +297,7 @@ class QuantumDB(object):
|
||||
port_dict = {}
|
||||
port_dict["port-id"] = str(port.uuid)
|
||||
return port_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
raise Exception("Failed to delete port: %s" % str(exc))
|
||||
|
||||
def update_port(self, net_id, port_id, port_state):
|
||||
@ -311,7 +311,7 @@ class QuantumDB(object):
|
||||
port_dict["int-id"] = port.interface_id
|
||||
port_dict["state"] = port.state
|
||||
return port_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
raise Exception("Failed to update port state: %s" % str(exc))
|
||||
|
||||
def plug_interface(self, net_id, port_id, int_id):
|
||||
@ -325,7 +325,7 @@ class QuantumDB(object):
|
||||
port_dict["int-id"] = port.interface_id
|
||||
port_dict["state"] = port.state
|
||||
return port_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
raise Exception("Failed to plug interface: %s" % str(exc))
|
||||
|
||||
def unplug_interface(self, net_id, port_id):
|
||||
@ -339,7 +339,7 @@ class QuantumDB(object):
|
||||
port_dict["int-id"] = port.interface_id
|
||||
port_dict["state"] = port.state
|
||||
return port_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
raise Exception("Failed to unplug interface: %s" % str(exc))
|
||||
|
||||
|
||||
|
@ -85,7 +85,7 @@ class OFCClient(object):
|
||||
else:
|
||||
reason = _("An operation on OFC is failed.")
|
||||
raise nexc.OFCException(reason=reason)
|
||||
except (socket.error, IOError), e:
|
||||
except (socket.error, IOError) as e:
|
||||
reason = _("Failed to connect OFC : %s") % str(e)
|
||||
LOG.error(reason)
|
||||
raise nexc.OFCException(reason=reason)
|
||||
|
@ -293,7 +293,7 @@ def main():
|
||||
agent = OVSQuantumOFPRyuAgent(integ_br, tunnel_ip, ovsdb_ip,
|
||||
ovsdb_port, polling_interval,
|
||||
root_helper)
|
||||
except httplib.HTTPException, e:
|
||||
except httplib.HTTPException as e:
|
||||
LOG.error(_("Initialization failed: %s"), e)
|
||||
sys.exit(1)
|
||||
|
||||
|
@ -121,7 +121,7 @@ class HaproxyNSDriver(object):
|
||||
break
|
||||
|
||||
return self._parse_stats(raw_stats)
|
||||
except socket.error, e:
|
||||
except socket.error as e:
|
||||
LOG.warn(_('Error while connecting to stats socket: %s') % e)
|
||||
return {}
|
||||
else:
|
||||
|
@ -37,7 +37,7 @@ def main():
|
||||
try:
|
||||
quantum_service = service.serve_wsgi(service.QuantumApiService)
|
||||
quantum_service.wait()
|
||||
except RuntimeError, e:
|
||||
except RuntimeError as e:
|
||||
sys.exit(_("ERROR: %s") % e)
|
||||
|
||||
|
||||
|
@ -39,7 +39,7 @@ class QuantumDB(object):
|
||||
net_dict["id"] = str(net.uuid)
|
||||
net_dict["name"] = net.name
|
||||
nets.append(net_dict)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to get all networks: %s", str(exc))
|
||||
return nets
|
||||
|
||||
@ -54,7 +54,7 @@ class QuantumDB(object):
|
||||
net_dict["id"] = str(net.uuid)
|
||||
net_dict["name"] = net.name
|
||||
net.append(net_dict)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to get network: %s", str(exc))
|
||||
return net
|
||||
|
||||
@ -68,7 +68,7 @@ class QuantumDB(object):
|
||||
net_dict["id"] = str(res.uuid)
|
||||
net_dict["name"] = res.name
|
||||
return net_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to create network: %s", str(exc))
|
||||
|
||||
def delete_network(self, net_id):
|
||||
@ -79,7 +79,7 @@ class QuantumDB(object):
|
||||
net_dict = {}
|
||||
net_dict["id"] = str(net.uuid)
|
||||
return net_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to delete network: %s", str(exc))
|
||||
|
||||
def update_network(self, tenant_id, net_id, param_data):
|
||||
@ -92,7 +92,7 @@ class QuantumDB(object):
|
||||
net_dict["id"] = str(net.uuid)
|
||||
net_dict["name"] = net.name
|
||||
return net_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to update network: %s", str(exc))
|
||||
|
||||
def get_all_ports(self, net_id):
|
||||
@ -108,7 +108,7 @@ class QuantumDB(object):
|
||||
port_dict["state"] = port.state
|
||||
ports.append(port_dict)
|
||||
return ports
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to get all ports: %s", str(exc))
|
||||
|
||||
def get_port(self, net_id, port_id):
|
||||
@ -124,7 +124,7 @@ class QuantumDB(object):
|
||||
port_dict["state"] = port.state
|
||||
port_list.append(port_dict)
|
||||
return port_list
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to get port: %s", str(exc))
|
||||
|
||||
def create_port(self, net_id):
|
||||
@ -138,7 +138,7 @@ class QuantumDB(object):
|
||||
port_dict["attachment"] = port.interface_id
|
||||
port_dict["state"] = port.state
|
||||
return port_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to create port: %s", str(exc))
|
||||
|
||||
def delete_port(self, net_id, port_id):
|
||||
@ -149,7 +149,7 @@ class QuantumDB(object):
|
||||
port_dict = {}
|
||||
port_dict["id"] = str(port.uuid)
|
||||
return port_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to delete port: %s", str(exc))
|
||||
|
||||
def update_port(self, net_id, port_id, **kwargs):
|
||||
@ -163,7 +163,7 @@ class QuantumDB(object):
|
||||
port_dict["attachment"] = port.interface_id
|
||||
port_dict["state"] = port.state
|
||||
return port_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to update port state: %s", str(exc))
|
||||
|
||||
def plug_interface(self, net_id, port_id, int_id):
|
||||
@ -177,7 +177,7 @@ class QuantumDB(object):
|
||||
port_dict["attachment"] = port.interface_id
|
||||
port_dict["state"] = port.state
|
||||
return port_dict
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to plug interface: %s", str(exc))
|
||||
|
||||
def unplug_interface(self, net_id, port_id):
|
||||
@ -185,5 +185,5 @@ class QuantumDB(object):
|
||||
try:
|
||||
db.port_unset_attachment(port_id, net_id)
|
||||
LOG.debug("Detached interface from port %s", port_id)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.error("Failed to unplug interface: %s", str(exc))
|
||||
|
@ -1043,7 +1043,7 @@ class Resource(Application):
|
||||
try:
|
||||
msg_dict = dict(url=request.url, status=response.status_int)
|
||||
msg = _("%(url)s returned with HTTP %(status)d") % msg_dict
|
||||
except AttributeError, e:
|
||||
except AttributeError as e:
|
||||
msg_dict = dict(url=request.url, exception=e)
|
||||
msg = _("%(url)s returned a fault: %(exception)s") % msg_dict
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user