diff --git a/mogan/api/controllers/v1/flavors.py b/mogan/api/controllers/v1/flavors.py index 47fc1895..75e0a930 100644 --- a/mogan/api/controllers/v1/flavors.py +++ b/mogan/api/controllers/v1/flavors.py @@ -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 @@ -160,10 +161,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, @@ -184,7 +185,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): diff --git a/mogan/api/controllers/v1/servers.py b/mogan/api/controllers/v1/servers.py index 1b69a9e0..6af2278e 100644 --- a/mogan/api/controllers/v1/servers.py +++ b/mogan/api/controllers/v1/servers.py @@ -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) diff --git a/mogan/engine/baremetal/ironic/driver.py b/mogan/engine/baremetal/ironic/driver.py index f99860ff..8bedd18f 100644 --- a/mogan/engine/baremetal/ironic/driver.py +++ b/mogan/engine/baremetal/ironic/driver.py @@ -445,7 +445,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 @@ -458,7 +458,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 @@ -487,7 +487,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 @@ -509,7 +509,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 diff --git a/mogan/engine/manager.py b/mogan/engine/manager.py index 1e012787..491b1f5b 100644 --- a/mogan/engine/manager.py +++ b/mogan/engine/manager.py @@ -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) @@ -614,4 +614,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))