Merge "Follow-up: Fix improper HTTP status code usage"
This commit is contained in:
@@ -2873,7 +2873,7 @@ class NodesController(rest.RestController):
|
|||||||
of the resource to be returned.
|
of the resource to be returned.
|
||||||
"""
|
"""
|
||||||
if self.from_chassis:
|
if self.from_chassis:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
rpc_node = api_utils.check_node_policy_and_retrieve(
|
rpc_node = api_utils.check_node_policy_and_retrieve(
|
||||||
'baremetal:node:get', node_ident, with_suffix=True)
|
'baremetal:node:get', node_ident, with_suffix=True)
|
||||||
@@ -2899,7 +2899,7 @@ class NodesController(rest.RestController):
|
|||||||
:language: javascript
|
:language: javascript
|
||||||
"""
|
"""
|
||||||
if self.from_chassis:
|
if self.from_chassis:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
node_capabilities = node.get('properties', {}).get('capabilities', '')
|
node_capabilities = node.get('properties', {}).get('capabilities', '')
|
||||||
# ``check_allow_boot_mode`` expects ``node_capabilities`` to be a list
|
# ``check_allow_boot_mode`` expects ``node_capabilities`` to be a list
|
||||||
@@ -3000,7 +3000,7 @@ class NodesController(rest.RestController):
|
|||||||
def _validate_patch(self, patch, reset_interfaces):
|
def _validate_patch(self, patch, reset_interfaces):
|
||||||
corrected_values = {}
|
corrected_values = {}
|
||||||
if self.from_chassis:
|
if self.from_chassis:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
node_capabilities = api_utils.get_patch_values(
|
node_capabilities = api_utils.get_patch_values(
|
||||||
patch, '/properties/capabilities')
|
patch, '/properties/capabilities')
|
||||||
@@ -3256,7 +3256,7 @@ class NodesController(rest.RestController):
|
|||||||
raise exception.NotFound()
|
raise exception.NotFound()
|
||||||
|
|
||||||
if self.from_chassis:
|
if self.from_chassis:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
context = api.request.context
|
context = api.request.context
|
||||||
try:
|
try:
|
||||||
|
@@ -589,7 +589,7 @@ class PortsController(rest.RestController):
|
|||||||
:raises: NotAcceptable, HTTPNotFound
|
:raises: NotAcceptable, HTTPNotFound
|
||||||
"""
|
"""
|
||||||
if self.parent_node_ident or self.parent_portgroup_ident:
|
if self.parent_node_ident or self.parent_portgroup_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
rpc_port, rpc_node = api_utils.check_port_policy_and_retrieve(
|
rpc_port, rpc_node = api_utils.check_port_policy_and_retrieve(
|
||||||
'baremetal:port:get', port_ident)
|
'baremetal:port:get', port_ident)
|
||||||
@@ -610,7 +610,7 @@ class PortsController(rest.RestController):
|
|||||||
:raises: NotAcceptable, HTTPNotFound, Conflict
|
:raises: NotAcceptable, HTTPNotFound, Conflict
|
||||||
"""
|
"""
|
||||||
if self.parent_node_ident or self.parent_portgroup_ident:
|
if self.parent_node_ident or self.parent_portgroup_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
# NOTE(lucasagomes): Create the node_id attribute on-the-fly
|
# NOTE(lucasagomes): Create the node_id attribute on-the-fly
|
||||||
# to satisfy the api -> rpc object
|
# to satisfy the api -> rpc object
|
||||||
@@ -732,7 +732,7 @@ class PortsController(rest.RestController):
|
|||||||
:raises: NotAcceptable, HTTPNotFound
|
:raises: NotAcceptable, HTTPNotFound
|
||||||
"""
|
"""
|
||||||
if self.parent_node_ident or self.parent_portgroup_ident:
|
if self.parent_node_ident or self.parent_portgroup_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
api_utils.patch_validate_allowed_fields(patch, PATCH_ALLOWED_FIELDS)
|
api_utils.patch_validate_allowed_fields(patch, PATCH_ALLOWED_FIELDS)
|
||||||
|
|
||||||
@@ -842,10 +842,10 @@ class PortsController(rest.RestController):
|
|||||||
"""Delete a port.
|
"""Delete a port.
|
||||||
|
|
||||||
:param port_uuid: UUID of a port.
|
:param port_uuid: UUID of a port.
|
||||||
:raises: Invalid, HTTPNotFound
|
:raises: MalformedRequestURI, HTTPNotFound
|
||||||
"""
|
"""
|
||||||
if self.parent_node_ident or self.parent_portgroup_ident:
|
if self.parent_node_ident or self.parent_portgroup_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
rpc_port, rpc_node = api_utils.check_port_policy_and_retrieve(
|
rpc_port, rpc_node = api_utils.check_port_policy_and_retrieve(
|
||||||
'baremetal:port:delete', port_uuid)
|
'baremetal:port:delete', port_uuid)
|
||||||
|
@@ -364,7 +364,7 @@ class PortgroupsController(pecan.rest.RestController):
|
|||||||
'baremetal:portgroup:get', portgroup_ident, portgroup=True)
|
'baremetal:portgroup:get', portgroup_ident, portgroup=True)
|
||||||
|
|
||||||
if self.parent_node_ident:
|
if self.parent_node_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
api_utils.check_allowed_portgroup_fields(fields)
|
api_utils.check_allowed_portgroup_fields(fields)
|
||||||
|
|
||||||
@@ -411,7 +411,7 @@ class PortgroupsController(pecan.rest.RestController):
|
|||||||
context = api.request.context
|
context = api.request.context
|
||||||
|
|
||||||
if self.parent_node_ident:
|
if self.parent_node_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
if (not api_utils.allow_portgroup_mode_properties()
|
if (not api_utils.allow_portgroup_mode_properties()
|
||||||
and (portgroup.get('mode') or portgroup.get('properties'))):
|
and (portgroup.get('mode') or portgroup.get('properties'))):
|
||||||
@@ -462,7 +462,7 @@ class PortgroupsController(pecan.rest.RestController):
|
|||||||
'baremetal:portgroup:update', portgroup_ident, portgroup=True)
|
'baremetal:portgroup:update', portgroup_ident, portgroup=True)
|
||||||
|
|
||||||
if self.parent_node_ident:
|
if self.parent_node_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
if (not api_utils.allow_portgroup_mode_properties()
|
if (not api_utils.allow_portgroup_mode_properties()
|
||||||
and (api_utils.is_path_updated(patch, '/mode')
|
and (api_utils.is_path_updated(patch, '/mode')
|
||||||
@@ -554,7 +554,7 @@ class PortgroupsController(pecan.rest.RestController):
|
|||||||
context = api.request.context
|
context = api.request.context
|
||||||
|
|
||||||
if self.parent_node_ident:
|
if self.parent_node_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
notify.emit_start_notification(context, rpc_portgroup, 'delete',
|
notify.emit_start_notification(context, rpc_portgroup, 'delete',
|
||||||
node_uuid=rpc_node.uuid)
|
node_uuid=rpc_node.uuid)
|
||||||
|
@@ -209,7 +209,7 @@ class VolumeConnectorsController(rest.RestController):
|
|||||||
|
|
||||||
:returns: API-serializable volume connector object.
|
:returns: API-serializable volume connector object.
|
||||||
|
|
||||||
:raises: Invalid if accessed with specifying a parent
|
:raises: MalformedRequestURI if accessed with specifying a parent
|
||||||
node.
|
node.
|
||||||
:raises: VolumeConnectorNotFound if no volume connector exists with
|
:raises: VolumeConnectorNotFound if no volume connector exists with
|
||||||
the specified UUID.
|
the specified UUID.
|
||||||
@@ -221,7 +221,7 @@ class VolumeConnectorsController(rest.RestController):
|
|||||||
target=False)
|
target=False)
|
||||||
|
|
||||||
if self.parent_node_ident:
|
if self.parent_node_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
return convert_with_links(rpc_connector, fields=fields)
|
return convert_with_links(rpc_connector, fields=fields)
|
||||||
|
|
||||||
@@ -236,7 +236,7 @@ class VolumeConnectorsController(rest.RestController):
|
|||||||
|
|
||||||
:returns: API-serializable volume connector object.
|
:returns: API-serializable volume connector object.
|
||||||
|
|
||||||
:raises: Invalid if accessed with specifying a parent
|
:raises: MalformedRequestURI if accessed with specifying a parent
|
||||||
node.
|
node.
|
||||||
:raises: VolumeConnectorTypeAndIdAlreadyExists if a volume
|
:raises: VolumeConnectorTypeAndIdAlreadyExists if a volume
|
||||||
connector already exists with the same type and connector_id
|
connector already exists with the same type and connector_id
|
||||||
@@ -263,7 +263,7 @@ class VolumeConnectorsController(rest.RestController):
|
|||||||
value=node_uuid)
|
value=node_uuid)
|
||||||
|
|
||||||
if self.parent_node_ident:
|
if self.parent_node_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
# NOTE(hshiina): UUID is mandatory for notification payload
|
# NOTE(hshiina): UUID is mandatory for notification payload
|
||||||
if not connector.get('uuid'):
|
if not connector.get('uuid'):
|
||||||
@@ -296,7 +296,7 @@ class VolumeConnectorsController(rest.RestController):
|
|||||||
|
|
||||||
:returns: API-serializable volume connector object.
|
:returns: API-serializable volume connector object.
|
||||||
|
|
||||||
:raises: Invalid if accessed with specifying a
|
:raises: MalformedRequestURI if accessed with specifying a
|
||||||
parent node.
|
parent node.
|
||||||
:raises: PatchError if a given patch can not be applied.
|
:raises: PatchError if a given patch can not be applied.
|
||||||
:raises: VolumeConnectorNotFound if no volume connector exists with
|
:raises: VolumeConnectorNotFound if no volume connector exists with
|
||||||
@@ -321,7 +321,7 @@ class VolumeConnectorsController(rest.RestController):
|
|||||||
target=False)
|
target=False)
|
||||||
|
|
||||||
if self.parent_node_ident:
|
if self.parent_node_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
api_utils.patch_validate_allowed_fields(patch, PATCH_ALLOWED_FIELDS)
|
api_utils.patch_validate_allowed_fields(patch, PATCH_ALLOWED_FIELDS)
|
||||||
|
|
||||||
@@ -380,7 +380,7 @@ class VolumeConnectorsController(rest.RestController):
|
|||||||
|
|
||||||
:param connector_uuid: UUID of a volume connector.
|
:param connector_uuid: UUID of a volume connector.
|
||||||
|
|
||||||
:raises: Invalid if accessed with specifying a
|
:raises: MalformedRequestURI if accessed with specifying a
|
||||||
parent node.
|
parent node.
|
||||||
:raises: NodeLocked if node is locked by another conductor
|
:raises: NodeLocked if node is locked by another conductor
|
||||||
:raises: NodeNotFound if the node associated with the connector does
|
:raises: NodeNotFound if the node associated with the connector does
|
||||||
@@ -397,7 +397,7 @@ class VolumeConnectorsController(rest.RestController):
|
|||||||
connector_uuid,
|
connector_uuid,
|
||||||
target=False)
|
target=False)
|
||||||
if self.parent_node_ident:
|
if self.parent_node_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
notify.emit_start_notification(context, rpc_connector, 'delete',
|
notify.emit_start_notification(context, rpc_connector, 'delete',
|
||||||
node_uuid=rpc_node.uuid)
|
node_uuid=rpc_node.uuid)
|
||||||
|
@@ -239,7 +239,7 @@ class VolumeTargetsController(rest.RestController):
|
|||||||
|
|
||||||
:returns: API-serializable volume target object.
|
:returns: API-serializable volume target object.
|
||||||
|
|
||||||
:raises: Invalid if accessed with specifying a parent
|
:raises: MalformedRequestURI if accessed with specifying a parent
|
||||||
node.
|
node.
|
||||||
:raises: VolumeTargetNotFound if no volume target with this UUID exists
|
:raises: VolumeTargetNotFound if no volume target with this UUID exists
|
||||||
"""
|
"""
|
||||||
@@ -250,7 +250,7 @@ class VolumeTargetsController(rest.RestController):
|
|||||||
target=True)
|
target=True)
|
||||||
|
|
||||||
if self.parent_node_ident:
|
if self.parent_node_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
cdict = api.request.context.to_policy_values()
|
cdict = api.request.context.to_policy_values()
|
||||||
if not policy.check_policy('baremetal:volume:view_target_properties',
|
if not policy.check_policy('baremetal:volume:view_target_properties',
|
||||||
@@ -270,7 +270,7 @@ class VolumeTargetsController(rest.RestController):
|
|||||||
|
|
||||||
:returns: API-serializable volume target object.
|
:returns: API-serializable volume target object.
|
||||||
|
|
||||||
:raises: Invalid if accessed with specifying a parent
|
:raises: MalformedRequestURI if accessed with specifying a parent
|
||||||
node.
|
node.
|
||||||
:raises: VolumeTargetBootIndexAlreadyExists if a volume target already
|
:raises: VolumeTargetBootIndexAlreadyExists if a volume target already
|
||||||
exists with the same node ID and boot index
|
exists with the same node ID and boot index
|
||||||
@@ -297,7 +297,7 @@ class VolumeTargetsController(rest.RestController):
|
|||||||
value=node_uuid)
|
value=node_uuid)
|
||||||
|
|
||||||
if self.parent_node_ident:
|
if self.parent_node_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
# NOTE(hshiina): UUID is mandatory for notification payload
|
# NOTE(hshiina): UUID is mandatory for notification payload
|
||||||
if not target.get('uuid'):
|
if not target.get('uuid'):
|
||||||
@@ -328,7 +328,7 @@ class VolumeTargetsController(rest.RestController):
|
|||||||
|
|
||||||
:returns: API-serializable volume target object.
|
:returns: API-serializable volume target object.
|
||||||
|
|
||||||
:raises: Invalid if accessed with specifying a
|
:raises: MalformedRequestURI if accessed with specifying a
|
||||||
parent node.
|
parent node.
|
||||||
:raises: PatchError if a given patch can not be applied.
|
:raises: PatchError if a given patch can not be applied.
|
||||||
:raises: InvalidParameterValue if the volume target's UUID is being
|
:raises: InvalidParameterValue if the volume target's UUID is being
|
||||||
@@ -350,7 +350,7 @@ class VolumeTargetsController(rest.RestController):
|
|||||||
target=True)
|
target=True)
|
||||||
|
|
||||||
if self.parent_node_ident:
|
if self.parent_node_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
api_utils.patch_validate_allowed_fields(patch, PATCH_ALLOWED_FIELDS)
|
api_utils.patch_validate_allowed_fields(patch, PATCH_ALLOWED_FIELDS)
|
||||||
|
|
||||||
@@ -414,7 +414,7 @@ class VolumeTargetsController(rest.RestController):
|
|||||||
|
|
||||||
:param target_uuid: UUID of a volume target.
|
:param target_uuid: UUID of a volume target.
|
||||||
|
|
||||||
:raises: Invalid if accessed with specifying a
|
:raises: MalformedRequestURI if accessed with specifying a
|
||||||
parent node.
|
parent node.
|
||||||
:raises: NodeLocked if node is locked by another conductor
|
:raises: NodeLocked if node is locked by another conductor
|
||||||
:raises: NodeNotFound if the node associated with the target does
|
:raises: NodeNotFound if the node associated with the target does
|
||||||
@@ -430,7 +430,7 @@ class VolumeTargetsController(rest.RestController):
|
|||||||
target=True)
|
target=True)
|
||||||
|
|
||||||
if self.parent_node_ident:
|
if self.parent_node_ident:
|
||||||
raise exception.Invalid(_("Malformed request URI."))
|
raise exception.MalformedRequestURI()
|
||||||
|
|
||||||
rpc_target = objects.VolumeTarget.get_by_uuid(context, target_uuid)
|
rpc_target = objects.VolumeTarget.get_by_uuid(context, target_uuid)
|
||||||
rpc_node = objects.Node.get_by_id(context, rpc_target.node_id)
|
rpc_node = objects.Node.get_by_id(context, rpc_target.node_id)
|
||||||
|
@@ -140,6 +140,10 @@ class Invalid(IronicException):
|
|||||||
code = http_client.BAD_REQUEST
|
code = http_client.BAD_REQUEST
|
||||||
|
|
||||||
|
|
||||||
|
class MalformedRequestURI(Invalid):
|
||||||
|
_msg_fmt = _("Malformed request URI.")
|
||||||
|
|
||||||
|
|
||||||
class Conflict(IronicException):
|
class Conflict(IronicException):
|
||||||
_msg_fmt = _('Conflict.')
|
_msg_fmt = _('Conflict.')
|
||||||
code = http_client.CONFLICT
|
code = http_client.CONFLICT
|
||||||
@@ -525,10 +529,6 @@ class ServiceUnavailable(IronicException):
|
|||||||
_msg_fmt = _("Connection failed")
|
_msg_fmt = _("Connection failed")
|
||||||
|
|
||||||
|
|
||||||
class Forbidden(IronicException):
|
|
||||||
_msg_fmt = _("Requested OpenStack Baremetal API is forbidden")
|
|
||||||
|
|
||||||
|
|
||||||
# TODO(dtantsur): leave only one variant
|
# TODO(dtantsur): leave only one variant
|
||||||
BadRequest = Invalid
|
BadRequest = Invalid
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user