Merge "Fix host-evacuate-live for 2.25 microversion" into stable/mitaka

This commit is contained in:
Jenkins 2016-03-30 07:16:55 +00:00 committed by Gerrit Code Review
commit 0e9c46a21a
2 changed files with 41 additions and 4 deletions

View File

@ -1729,6 +1729,15 @@ class ShellTest(utils.TestCase):
self.assert_called('POST', '/servers/uuid3/action', body, pos=3)
self.assert_called('POST', '/servers/uuid4/action', body, pos=4)
def test_host_evacuate_live_2_25(self):
self.run_command('host-evacuate-live hyper', api_version='2.25')
self.assert_called('GET', '/os-hypervisors/hyper/servers', pos=0)
body = {'os-migrateLive': {'host': None, 'block_migration': 'auto'}}
self.assert_called('POST', '/servers/uuid1/action', body, pos=1)
self.assert_called('POST', '/servers/uuid2/action', body, pos=2)
self.assert_called('POST', '/servers/uuid3/action', body, pos=3)
self.assert_called('POST', '/servers/uuid4/action', body, pos=4)
def test_host_evacuate_live_with_target_host(self):
self.run_command('host-evacuate-live hyper '
'--target-host hostname')
@ -1752,6 +1761,16 @@ class ShellTest(utils.TestCase):
self.assert_called('POST', '/servers/uuid3/action', body, pos=3)
self.assert_called('POST', '/servers/uuid4/action', body, pos=4)
def test_host_evacuate_live_with_block_migration_2_25(self):
self.run_command('host-evacuate-live --block-migrate hyper',
api_version='2.25')
self.assert_called('GET', '/os-hypervisors/hyper/servers', pos=0)
body = {'os-migrateLive': {'host': None, 'block_migration': True}}
self.assert_called('POST', '/servers/uuid1/action', body, pos=1)
self.assert_called('POST', '/servers/uuid2/action', body, pos=2)
self.assert_called('POST', '/servers/uuid3/action', body, pos=3)
self.assert_called('POST', '/servers/uuid4/action', body, pos=4)
def test_host_evacuate_live_with_disk_over_commit(self):
self.run_command('host-evacuate-live --disk-over-commit hyper')
self.assert_called('GET', '/os-hypervisors/hyper/servers', pos=0)
@ -1763,6 +1782,11 @@ class ShellTest(utils.TestCase):
self.assert_called('POST', '/servers/uuid3/action', body, pos=3)
self.assert_called('POST', '/servers/uuid4/action', body, pos=4)
def test_host_evacuate_live_with_disk_over_commit_2_25(self):
self.assertRaises(SystemExit, self.run_command,
'host-evacuate-live --disk-over-commit hyper',
api_version='2.25')
def test_host_evacuate_list_with_max_servers(self):
self.run_command('host-evacuate-live --max-servers 1 hyper')
self.assert_called('GET', '/os-hypervisors/hyper/servers', pos=0)

View File

@ -28,8 +28,13 @@ def _server_live_migrate(cs, server, args):
success = True
error_message = ""
try:
cs.servers.live_migrate(server['uuid'], args.target_host,
args.block_migrate, args.disk_over_commit)
# API 2.0->2.24
if 'disk_over_commit' in args:
cs.servers.live_migrate(server['uuid'], args.target_host,
args.block_migrate, args.disk_over_commit)
else: # API 2.25+
cs.servers.live_migrate(server['uuid'], args.target_host,
args.block_migrate)
except Exception as e:
success = False
error_message = _("Error while live migrating instance: %s") % e
@ -48,12 +53,20 @@ def _server_live_migrate(cs, server, args):
'--block-migrate',
action='store_true',
default=False,
help=_('Enable block migration.'))
help=_('Enable block migration. (Default=False)'),
start_version="2.0", end_version="2.24")
@cliutils.arg(
'--block-migrate',
action='store_true',
default="auto",
help=_('Enable block migration. (Default=auto)'),
start_version="2.25")
@cliutils.arg(
'--disk-over-commit',
action='store_true',
default=False,
help=_('Enable disk overcommit.'))
help=_('Enable disk overcommit.'),
start_version="2.0", end_version="2.24")
@cliutils.arg(
'--max-servers',
type=int,