Add ability to provide configdrive when rebuilding with OSC
Ironic introduces the API microversion 1.35 which allows configdrive to be provided when setting the node's provisioning state to "rebuild". This change adds the ability to provide a config-drive when rebuilding a node. Closes-bug: #1575935 Change-Id: I950ac35bcde97b0f93225f80f989d42c5519faf2
This commit is contained in:
parent
ac5b86a6d5
commit
0729022076
|
@ -26,7 +26,7 @@ LOG = logging.getLogger(__name__)
|
|||
CLIENT_CLASS = 'ironicclient.v1.client.Client'
|
||||
API_VERSION_OPTION = 'os_baremetal_api_version'
|
||||
API_NAME = 'baremetal'
|
||||
LAST_KNOWN_API_VERSION = 34
|
||||
LAST_KNOWN_API_VERSION = 35
|
||||
LATEST_VERSION = "1.{}".format(LAST_KNOWN_API_VERSION)
|
||||
API_VERSIONS = {
|
||||
'1.%d' % i: CLIENT_CLASS
|
||||
|
|
|
@ -27,6 +27,12 @@ from ironicclient import exc
|
|||
from ironicclient.v1 import resource_fields as res_fields
|
||||
from ironicclient.v1 import utils as v1_utils
|
||||
|
||||
CONFIG_DRIVE_ARG_HELP = _(
|
||||
"A gzipped, base64-encoded configuration drive string OR "
|
||||
"the path to the configuration drive file OR the path to a "
|
||||
"directory containing the config drive files. In case it's "
|
||||
"a directory, a config drive will be generated from it.")
|
||||
|
||||
|
||||
class ProvisionStateBaremetalNode(command.Command):
|
||||
"""Base provision state class"""
|
||||
|
@ -483,10 +489,7 @@ class DeployBaremetalNode(ProvisionStateWithWait):
|
|||
'--config-drive',
|
||||
metavar='<config-drive>',
|
||||
default=None,
|
||||
help=_("A gzipped, base64-encoded configuration drive string OR "
|
||||
"the path to the configuration drive file OR the path to a "
|
||||
"directory containing the config drive files. In case it's "
|
||||
"a directory, a config drive will be generated from it. "))
|
||||
help=CONFIG_DRIVE_ARG_HELP)
|
||||
return parser
|
||||
|
||||
|
||||
|
@ -898,6 +901,16 @@ class RebuildBaremetalNode(ProvisionStateWithWait):
|
|||
log = logging.getLogger(__name__ + ".RebuildBaremetalNode")
|
||||
PROVISION_STATE = 'rebuild'
|
||||
|
||||
def get_parser(self, prog_name):
|
||||
parser = super(RebuildBaremetalNode, self).get_parser(prog_name)
|
||||
|
||||
parser.add_argument(
|
||||
'--config-drive',
|
||||
metavar='<config-drive>',
|
||||
default=None,
|
||||
help=CONFIG_DRIVE_ARG_HELP)
|
||||
return parser
|
||||
|
||||
|
||||
class SetBaremetalNode(command.Command):
|
||||
"""Set baremetal properties"""
|
||||
|
|
|
@ -1489,6 +1489,23 @@ class TestRebuildBaremetalProvisionState(TestBaremetal):
|
|||
# Get the command object to test
|
||||
self.cmd = baremetal_node.RebuildBaremetalNode(self.app, None)
|
||||
|
||||
def test_rebuild_baremetal_provision_state_active_and_configdrive(self):
|
||||
arglist = ['node_uuid',
|
||||
'--config-drive', 'path/to/drive']
|
||||
verifylist = [
|
||||
('node', 'node_uuid'),
|
||||
('provision_state', 'rebuild'),
|
||||
('config_drive', 'path/to/drive'),
|
||||
]
|
||||
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.baremetal_mock.node.set_provision_state.assert_called_once_with(
|
||||
'node_uuid', 'rebuild',
|
||||
cleansteps=None, configdrive='path/to/drive')
|
||||
|
||||
def test_rebuild_no_wait(self):
|
||||
arglist = ['node_uuid']
|
||||
verifylist = [
|
||||
|
@ -1500,6 +1517,10 @@ class TestRebuildBaremetalProvisionState(TestBaremetal):
|
|||
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.baremetal_mock.node.set_provision_state.assert_called_once_with(
|
||||
'node_uuid', 'rebuild',
|
||||
cleansteps=None, configdrive=None)
|
||||
|
||||
self.baremetal_mock.node.wait_for_provision_state.assert_not_called()
|
||||
|
||||
def test_rebuild_baremetal_provision_state_active_and_wait(self):
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
features:
|
||||
- |
|
||||
Adds the ability to specify a configuration drive when
|
||||
rebuilding a node, via the ``--config-drive`` option to the
|
||||
``openstack baremetal node rebuild`` command. This is available starting
|
||||
with ironic API version 1.35.
|
Loading…
Reference in New Issue