[microversions] Add support for 2.14

In I54bfa1275e188573c1b95d770d89160a86cdf52c the onSharedStorage
flag is removed from the evacuate API. This patch removes it from
the novaclient as well.

Implements: bp remove-shared-storage-flag-in-evacuate-api
Change-Id: I5ae75fdac226f0246f22a4d5245c1e4952571fc1
This commit is contained in:
Balazs Gibizer 2015-12-18 16:42:23 +01:00
parent b6677ebc03
commit 5a3956c399
5 changed files with 56 additions and 9 deletions

View File

@ -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.13")
API_MAX_VERSION = api_versions.APIVersion("2.14")

View File

@ -449,7 +449,7 @@ class V1(Base):
keys = list(body[action])
if 'adminPass' in keys:
keys.remove('adminPass')
assert set(keys) == set(['host', 'onSharedStorage'])
assert 'host' in keys
else:
raise AssertionError("Unexpected server action: %s" % action)
return {'server': _body}

View File

@ -871,3 +871,17 @@ class ServersV28Test(ServersV26Test):
self.cs.servers.get_mks_console(s)
self.assert_called('POST', '/servers/1234/remote-consoles')
class ServersV214Test(ServersV28Test):
def setUp(self):
super(ServersV214Test, self).setUp()
self.cs.api_version = api_versions.APIVersion("2.14")
def test_evacuate(self):
s = self.cs.servers.get(1234)
s.evacuate('fake_target_host')
self.assert_called('POST', '/servers/1234/action')
self.cs.servers.evacuate(s, 'fake_target_host',
password='NewAdminPassword')
self.assert_called('POST', '/servers/1234/action')

View File

@ -388,17 +388,28 @@ class Server(base.Resource):
"""
return self.manager.list_security_group(self)
def evacuate(self, host=None, on_shared_storage=True, password=None):
def evacuate(self, host=None, on_shared_storage=None, password=None):
"""
Evacuate an instance from failed host to specified host.
:param host: Name of the target host
:param on_shared_storage: Specifies whether instance files located
on shared storage
on shared storage. After microversion 2.14, this
parameter must have its default value of None.
:param password: string to set as admin password on the evacuated
server.
"""
return self.manager.evacuate(self, host, on_shared_storage, password)
if api_versions.APIVersion("2.14") <= self.manager.api_version:
if on_shared_storage is not None:
raise ValueError("Setting 'on_shared_storage' argument is "
"prohibited after microversion 2.14.")
return self.manager.evacuate(self, host, password)
else:
# microversions 2.0 - 2.13
if on_shared_storage is None:
on_shared_storage = True
return self.manager.evacuate(self, host, on_shared_storage,
password)
def interface_list(self):
"""
@ -1291,6 +1302,7 @@ class ServerManager(base.BootingManagerWithFind):
base.getid(server), 'security_groups',
security_groups.SecurityGroup)
@api_versions.wraps("2.0", "2.13")
def evacuate(self, server, host=None, on_shared_storage=True,
password=None):
"""
@ -1312,6 +1324,25 @@ class ServerManager(base.BootingManagerWithFind):
return self._action('evacuate', server, body)
@api_versions.wraps("2.14")
def evacuate(self, server, host=None, password=None):
"""
Evacuate a server instance.
:param server: The :class:`Server` (or its ID) to share onto.
:param host: Name of the target host.
:param password: string to set as password on the evacuated server.
"""
body = {}
if host is not None:
body['host'] = host
if password is not None:
body['adminPass'] = password
return self._action('evacuate', server, body)
def interface_list(self, server):
"""
List attached network interfaces

View File

@ -4454,19 +4454,21 @@ def do_quota_class_update(cs, args):
dest='password',
metavar='<password>',
help=_("Set the provided admin password on the evacuated server. Not"
" applicable with on-shared-storage flag."))
" applicable if the server is on shared storage."))
@cliutils.arg(
'--on-shared-storage',
dest='on_shared_storage',
action="store_true",
default=False,
help=_('Specifies whether server files are located on shared storage.'))
help=_('Specifies whether server files are located on shared storage.'),
start_version='2.0',
end_version='2.13')
def do_evacuate(cs, args):
"""Evacuate server from failed host."""
server = _find_server(cs, args.server)
res = server.evacuate(args.host, args.on_shared_storage, args.password)[1]
on_shared_storage = getattr(args, 'on_shared_storage', None)
res = server.evacuate(args.host, on_shared_storage, args.password)[1]
if type(res) is dict:
utils.print_dict(res)