summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-03-30 07:16:55 +0000
committerGerrit Code Review <review@openstack.org>2016-03-30 07:16:56 +0000
commit0e9c46a21a2b8579794612c269cecd2c05a819ef (patch)
tree097ec6bf9ee83ef322582312f64929cf950fd1a8
parente5afdbb42ec044b1e7970f307e2a7d3830f7126d (diff)
parentb269aa4d7f40f259642474227e9258e982155f0d (diff)
downloadpython-novaclient-0e9c46a21a2b8579794612c269cecd2c05a819ef.tar.gz
Merge "Fix host-evacuate-live for 2.25 microversion" into stable/mitaka3.3.1
-rw-r--r--novaclient/tests/unit/v2/test_shell.py24
-rw-r--r--novaclient/v2/contrib/host_evacuate_live.py21
2 files changed, 41 insertions, 4 deletions
diff --git a/novaclient/tests/unit/v2/test_shell.py b/novaclient/tests/unit/v2/test_shell.py
index 68bc1b4e..758faa47 100644
--- a/novaclient/tests/unit/v2/test_shell.py
+++ b/novaclient/tests/unit/v2/test_shell.py
@@ -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)
diff --git a/novaclient/v2/contrib/host_evacuate_live.py b/novaclient/v2/contrib/host_evacuate_live.py
index f91599bb..8db4fa84 100644
--- a/novaclient/v2/contrib/host_evacuate_live.py
+++ b/novaclient/v2/contrib/host_evacuate_live.py
@@ -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,