Microversion 2.52 - Support tag when boot
Change-Id: Ib65894f0e128c599db8d3440fe5a8427e62d5782 Depends-On: Ifcaaf285c8f98a1d0e8bbbc87b2f57fbce057346 Implements: blueprint support-tag-instance-when-boot
This commit is contained in:
parent
24e4e92c1e
commit
30c9215da7
@ -25,4 +25,4 @@ API_MIN_VERSION = api_versions.APIVersion("2.1")
|
||||
# when client supported the max version, and bumped sequentially, otherwise
|
||||
# the client may break due to server side new version may include some
|
||||
# backward incompatible change.
|
||||
API_MAX_VERSION = api_versions.APIVersion("2.51")
|
||||
API_MAX_VERSION = api_versions.APIVersion("2.52")
|
||||
|
@ -1483,3 +1483,47 @@ class ServersV249Test(ServersV2_37Test):
|
||||
# novaclient.v2.servers.Server.remove_fixed_ip()
|
||||
# is not available after 2.44
|
||||
pass
|
||||
|
||||
|
||||
class ServersV252Test(ServersV249Test):
|
||||
|
||||
api_version = "2.52"
|
||||
|
||||
def test_create_server_with_tags(self):
|
||||
self.cs.servers.create(
|
||||
name="My server",
|
||||
image=1,
|
||||
flavor=1,
|
||||
meta={'foo': 'bar'},
|
||||
userdata="hello moto",
|
||||
key_name="fakekey",
|
||||
nics=self._get_server_create_default_nics(),
|
||||
tags=['tag1', 'tag2']
|
||||
)
|
||||
self.assert_called('POST', '/servers',
|
||||
{'server': {
|
||||
'flavorRef': '1',
|
||||
'imageRef': '1',
|
||||
'key_name': 'fakekey',
|
||||
'max_count': 1,
|
||||
'metadata': {'foo': 'bar'},
|
||||
'min_count': 1,
|
||||
'name': 'My server',
|
||||
'networks': 'auto',
|
||||
'tags': ['tag1', 'tag2'],
|
||||
'user_data': 'aGVsbG8gbW90bw=='
|
||||
}}
|
||||
)
|
||||
|
||||
def test_create_server_with_tags_pre_252_fails(self):
|
||||
self.cs.api_version = api_versions.APIVersion('2.51')
|
||||
self.assertRaises(exceptions.UnsupportedAttribute,
|
||||
self.cs.servers.create,
|
||||
name="My server",
|
||||
image=1,
|
||||
flavor=1,
|
||||
meta={'foo': 'bar'},
|
||||
userdata="hello moto",
|
||||
key_name="fakekey",
|
||||
nics=self._get_server_create_default_nics(),
|
||||
tags=['tag1', 'tag2'])
|
||||
|
@ -1068,6 +1068,45 @@ class ShellTest(utils.TestCase):
|
||||
FAKE_UUID_1)
|
||||
self.assertRaises(argparse.ArgumentTypeError, self.run_command, cmd)
|
||||
|
||||
def test_boot_with_tags(self):
|
||||
self.run_command('boot --flavor 1 --image %s --nic auto '
|
||||
'some-server --tags tag1,tag2' % FAKE_UUID_1,
|
||||
api_version='2.52')
|
||||
self.assert_called_anytime(
|
||||
'POST', '/servers',
|
||||
{'server': {
|
||||
'flavorRef': '1',
|
||||
'name': 'some-server',
|
||||
'imageRef': FAKE_UUID_1,
|
||||
'min_count': 1,
|
||||
'max_count': 1,
|
||||
'networks': 'auto',
|
||||
'tags': ['tag1', 'tag2']
|
||||
}},
|
||||
)
|
||||
|
||||
def test_boot_without_tags_v252(self):
|
||||
self.run_command('boot --flavor 1 --image %s --nic auto '
|
||||
'some-server' % FAKE_UUID_1,
|
||||
api_version='2.52')
|
||||
self.assert_called_anytime(
|
||||
'POST', '/servers',
|
||||
{'server': {
|
||||
'flavorRef': '1',
|
||||
'name': 'some-server',
|
||||
'imageRef': FAKE_UUID_1,
|
||||
'min_count': 1,
|
||||
'max_count': 1,
|
||||
'networks': 'auto',
|
||||
}},
|
||||
)
|
||||
|
||||
def test_boot_with_tags_pre_v2_52(self):
|
||||
cmd = ('boot --flavor 1 --image %s some-server '
|
||||
'--tags tag1,tag2' % FAKE_UUID_1)
|
||||
self.assertRaises(SystemExit, self.run_command,
|
||||
cmd, api_version='2.51')
|
||||
|
||||
def test_flavor_list(self):
|
||||
self.run_command('flavor-list')
|
||||
self.assert_called_anytime('GET', '/flavors/detail')
|
||||
@ -3020,6 +3059,7 @@ class ShellTest(utils.TestCase):
|
||||
# within the server details
|
||||
48, # There are no version-wrapped shell method changes for this.
|
||||
51, # There are no version-wrapped shell method changes for this.
|
||||
52, # There are no version-wrapped shell method changes for this.
|
||||
])
|
||||
versions_supported = set(range(0,
|
||||
novaclient.API_MAX_VERSION.ver_minor + 1))
|
||||
|
@ -663,7 +663,7 @@ class ServerManager(base.BootingManagerWithFind):
|
||||
block_device_mapping_v2=None, nics=None, scheduler_hints=None,
|
||||
config_drive=None, admin_pass=None, disk_config=None,
|
||||
access_ip_v4=None, access_ip_v6=None, description=None,
|
||||
**kwargs):
|
||||
tags=None, **kwargs):
|
||||
"""
|
||||
Create (boot) a new server.
|
||||
"""
|
||||
@ -795,6 +795,9 @@ class ServerManager(base.BootingManagerWithFind):
|
||||
if description:
|
||||
body['server']['description'] = description
|
||||
|
||||
if tags:
|
||||
body['server']['tags'] = tags
|
||||
|
||||
return self._create(resource_url, body, response_key,
|
||||
return_raw=return_raw, **kwargs)
|
||||
|
||||
@ -1337,6 +1340,8 @@ class ServerManager(base.BootingManagerWithFind):
|
||||
:param access_ip_v6: (optional extension) add alternative access ip v6
|
||||
:param description: optional description of the server (allowed since
|
||||
microversion 2.19)
|
||||
:param tags: A list of arbitrary strings to be added to the
|
||||
server as tags (allowed since microversion 2.52)
|
||||
"""
|
||||
if not min_count:
|
||||
min_count = 1
|
||||
@ -1369,6 +1374,10 @@ class ServerManager(base.BootingManagerWithFind):
|
||||
"unsupported before microversion "
|
||||
"2.32")
|
||||
|
||||
boot_tags_microversion = api_versions.APIVersion("2.52")
|
||||
if "tags" in kwargs and self.api_version < boot_tags_microversion:
|
||||
raise exceptions.UnsupportedAttribute("tags", "2.52")
|
||||
|
||||
boot_kwargs = dict(
|
||||
meta=meta, files=files, userdata=userdata,
|
||||
reservation_id=reservation_id, min_count=min_count,
|
||||
|
@ -530,6 +530,9 @@ def _boot(cs, args):
|
||||
if 'description' in args:
|
||||
boot_kwargs["description"] = args.description
|
||||
|
||||
if 'tags' in args and args.tags:
|
||||
boot_kwargs["tags"] = args.tags.split(',')
|
||||
|
||||
return boot_args, boot_kwargs
|
||||
|
||||
|
||||
@ -877,6 +880,13 @@ def _boot(cs, args):
|
||||
default=None,
|
||||
help=_('Description for the server.'),
|
||||
start_version="2.19")
|
||||
@utils.arg(
|
||||
'--tags',
|
||||
metavar='<tags>',
|
||||
default=None,
|
||||
help=_('Tags for the server.'
|
||||
'Tags must be separated by commas: --tags <tag1,tag2>'),
|
||||
start_version="2.52")
|
||||
def do_boot(cs, args):
|
||||
"""Boot a new server."""
|
||||
boot_args, boot_kwargs = _boot(cs, args)
|
||||
|
@ -0,0 +1,8 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
`Microversion 2.52`_ is now supported which adds the ``--tags`` option to
|
||||
the ``nova boot`` command and a ``tags`` kwarg to the
|
||||
``novaclient.v2.servers.ServerManager.create()`` python API binding method.
|
||||
|
||||
.. _Microversion 2.52: https://docs.openstack.org/nova/latest/api_microversion_history.html#id47
|
Loading…
Reference in New Issue
Block a user