Stop using deprecated 'message' attribute in Exception

The 'message' attribute has been deprecated and removed
from Python3.
For more details, please check:
https://www.python.org/dev/peps/pep-0352/

Change-Id: If69389968f92b2b32f876c10ce9b4a00306c4d2a
This commit is contained in:
Vu Cong Tuan 2017-06-20 17:07:42 +07:00
parent 9f0b8ba520
commit e4bf6a631f
4 changed files with 21 additions and 19 deletions

View File

@ -15,6 +15,7 @@
import pecan
from pecan import rest
import six
from six.moves import http_client
import wsme
from wsme import types as wtypes
@ -157,10 +158,10 @@ class FlavorAccessController(rest.RestController):
flavor.save()
except exception.FlavorNotFound as e:
raise wsme.exc.ClientSideError(
e.message, status_code=http_client.NOT_FOUND)
six.text_type(e), status_code=http_client.NOT_FOUND)
except exception.FlavorAccessExists as err:
raise wsme.exc.ClientSideError(
err.message, status_code=http_client.CONFLICT)
six.text_type(err), status_code=http_client.CONFLICT)
@policy.authorize_wsgi("mogan:flavor_access", "remove_tenant_access")
@expose.expose(None, types.uuid, types.uuid,
@ -181,7 +182,7 @@ class FlavorAccessController(rest.RestController):
except (exception.FlavorAccessNotFound,
exception.FlavorNotFound) as e:
raise wsme.exc.ClientSideError(
e.message, status_code=http_client.NOT_FOUND)
six.text_type(e), status_code=http_client.NOT_FOUND)
class FlavorsController(rest.RestController):

View File

@ -19,6 +19,7 @@ from oslo_log import log
from oslo_utils import netutils
import pecan
from pecan import rest
import six
from six.moves import http_client
from webob import exc
import wsme
@ -262,10 +263,10 @@ class FloatingIPController(ServerControllerBase):
port_id=nic.port_id, fixed_address=fixed_address)
except exception.FloatingIpNotFoundForAddress as e:
raise wsme.exc.ClientSideError(
e.message, status_code=http_client.NOT_FOUND)
six.text_type(e), status_code=http_client.NOT_FOUND)
except exception.Forbidden as e:
raise wsme.exc.ClientSideError(
e.message, status_code=http_client.FORBIDDEN)
six.text_type(e), status_code=http_client.FORBIDDEN)
except Exception as e:
msg = _('Unable to associate floating IP %(address)s to '
'fixed IP %(fixed_address)s for server %(id)s. '
@ -305,10 +306,10 @@ class FloatingIPController(ServerControllerBase):
pecan.request.context, address)
except exception.FloatingIpNotFoundForAddress as e:
raise wsme.exc.ClientSideError(
e.message, status_code=http_client.NOT_FOUND)
six.text_type(e), status_code=http_client.NOT_FOUND)
except exception.FloatingIpMultipleFoundForAddress as e:
raise wsme.exc.ClientSideError(
e.message, status_code=http_client.CONFLICT)
six.text_type(e), status_code=http_client.CONFLICT)
# disassociate if associated
if (floating_ip.get('port_id') and server_id == server_uuid):
@ -317,7 +318,7 @@ class FloatingIPController(ServerControllerBase):
pecan.request.context, address)
except exception.Forbidden as e:
raise wsme.exc.ClientSideError(
e.message, status_code=http_client.FORBIDDEN)
six.text_type(e), status_code=http_client.FORBIDDEN)
except exception.CannotDisassociateAutoAssignedFloatingIP:
msg = _('Cannot disassociate auto assigned floating IP')
raise wsme.exc.ClientSideError(
@ -363,10 +364,10 @@ class InterfaceController(ServerControllerBase):
exception.ComputePortNotAvailable,
exception.NetworkNotFound) as e:
raise wsme.exc.ClientSideError(
e.message, status_code=http_client.BAD_REQUEST)
six.text_type(e), status_code=http_client.BAD_REQUEST)
except exception.InterfaceAttachFailed as e:
raise wsme.exc.ClientSideError(
e.message, status_code=http_client.CONFLICT)
six.text_type(e), status_code=http_client.CONFLICT)
class ServerNetworks(base.APIBase):
@ -671,7 +672,7 @@ class ServerController(ServerControllerBase):
msg, status_code=http_client.BAD_REQUEST)
except exception.PortLimitExceeded as e:
raise wsme.exc.ClientSideError(
e.message, status_code=http_client.FORBIDDEN)
six.text_type(e), status_code=http_client.FORBIDDEN)
except exception.AZNotFound:
msg = _('The requested availability zone is not available')
raise wsme.exc.ClientSideError(
@ -684,10 +685,10 @@ class ServerController(ServerControllerBase):
exception.NetworkNotFound,
exception.PortRequiresFixedIP) as e:
raise wsme.exc.ClientSideError(
e.message, status_code=http_client.BAD_REQUEST)
six.text_type(e), status_code=http_client.BAD_REQUEST)
except exception.PortInUse as e:
raise wsme.exc.ClientSideError(
e.message, status_code=http_client.CONFLICT)
six.text_type(e), status_code=http_client.CONFLICT)
# Set the HTTP Location Header for the first server.
pecan.response.location = link.build_url('server', servers[0].uuid)

View File

@ -451,7 +451,7 @@ class IronicDriver(base_driver.BaseEngineDriver):
node_list = self.ironicclient.call("node.list", **params)
except client_e.ClientException as e:
LOG.exception("Could not get nodes from ironic. Reason: "
"%(detail)s", {'detail': e.message})
"%(detail)s", {'detail': six.text_type(e)})
node_list = []
# Retrive ports
@ -464,7 +464,7 @@ class IronicDriver(base_driver.BaseEngineDriver):
port_list = self.ironicclient.call("port.list", **params)
except client_e.ClientException as e:
LOG.exception("Could not get ports from ironic. Reason: "
"%(detail)s", {'detail': e.message})
"%(detail)s", {'detail': six.text_type(e)})
port_list = []
# TODO(zhenguo): Add portgroups resources
@ -493,7 +493,7 @@ class IronicDriver(base_driver.BaseEngineDriver):
node_list = self.ironicclient.call("node.list", **params)
except client_e.ClientException as e:
LOG.exception("Could not get nodes from ironic. Reason: "
"%(detail)s", {'detail': e.message})
"%(detail)s", {'detail': six.text_type(e)})
node_list = []
return node_list
@ -515,7 +515,7 @@ class IronicDriver(base_driver.BaseEngineDriver):
node_list = self.ironicclient.call("node.list", **params)
except client_e.ClientException as e:
LOG.exception("Could not get nodes from ironic. Reason: "
"%(detail)s", {'detail': e.message})
"%(detail)s", {'detail': six.text_type(e)})
node_list = []
return node_list

View File

@ -594,7 +594,7 @@ class EngineManager(base_manager.BaseEngineManager):
return pif
# if no available compute ports, raise exception
message = "Node %s has no available pysical ports." % node
message = "Node %s has no available physical ports." % node
LOG.error(message)
raise exception.ComputePortNotAvailable(message=message)
@ -618,4 +618,4 @@ class EngineManager(base_manager.BaseEngineManager):
server.nics = nics_obj
server.save()
except Exception as e:
raise exception.InterfaceAttachFailed(message=e.message)
raise exception.InterfaceAttachFailed(message=six.text_type(e))