Merge "Stop using deprecated 'message' attribute in Exception"

This commit is contained in:
Jenkins 2017-07-03 11:54:00 +00:00 committed by Gerrit Code Review
commit bddfad0863
4 changed files with 21 additions and 19 deletions

View File

@ -15,6 +15,7 @@
import pecan import pecan
from pecan import rest from pecan import rest
import six
from six.moves import http_client from six.moves import http_client
import wsme import wsme
from wsme import types as wtypes from wsme import types as wtypes
@ -160,10 +161,10 @@ class FlavorAccessController(rest.RestController):
flavor.save() flavor.save()
except exception.FlavorNotFound as e: except exception.FlavorNotFound as e:
raise wsme.exc.ClientSideError( 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: except exception.FlavorAccessExists as err:
raise wsme.exc.ClientSideError( 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") @policy.authorize_wsgi("mogan:flavor_access", "remove_tenant_access")
@expose.expose(None, types.uuid, types.uuid, @expose.expose(None, types.uuid, types.uuid,
@ -184,7 +185,7 @@ class FlavorAccessController(rest.RestController):
except (exception.FlavorAccessNotFound, except (exception.FlavorAccessNotFound,
exception.FlavorNotFound) as e: exception.FlavorNotFound) as e:
raise wsme.exc.ClientSideError( 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): class FlavorsController(rest.RestController):

View File

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

View File

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

View File

@ -594,7 +594,7 @@ class EngineManager(base_manager.BaseEngineManager):
return pif return pif
# if no available compute ports, raise exception # 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) LOG.error(message)
raise exception.ComputePortNotAvailable(message=message) raise exception.ComputePortNotAvailable(message=message)
@ -614,4 +614,4 @@ class EngineManager(base_manager.BaseEngineManager):
server.nics = nics_obj server.nics = nics_obj
server.save() server.save()
except Exception as e: except Exception as e:
raise exception.InterfaceAttachFailed(message=e.message) raise exception.InterfaceAttachFailed(message=six.text_type(e))