diff options
author | Yolanda Robla <yroblamo@redhat.com> | 2018-07-26 10:27:16 +0200 |
---|---|---|
committer | Yolanda Robla <yroblamo@redhat.com> | 2018-10-05 10:09:48 +0200 |
commit | f11c949a111bff0b34ce14dd219ec7cf23e0d082 (patch) | |
tree | 01f793aa4ce0c5bf123715a7a305833556dfdc9c /ironic/api/controllers | |
parent | 869b86e0c3edc0d285502d1a9c2cb4c76d4c7e2c (diff) | |
download | ironic-f11c949a111bff0b34ce14dd219ec7cf23e0d082.tar.gz |
Add automated_clean field to the API
Creates the automated_clean entry in the API.
Change-Id: Ia086b2aae6665c57d2b4264c11de7b0601038a41
Story: #2002161
Task: #23368
Diffstat (limited to 'ironic/api/controllers')
-rw-r--r-- | ironic/api/controllers/v1/node.py | 17 | ||||
-rw-r--r-- | ironic/api/controllers/v1/utils.py | 11 | ||||
-rw-r--r-- | ironic/api/controllers/v1/versions.py | 4 |
3 files changed, 30 insertions, 2 deletions
diff --git a/ironic/api/controllers/v1/node.py b/ironic/api/controllers/v1/node.py index 1808a4f94..87c632472 100644 --- a/ironic/api/controllers/v1/node.py +++ b/ironic/api/controllers/v1/node.py @@ -171,6 +171,9 @@ def _hide_fields_in_newer_versions_part_two(obj): if not api_utils.allow_conductor_group(): obj.conductor_group = wsme.Unset + if not api_utils.allow_automated_clean(): + obj.automated_clean = wsme.Unset + def hide_fields_in_newer_versions(obj): """This method hides fields that were added in newer API versions. @@ -1089,6 +1092,9 @@ class Node(base.APIBase): conductor_group = wsme.wsattr(wtypes.text) """The conductor group to manage this node""" + automated_clean = types.boolean + """Indicates whether the node will perform automated clean or not.""" + # NOTE(deva): "conductor_affinity" shouldn't be presented on the # API because it's an internal value. Don't add it here. @@ -1249,7 +1255,8 @@ class Node(base.APIBase): management_interface=None, power_interface=None, raid_interface=None, vendor_interface=None, storage_interface=None, traits=[], rescue_interface=None, - bios_interface=None, conductor_group="") + bios_interface=None, conductor_group="", + automated_clean=None) # NOTE(matty_dubs): The chassis_uuid getter() is based on the # _chassis_uuid variable: sample._chassis_uuid = 'edcad704-b2da-41d5-96d9-afd580ecfa12' @@ -1934,6 +1941,10 @@ class NodesController(rest.RestController): and node.conductor_group != ""): raise exception.NotAcceptable() + if (not api_utils.allow_automated_clean() + and node.automated_clean is not wtypes.Unset): + raise exception.NotAcceptable() + # NOTE(deva): get_topic_for checks if node.driver is in the hash ring # and raises NoValidHost if it is not. # We need to ensure that node has a UUID before it can @@ -2018,6 +2029,10 @@ class NodesController(rest.RestController): if conductor_group and not api_utils.allow_conductor_group(): raise exception.NotAcceptable() + automated_clean = api_utils.get_patch_values(patch, '/automated_clean') + if automated_clean and not api_utils.allow_automated_clean(): + raise exception.NotAcceptable() + @METRICS.timer('NodesController.patch') @wsme.validate(types.uuid, types.boolean, [NodePatchType]) @expose.expose(Node, types.uuid_or_name, types.boolean, diff --git a/ironic/api/controllers/v1/utils.py b/ironic/api/controllers/v1/utils.py index 36d89869c..52ccef183 100644 --- a/ironic/api/controllers/v1/utils.py +++ b/ironic/api/controllers/v1/utils.py @@ -383,6 +383,8 @@ def check_allowed_fields(fields): raise exception.NotAcceptable() if 'conductor_group' in fields and not allow_conductor_group(): raise exception.NotAcceptable() + if 'automated_clean' in fields and not allow_automated_clean(): + raise exception.NotAcceptable() def check_allowed_portgroup_fields(fields): @@ -896,6 +898,15 @@ def allow_conductor_group(): versions.MINOR_46_NODE_CONDUCTOR_GROUP) +def allow_automated_clean(): + """Check if passing automated_clean for a node is allowed. + + Version 1.47 exposes this field. + """ + return (pecan.request.version.minor >= + versions.MINOR_47_NODE_AUTOMATED_CLEAN) + + def get_request_return_fields(fields, detail, default_fields): """Calculate fields to return from an API request diff --git a/ironic/api/controllers/v1/versions.py b/ironic/api/controllers/v1/versions.py index 650e8be78..f7c5c02d2 100644 --- a/ironic/api/controllers/v1/versions.py +++ b/ironic/api/controllers/v1/versions.py @@ -84,6 +84,7 @@ BASE_VERSION = 1 # v1.44: Add node deploy_step field # v1.45: reset_interfaces parameter to node's PATCH # v1.46: Add conductor_group to the node object. +# v1.47: Add automated_clean to the node object. MINOR_0_JUNO = 0 MINOR_1_INITIAL_VERSION = 1 @@ -132,6 +133,7 @@ MINOR_43_ENABLE_DETAIL_QUERY = 43 MINOR_44_NODE_DEPLOY_STEP = 44 MINOR_45_RESET_INTERFACES = 45 MINOR_46_NODE_CONDUCTOR_GROUP = 46 +MINOR_47_NODE_AUTOMATED_CLEAN = 47 # When adding another version, update: # - MINOR_MAX_VERSION @@ -139,7 +141,7 @@ MINOR_46_NODE_CONDUCTOR_GROUP = 46 # explanation of what changed in the new version # - common/release_mappings.py, RELEASE_MAPPING['master']['api'] -MINOR_MAX_VERSION = MINOR_46_NODE_CONDUCTOR_GROUP +MINOR_MAX_VERSION = MINOR_47_NODE_AUTOMATED_CLEAN # String representations of the minor and maximum versions _MIN_VERSION_STRING = '{}.{}'.format(BASE_VERSION, MINOR_1_INITIAL_VERSION) |