diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-09-23 02:36:10 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-09-23 02:36:10 +0000 |
commit | fb1e3d1e40697dd6b94d0037394a3f5d28cc7138 (patch) | |
tree | 912d4f5b6e309412edec1f59cf566711fe83e8ac /ironic/api | |
parent | b893b0ed3195f687f5be627dbecee4d0cb736712 (diff) | |
parent | 3274cdeed452e6fb37872001b615a0b37ed69d65 (diff) | |
download | ironic-fb1e3d1e40697dd6b94d0037394a3f5d28cc7138.tar.gz |
Merge "Make end-points discoverable via Ironic API"
Diffstat (limited to 'ironic/api')
-rw-r--r-- | ironic/api/controllers/v1/driver.py | 13 | ||||
-rw-r--r-- | ironic/api/controllers/v1/node.py | 17 | ||||
-rw-r--r-- | ironic/api/controllers/v1/utils.py | 10 | ||||
-rw-r--r-- | ironic/api/controllers/v1/versions.py | 6 |
4 files changed, 43 insertions, 3 deletions
diff --git a/ironic/api/controllers/v1/driver.py b/ironic/api/controllers/v1/driver.py index 74299028b..f84c1aad2 100644 --- a/ironic/api/controllers/v1/driver.py +++ b/ironic/api/controllers/v1/driver.py @@ -70,6 +70,9 @@ class Driver(base.APIBase): links = wsme.wsattr([link.Link], readonly=True) """A list containing self and bookmark links""" + properties = wsme.wsattr([link.Link], readonly=True) + """A list containing links to driver properties""" + @staticmethod def convert_with_links(name, hosts): driver = Driver() @@ -84,6 +87,16 @@ class Driver(base.APIBase): 'drivers', name, bookmark=True) ] + if api_utils.allow_links_node_states_and_driver_properties(): + driver.properties = [ + link.Link.make_link('self', + pecan.request.public_url, + 'drivers', name + "/properties"), + link.Link.make_link('bookmark', + pecan.request.public_url, + 'drivers', name + "/properties", + bookmark=True) + ] return driver @classmethod diff --git a/ironic/api/controllers/v1/node.py b/ironic/api/controllers/v1/node.py index 664016b9c..d95298f71 100644 --- a/ironic/api/controllers/v1/node.py +++ b/ironic/api/controllers/v1/node.py @@ -625,6 +625,9 @@ class Node(base.APIBase): ports = wsme.wsattr([link.Link], readonly=True) """Links to the collection of ports on this node""" + states = wsme.wsattr([link.Link], readonly=True) + """Links to endpoint for retrieving and setting node states""" + # NOTE(deva): "conductor_affinity" shouldn't be presented on the # API because it's an internal value. Don't add it here. @@ -648,7 +651,8 @@ class Node(base.APIBase): setattr(self, 'chassis_uuid', kwargs.get('chassis_id', wtypes.Unset)) @staticmethod - def _convert_with_links(node, url, fields=None, show_password=True): + def _convert_with_links(node, url, fields=None, show_password=True, + show_states_links=True): # NOTE(lucasagomes): Since we are able to return a specified set of # fields the "uuid" can be unset, so we need to save it in another # variable to use when building the links @@ -662,6 +666,12 @@ class Node(base.APIBase): node_uuid + "/ports", bookmark=True) ] + if show_states_links: + node.states = [link.Link.make_link('self', url, 'nodes', + node_uuid + "/states"), + link.Link.make_link('bookmark', url, 'nodes', + node_uuid + "/states", + bookmark=True)] if not show_password and node.driver_info != wtypes.Unset: node.driver_info = ast.literal_eval(strutils.mask_password( @@ -689,9 +699,12 @@ class Node(base.APIBase): assert_juno_provision_state_name(node) hide_fields_in_newer_versions(node) show_password = pecan.request.context.show_password + show_states_links = ( + api_utils.allow_links_node_states_and_driver_properties()) return cls._convert_with_links(node, pecan.request.public_url, fields=fields, - show_password=show_password) + show_password=show_password, + show_states_links=show_states_links) @classmethod def sample(cls, expand=True): diff --git a/ironic/api/controllers/v1/utils.py b/ironic/api/controllers/v1/utils.py index 323e1b66c..538ca4540 100644 --- a/ironic/api/controllers/v1/utils.py +++ b/ironic/api/controllers/v1/utils.py @@ -231,3 +231,13 @@ def allow_raid_config(): Version 1.12 of the API allows RAID configuration for the node. """ return pecan.request.version.minor >= versions.MINOR_12_RAID_CONFIG + + +def allow_links_node_states_and_driver_properties(): + """Check if links are displayable. + + Version 1.14 of the API allows the display of links to node states + and driver properties. + """ + return (pecan.request.version.minor >= + versions.MINOR_14_LINKS_NODESTATES_DRIVERPROPERTIES) diff --git a/ironic/api/controllers/v1/versions.py b/ironic/api/controllers/v1/versions.py index 4ca3ddf66..a9367d3ff 100644 --- a/ironic/api/controllers/v1/versions.py +++ b/ironic/api/controllers/v1/versions.py @@ -41,6 +41,9 @@ BASE_VERSION = 1 # v1.11: Nodes appear in ENROLL state by default # v1.12: Add support for RAID # v1.13: Add 'abort' verb to CLEANWAIT +# v1.14: Make the following endpoints discoverable via API: +# 1. '/v1/nodes/<uuid>/states' +# 2. '/v1/drivers/<driver-name>/properties' MINOR_0_JUNO = 0 MINOR_1_INITIAL_VERSION = 1 @@ -56,11 +59,12 @@ MINOR_10_UNRESTRICTED_NODE_NAME = 10 MINOR_11_ENROLL_STATE = 11 MINOR_12_RAID_CONFIG = 12 MINOR_13_ABORT_VERB = 13 +MINOR_14_LINKS_NODESTATES_DRIVERPROPERTIES = 14 # When adding another version, update MINOR_MAX_VERSION and also update # doc/source/webapi/v1.rst with a detailed explanation of what the version has # changed. -MINOR_MAX_VERSION = MINOR_13_ABORT_VERB +MINOR_MAX_VERSION = MINOR_14_LINKS_NODESTATES_DRIVERPROPERTIES # String representations of the minor and maximum versions MIN_VERSION_STRING = '{}.{}'.format(BASE_VERSION, MINOR_1_INITIAL_VERSION) |