baremetal: support server-side configdrive building (API 1.56)
Bare Metal API 1.56 allows passing a dictionary for configdrive. Change-Id: Ib245801ae326754a9ba319d29b0507cd759fdb4c Story: #2005083 Task: #29875
This commit is contained in:
parent
da4ec3e70c
commit
371db82c6e
@ -296,13 +296,17 @@ class Node(_common.ListMixin, resource.Resource):
|
||||
"""
|
||||
session = self._get_session(session)
|
||||
|
||||
version = None
|
||||
if target in _common.PROVISIONING_VERSIONS:
|
||||
version = '1.%d' % _common.PROVISIONING_VERSIONS[target]
|
||||
else:
|
||||
if config_drive and target == 'rebuild':
|
||||
|
||||
if config_drive:
|
||||
# Some config drive actions require a higher version.
|
||||
if isinstance(config_drive, dict):
|
||||
version = '1.56'
|
||||
elif target == 'rebuild':
|
||||
version = '1.35'
|
||||
else:
|
||||
version = None
|
||||
|
||||
version = utils.pick_microversion(session, version)
|
||||
|
||||
body = {'target': target}
|
||||
|
@ -225,7 +225,54 @@ class TestNodeSetProvisionState(base.TestCase):
|
||||
default_microversion=None)
|
||||
|
||||
def test_no_arguments(self):
|
||||
self.node.set_provision_state(self.session, 'manage')
|
||||
result = self.node.set_provision_state(self.session, 'active')
|
||||
self.assertIs(result, self.node)
|
||||
self.session.put.assert_called_once_with(
|
||||
'nodes/%s/states/provision' % self.node.id,
|
||||
json={'target': 'active'},
|
||||
headers=mock.ANY, microversion=None,
|
||||
retriable_status_codes=_common.RETRIABLE_STATUS_CODES)
|
||||
|
||||
def test_manage(self):
|
||||
result = self.node.set_provision_state(self.session, 'manage')
|
||||
self.assertIs(result, self.node)
|
||||
self.session.put.assert_called_once_with(
|
||||
'nodes/%s/states/provision' % self.node.id,
|
||||
json={'target': 'manage'},
|
||||
headers=mock.ANY, microversion='1.4',
|
||||
retriable_status_codes=_common.RETRIABLE_STATUS_CODES)
|
||||
|
||||
def test_deploy_with_configdrive(self):
|
||||
result = self.node.set_provision_state(self.session, 'active',
|
||||
config_drive='abcd')
|
||||
self.assertIs(result, self.node)
|
||||
self.session.put.assert_called_once_with(
|
||||
'nodes/%s/states/provision' % self.node.id,
|
||||
json={'target': 'active', 'configdrive': 'abcd'},
|
||||
headers=mock.ANY, microversion=None,
|
||||
retriable_status_codes=_common.RETRIABLE_STATUS_CODES)
|
||||
|
||||
def test_rebuild_with_configdrive(self):
|
||||
result = self.node.set_provision_state(self.session, 'rebuild',
|
||||
config_drive='abcd')
|
||||
self.assertIs(result, self.node)
|
||||
self.session.put.assert_called_once_with(
|
||||
'nodes/%s/states/provision' % self.node.id,
|
||||
json={'target': 'rebuild', 'configdrive': 'abcd'},
|
||||
headers=mock.ANY, microversion='1.35',
|
||||
retriable_status_codes=_common.RETRIABLE_STATUS_CODES)
|
||||
|
||||
def test_configdrive_as_dict(self):
|
||||
for target in ('rebuild', 'active'):
|
||||
self.session.put.reset_mock()
|
||||
result = self.node.set_provision_state(
|
||||
self.session, target, config_drive={'user_data': 'abcd'})
|
||||
self.assertIs(result, self.node)
|
||||
self.session.put.assert_called_once_with(
|
||||
'nodes/%s/states/provision' % self.node.id,
|
||||
json={'target': target, 'configdrive': {'user_data': 'abcd'}},
|
||||
headers=mock.ANY, microversion='1.56',
|
||||
retriable_status_codes=_common.RETRIABLE_STATUS_CODES)
|
||||
|
||||
|
||||
@mock.patch.object(node.Node, '_translate_response', mock.Mock())
|
||||
|
5
releasenotes/notes/configdrive-f8ca9f94b2981db7.yaml
Normal file
5
releasenotes/notes/configdrive-f8ca9f94b2981db7.yaml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Supports Bare Metal API version 1.56, which allows building a config drive
|
||||
on the server side from a provided dictionary.
|
Loading…
Reference in New Issue
Block a user