Merge "Support per-call version: set_provision_state"
This commit is contained in:
commit
5448011fdf
@ -185,18 +185,24 @@ class Manager(object):
|
||||
def _list_primitives(self, url, response_key=None):
|
||||
return self.__list(url, response_key=response_key)
|
||||
|
||||
def _update(self, resource_id, patch, method='PATCH'):
|
||||
def _update(self, resource_id, patch, method='PATCH',
|
||||
os_ironic_api_version=None):
|
||||
"""Update a resource.
|
||||
|
||||
:param resource_id: Resource identifier.
|
||||
:param patch: New version of a given resource, a dictionary or None.
|
||||
:param method: Name of the method for the request.
|
||||
:param os_ironic_api_version: String version (e.g. "1.35") to use for
|
||||
the request. If not specified, the client's default is used.
|
||||
"""
|
||||
|
||||
url = self._path(resource_id)
|
||||
kwargs = {}
|
||||
if patch is not None:
|
||||
kwargs['body'] = patch
|
||||
if os_ironic_api_version is not None:
|
||||
kwargs['headers'] = {'X-OpenStack-Ironic-API-Version':
|
||||
os_ironic_api_version}
|
||||
resp, body = self.api.json_request(method, url, **kwargs)
|
||||
# PATCH/PUT requests may not return a body
|
||||
if body:
|
||||
|
@ -1298,6 +1298,17 @@ class NodeManagerTest(testtools.TestCase):
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
|
||||
def test_node_set_provision_state_microversion_override(self):
|
||||
target_state = 'active'
|
||||
self.mgr.set_provision_state(NODE1['uuid'], target_state,
|
||||
os_ironic_api_version="1.35")
|
||||
body = {'target': target_state}
|
||||
expect = [
|
||||
('PUT', '/v1/nodes/%s/states/provision' % NODE1['uuid'],
|
||||
{'X-OpenStack-Ironic-API-Version': '1.35'}, body),
|
||||
]
|
||||
self.assertEqual(expect, self.api.calls)
|
||||
|
||||
def test_node_set_provision_state_with_configdrive(self):
|
||||
target_state = 'active'
|
||||
self.mgr.set_provision_state(NODE1['uuid'], target_state,
|
||||
|
@ -336,9 +336,11 @@ class NodeManager(base.CreateManager):
|
||||
def delete(self, node_id):
|
||||
return self._delete(resource_id=node_id)
|
||||
|
||||
def update(self, node_id, patch, http_method='PATCH'):
|
||||
def update(self, node_id, patch, http_method='PATCH',
|
||||
os_ironic_api_version=None):
|
||||
return self._update(resource_id=node_id, patch=patch,
|
||||
method=http_method)
|
||||
method=http_method,
|
||||
os_ironic_api_version=os_ironic_api_version)
|
||||
|
||||
def vendor_passthru(self, node_id, method, args=None,
|
||||
http_method=None):
|
||||
@ -483,7 +485,8 @@ class NodeManager(base.CreateManager):
|
||||
return self.get(path)
|
||||
|
||||
def set_provision_state(self, node_uuid, state, configdrive=None,
|
||||
cleansteps=None, rescue_password=None):
|
||||
cleansteps=None, rescue_password=None,
|
||||
os_ironic_api_version=None):
|
||||
"""Set the provision state for the node.
|
||||
|
||||
:param node_uuid: The UUID or name of the node.
|
||||
@ -502,6 +505,8 @@ class NodeManager(base.CreateManager):
|
||||
:param rescue_password: A string to be used as the login password
|
||||
inside the rescue ramdisk once a node is rescued. This must be
|
||||
specified (and is only valid) when setting 'state' to 'rescue'.
|
||||
:param os_ironic_api_version: String version (e.g. "1.35") to use for
|
||||
the request. If not specified, the client's default is used.
|
||||
:raises: InvalidAttribute if there was an error with the clean steps
|
||||
:returns: The status of the request
|
||||
"""
|
||||
@ -521,7 +526,8 @@ class NodeManager(base.CreateManager):
|
||||
elif rescue_password:
|
||||
body['rescue_password'] = rescue_password
|
||||
|
||||
return self.update(path, body, http_method='PUT')
|
||||
return self.update(path, body, http_method='PUT',
|
||||
os_ironic_api_version=os_ironic_api_version)
|
||||
|
||||
def states(self, node_uuid):
|
||||
path = "%s/states" % node_uuid
|
||||
|
Loading…
Reference in New Issue
Block a user