Add --property option to 'server rebuild' command
Add '--property' option to the 'server rebuild' command, to provide the ability to specify properties of the rebuilt instance. This is equivalent to the '--meta' option of the compute's 'nova rebuild' command. Change-Id: I25ea6622e970416090109316e1e28fab8b0b3f07 Story: #2003979 Task: #26922
This commit is contained in:
parent
4e6f47e28e
commit
e3dc30fe8c
@ -1517,6 +1517,13 @@ class RebuildServer(command.ShowOne):
|
||||
metavar='<password>',
|
||||
help=_("Set the password on the rebuilt instance"),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--property',
|
||||
metavar='<key=value>',
|
||||
action=parseractions.KeyValueAction,
|
||||
help=_('Set a property on the rebuilt instance '
|
||||
'(repeat option to set multiple values)'),
|
||||
)
|
||||
parser.add_argument(
|
||||
'--wait',
|
||||
action='store_true',
|
||||
@ -1542,7 +1549,11 @@ class RebuildServer(command.ShowOne):
|
||||
'image', {}).get('id')
|
||||
image = utils.find_resource(image_client.images, image_id)
|
||||
|
||||
server = server.rebuild(image, parsed_args.password)
|
||||
kwargs = {}
|
||||
if parsed_args.property:
|
||||
kwargs['meta'] = parsed_args.property
|
||||
|
||||
server = server.rebuild(image, parsed_args.password, **kwargs)
|
||||
if parsed_args.wait:
|
||||
if utils.wait_for_status(
|
||||
compute_client.servers.get,
|
||||
|
@ -2496,6 +2496,27 @@ class TestServerRebuild(TestServer):
|
||||
self.images_mock.get.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(self.image, None)
|
||||
|
||||
def test_rebuild_with_property(self):
|
||||
arglist = [
|
||||
self.server.id,
|
||||
'--property', 'key1=value1',
|
||||
'--property', 'key2=value2'
|
||||
]
|
||||
expected_property = {'key1': 'value1', 'key2': 'value2'}
|
||||
verifylist = [
|
||||
('server', self.server.id),
|
||||
('property', expected_property)
|
||||
]
|
||||
parsed_args = self.check_parser(self.cmd, arglist, verifylist)
|
||||
|
||||
# Get the command object to test
|
||||
self.cmd.take_action(parsed_args)
|
||||
|
||||
self.servers_mock.get.assert_called_with(self.server.id)
|
||||
self.images_mock.get.assert_called_with(self.image.id)
|
||||
self.server.rebuild.assert_called_with(
|
||||
self.image, None, meta=expected_property)
|
||||
|
||||
|
||||
class TestServerRemoveFixedIP(TestServer):
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Add ``--property`` option to the ``server rebuild`` command, to provide
|
||||
the ability to specify properties of the rebuilt instance.
|
||||
[Story `2003979 <https://storyboard.openstack.org/#!/story/2003979>`_]
|
Loading…
Reference in New Issue
Block a user