Merge "Follow-up patch of 8e5e69869df476788b3ccf7e5ba6c2210a98fc8a"

This commit is contained in:
Jenkins
2016-05-26 10:15:13 +00:00
committed by Gerrit Code Review
2 changed files with 20 additions and 4 deletions

View File

@@ -96,6 +96,16 @@ PROVISION_ACTION_STATES = (ir_states.VERBS['manage'],
ir_states.VERBS['provide'],
ir_states.VERBS['abort'])
_NODES_CONTROLLER_RESERVED_WORDS = None
def get_nodes_controller_reserved_names():
global _NODES_CONTROLLER_RESERVED_WORDS
if _NODES_CONTROLLER_RESERVED_WORDS is None:
_NODES_CONTROLLER_RESERVED_WORDS = (
api_utils.get_controller_reserved_names(NodesController))
return _NODES_CONTROLLER_RESERVED_WORDS
def hide_fields_in_newer_versions(obj):
# if requested version is < 1.3, hide driver_internal_info
@@ -924,6 +934,12 @@ class NodeMaintenanceController(rest.RestController):
class NodesController(rest.RestController):
"""REST controller for Nodes."""
# NOTE(lucasagomes): For future reference. If we happen
# to need to add another sub-controller in this class let's
# try to make it a parameter instead of an endpoint due
# https://bugs.launchpad.net/ironic/+bug/1572651, e.g, instead of
# v1/nodes/(ident)/detail we could have v1/nodes/(ident)?detail=True
states = NodeStatesController()
"""Expose the state controller action as a sub-element of nodes"""
@@ -1033,8 +1049,7 @@ class NodesController(rest.RestController):
if not api_utils.allow_node_logical_names():
raise exception.NotAcceptable()
reserved_names = api_utils.get_controller_reserved_names(
NodesController)
reserved_names = get_nodes_controller_reserved_names()
for name in names:
if not api_utils.is_valid_node_name(name):
raise wsme.exc.ClientSideError(
@@ -1043,7 +1058,7 @@ class NodesController(rest.RestController):
if name in reserved_names:
raise wsme.exc.ClientSideError(
'The word "%(name)s" is reserved and can not be used as a '
'node name. Other reserved words are: %(reserved)s' %
'node name. Reserved words are: %(reserved)s.' %
{'name': name,
'reserved': ', '.join(reserved_names)},
status_code=http_client.BAD_REQUEST)

View File

@@ -2,4 +2,5 @@
fixes:
- Fixes a problem which allowed nodes to be named with some reserved
words that are implicitly not allowed due the way the Ironic API
works.
works. The reserved words are "maintenance", "management", "ports",
"states", "vendor_passthru", "validate" and "detail".