[microversion] Bump to 2.25
microversion v2.25 will change parameter of os-migrateLive, this patch adds supports to that changes. os-migrateLive will abandon disk_over_commit and the default value of block_migration will be set to `auto` Depends-on: Ibb0d50f0f7444028ef9d0c294aea41edf0024b31 Implements: blueprint making-live-migration-api-friendly Change-Id: I01b22593724616bc0a7793c509ecabf095d6927d
This commit is contained in:
parent
77e50cc91b
commit
ae598280ac
@ -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.24")
|
||||
API_MAX_VERSION = api_versions.APIVersion("2.25")
|
||||
|
@ -425,6 +425,11 @@ class V1(Base):
|
||||
# if we found 'action' in method check_server_actions and
|
||||
# raise AssertionError if we didn't find 'action' at all.
|
||||
pass
|
||||
elif action == 'os-migrateLive':
|
||||
# Fixme(eliqiao): body of os-migrateLive changes from v2.25
|
||||
# but we can not specify version in data_fixture now and this is
|
||||
# V1 data, so just let it pass
|
||||
pass
|
||||
elif action == 'rebuild':
|
||||
body = body[action]
|
||||
adminPass = body.get('adminPass', 'randompassword')
|
||||
|
@ -710,9 +710,6 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
assert list(body[action]) == ['adminPass']
|
||||
elif action in cls.type_actions:
|
||||
assert list(body[action]) == ['type']
|
||||
elif action == 'os-migrateLive':
|
||||
assert set(body[action].keys()) == set(['host', 'block_migration',
|
||||
'disk_over_commit'])
|
||||
elif action == 'os-resetState':
|
||||
assert list(body[action]) == ['state']
|
||||
elif action == 'resetNetwork':
|
||||
@ -741,6 +738,14 @@ class FakeHTTPClient(base_client.HTTPClient):
|
||||
# if we found 'action' in method check_server_actions and
|
||||
# raise AssertionError if we didn't find 'action' at all.
|
||||
pass
|
||||
elif action == 'os-migrateLive':
|
||||
if self.api_version < api_versions.APIVersion("2.25"):
|
||||
assert set(body[action].keys()) == set(['host',
|
||||
'block_migration',
|
||||
'disk_over_commit'])
|
||||
else:
|
||||
assert set(body[action].keys()) == set(['host',
|
||||
'block_migration'])
|
||||
elif action == 'rebuild':
|
||||
body = body[action]
|
||||
adminPass = body.get('adminPass', 'randompassword')
|
||||
|
@ -841,12 +841,28 @@ class ServersTest(utils.FixturedTestCase):
|
||||
ret = s.live_migrate(host='hostname', block_migration=False,
|
||||
disk_over_commit=False)
|
||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||
self.assert_called('POST', '/servers/1234/action')
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'os-migrateLive': {'host': 'hostname',
|
||||
'block_migration': False,
|
||||
'disk_over_commit': False}})
|
||||
ret = self.cs.servers.live_migrate(s, host='hostname',
|
||||
block_migration=False,
|
||||
disk_over_commit=False)
|
||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||
self.assert_called('POST', '/servers/1234/action')
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'os-migrateLive': {'host': 'hostname',
|
||||
'block_migration': False,
|
||||
'disk_over_commit': False}})
|
||||
|
||||
def test_live_migrate_server_block_migration_none(self):
|
||||
s = self.cs.servers.get(1234)
|
||||
ret = s.live_migrate(host='hostname', block_migration=None,
|
||||
disk_over_commit=None)
|
||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'os-migrateLive': {'host': 'hostname',
|
||||
'block_migration': False,
|
||||
'disk_over_commit': False}})
|
||||
|
||||
def test_reset_state(self):
|
||||
s = self.cs.servers.get(1234)
|
||||
@ -1077,3 +1093,58 @@ class ServersV219Test(ServersV217Test):
|
||||
ret = s.rebuild(image="1", description="descr")
|
||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||
self.assert_called('POST', '/servers/1234/action')
|
||||
|
||||
|
||||
class ServersV225Test(ServersV219Test):
|
||||
def setUp(self):
|
||||
super(ServersV219Test, self).setUp()
|
||||
self.cs.api_version = api_versions.APIVersion("2.25")
|
||||
|
||||
def test_live_migrate_server(self):
|
||||
s = self.cs.servers.get(1234)
|
||||
ret = s.live_migrate(host='hostname', block_migration='auto')
|
||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'os-migrateLive': {'host': 'hostname',
|
||||
'block_migration': 'auto'}})
|
||||
ret = self.cs.servers.live_migrate(s, host='hostname',
|
||||
block_migration='auto')
|
||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'os-migrateLive': {'host': 'hostname',
|
||||
'block_migration': 'auto'}})
|
||||
|
||||
def test_live_migrate_server_block_migration_true(self):
|
||||
s = self.cs.servers.get(1234)
|
||||
ret = s.live_migrate(host='hostname', block_migration=True)
|
||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'os-migrateLive': {'host': 'hostname',
|
||||
'block_migration': True}})
|
||||
|
||||
ret = self.cs.servers.live_migrate(s, host='hostname',
|
||||
block_migration=True)
|
||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'os-migrateLive': {'host': 'hostname',
|
||||
'block_migration': True}})
|
||||
|
||||
def test_live_migrate_server_block_migration_none(self):
|
||||
s = self.cs.servers.get(1234)
|
||||
ret = s.live_migrate(host='hostname', block_migration=None)
|
||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'os-migrateLive': {'host': 'hostname',
|
||||
'block_migration': 'auto'}})
|
||||
|
||||
ret = self.cs.servers.live_migrate(s, host='hostname',
|
||||
block_migration='auto')
|
||||
self.assert_request_id(ret, fakes.FAKE_REQUEST_ID_LIST)
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'os-migrateLive': {'host': 'hostname',
|
||||
'block_migration': 'auto'}})
|
||||
|
||||
def test_live_migrate_server_with_disk_over_commit(self):
|
||||
s = self.cs.servers.get(1234)
|
||||
self.assertRaises(ValueError, s.live_migrate, 'hostname',
|
||||
'auto', 'True')
|
||||
|
@ -1681,6 +1681,22 @@ class ShellTest(utils.TestCase):
|
||||
'block_migration': True,
|
||||
'disk_over_commit': True}})
|
||||
|
||||
def test_live_migration_v225(self):
|
||||
self.run_command('live-migration sample-server hostname',
|
||||
api_version='2.25')
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'os-migrateLive': {'host': 'hostname',
|
||||
'block_migration': 'auto'}})
|
||||
self.run_command('live-migration sample-server hostname'
|
||||
' --block-migrate', api_version='2.25')
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'os-migrateLive': {'host': 'hostname',
|
||||
'block_migration': True}})
|
||||
self.run_command('live-migration sample-server', api_version='2.25')
|
||||
self.assert_called('POST', '/servers/1234/action',
|
||||
{'os-migrateLive': {'host': None,
|
||||
'block_migration': 'auto'}})
|
||||
|
||||
def test_live_migration_force_complete(self):
|
||||
self.run_command('live-migration-force-complete sample-server 1',
|
||||
api_version='2.22')
|
||||
|
@ -408,19 +408,42 @@ class Server(base.Resource):
|
||||
return {}
|
||||
|
||||
def live_migrate(self, host=None,
|
||||
block_migration=False,
|
||||
disk_over_commit=False):
|
||||
block_migration=None,
|
||||
disk_over_commit=None):
|
||||
"""
|
||||
Migrates a running instance to a new machine.
|
||||
|
||||
:param host: destination host name.
|
||||
:param block_migration: if True, do block_migration.
|
||||
:param disk_over_commit: if True, Allow overcommit.
|
||||
:param block_migration: if True, do block_migration, the default
|
||||
value None will be mapped to False for 2.0 -
|
||||
2.24, 'auto' for higher than 2.25
|
||||
:param disk_over_commit: if True, allow disk over commit, the default
|
||||
value None will be mapped to False. It will
|
||||
not be supported since 2.25
|
||||
:returns: An instance of novaclient.base.TupleWithMeta
|
||||
"""
|
||||
return self.manager.live_migrate(self, host,
|
||||
block_migration,
|
||||
disk_over_commit)
|
||||
|
||||
if (self.manager.api_version < api_versions.APIVersion("2.25")):
|
||||
# NOTE(eliqiao): We do this to keep old version api has same
|
||||
# default value if user don't pass these parameters when using
|
||||
# SDK
|
||||
if block_migration is None:
|
||||
block_migration = False
|
||||
if disk_over_commit is None:
|
||||
disk_over_commit = False
|
||||
|
||||
return self.manager.live_migrate(self, host,
|
||||
block_migration,
|
||||
disk_over_commit)
|
||||
else:
|
||||
if block_migration is None:
|
||||
block_migration = 'auto'
|
||||
if disk_over_commit is not None:
|
||||
raise ValueError("Setting 'disk_over_commit' argument is "
|
||||
"prohibited after microversion 2.25.")
|
||||
|
||||
return self.manager.live_migrate(self, host,
|
||||
block_migration)
|
||||
|
||||
def reset_state(self, state='error'):
|
||||
"""
|
||||
@ -1487,6 +1510,7 @@ class ServerManager(base.BootingManagerWithFind):
|
||||
|
||||
return result
|
||||
|
||||
@api_versions.wraps('2.0', '2.24')
|
||||
def live_migrate(self, server, host, block_migration, disk_over_commit):
|
||||
"""
|
||||
Migrates a running instance to a new machine.
|
||||
@ -1494,7 +1518,7 @@ class ServerManager(base.BootingManagerWithFind):
|
||||
:param server: instance id which comes from nova list.
|
||||
:param host: destination host name.
|
||||
:param block_migration: if True, do block_migration.
|
||||
:param disk_over_commit: if True, Allow overcommit.
|
||||
:param disk_over_commit: if True, allow disk overcommit.
|
||||
:returns: An instance of novaclient.base.TupleWithMeta
|
||||
"""
|
||||
return self._action('os-migrateLive', server,
|
||||
@ -1502,6 +1526,21 @@ class ServerManager(base.BootingManagerWithFind):
|
||||
'block_migration': block_migration,
|
||||
'disk_over_commit': disk_over_commit})
|
||||
|
||||
@api_versions.wraps('2.25')
|
||||
def live_migrate(self, server, host, block_migration):
|
||||
"""
|
||||
Migrates a running instance to a new machine.
|
||||
|
||||
:param server: instance id which comes from nova list.
|
||||
:param host: destination host name.
|
||||
:param block_migration: if True, do block_migration, can be set as
|
||||
'auto'
|
||||
:returns: An instance of novaclient.base.TupleWithMeta
|
||||
"""
|
||||
return self._action('os-migrateLive', server,
|
||||
{'host': host,
|
||||
'block_migration': block_migration})
|
||||
|
||||
def reset_state(self, server, state='error'):
|
||||
"""
|
||||
Reset the state of an instance to active or error.
|
||||
|
@ -3810,7 +3810,15 @@ def _print_aggregate_details(aggregate):
|
||||
action='store_true',
|
||||
dest='block_migrate',
|
||||
default=False,
|
||||
help=_('True in case of block_migration. (Default=False:live_migration)'))
|
||||
help=_('True in case of block_migration. (Default=False:live_migration)'),
|
||||
start_version="2.0", end_version="2.24")
|
||||
@cliutils.arg(
|
||||
'--block-migrate',
|
||||
action='store_true',
|
||||
dest='block_migrate',
|
||||
default="auto",
|
||||
help=_('True in case of block_migration. (Default=auto:live_migration)'),
|
||||
start_version="2.25")
|
||||
@cliutils.arg(
|
||||
'--block_migrate',
|
||||
real_action='store_true',
|
||||
@ -3823,19 +3831,26 @@ def _print_aggregate_details(aggregate):
|
||||
action='store_true',
|
||||
dest='disk_over_commit',
|
||||
default=False,
|
||||
help=_('Allow overcommit. (Default=False)'))
|
||||
help=_('Allow overcommit. (Default=False)'),
|
||||
start_version="2.0", end_version="2.24")
|
||||
@cliutils.arg(
|
||||
'--disk_over_commit',
|
||||
real_action='store_true',
|
||||
action=shell.DeprecatedAction,
|
||||
use=_('use "%s"; this option will be removed in '
|
||||
'novaclient 3.3.0.') % '--disk-over-commit',
|
||||
help=argparse.SUPPRESS)
|
||||
help=argparse.SUPPRESS,
|
||||
start_version="2.0", end_version="2.24")
|
||||
def do_live_migration(cs, args):
|
||||
"""Migrate running server to a new machine."""
|
||||
_find_server(cs, args.server).live_migrate(args.host,
|
||||
args.block_migrate,
|
||||
args.disk_over_commit)
|
||||
|
||||
if 'disk_over_commit' in args:
|
||||
_find_server(cs, args.server).live_migrate(args.host,
|
||||
args.block_migrate,
|
||||
args.disk_over_commit)
|
||||
else:
|
||||
_find_server(cs, args.server).live_migrate(args.host,
|
||||
args.block_migrate)
|
||||
|
||||
|
||||
@api_versions.wraps("2.22")
|
||||
|
Loading…
x
Reference in New Issue
Block a user