@@ -2528,6 +2528,32 @@ def test_server_migrate_no_options(self):
25282528 self .assertNotCalled (self .servers_mock .live_migrate )
25292529 self .assertIsNone (result )
25302530
2531+ def test_server_migrate_with_host_2_56 (self ):
2532+ # Tests that --host is allowed for a cold migration
2533+ # for microversion 2.56 and greater.
2534+ arglist = [
2535+ '--host' , 'fakehost' , self .server .id ,
2536+ ]
2537+ verifylist = [
2538+ ('live' , None ),
2539+ ('live_migration' , False ),
2540+ ('host' , 'fakehost' ),
2541+ ('block_migration' , False ),
2542+ ('disk_overcommit' , False ),
2543+ ('wait' , False ),
2544+ ]
2545+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
2546+
2547+ self .app .client_manager .compute .api_version = \
2548+ api_versions .APIVersion ('2.56' )
2549+
2550+ result = self .cmd .take_action (parsed_args )
2551+
2552+ self .servers_mock .get .assert_called_with (self .server .id )
2553+ self .server .migrate .assert_called_with (host = 'fakehost' )
2554+ self .assertNotCalled (self .servers_mock .live_migrate )
2555+ self .assertIsNone (result )
2556+
25312557 def test_server_migrate_with_block_migration (self ):
25322558 arglist = [
25332559 '--block-migration' , self .server .id ,
@@ -2566,8 +2592,9 @@ def test_server_migrate_with_disk_overcommit(self):
25662592 self .assertNotCalled (self .servers_mock .live_migrate )
25672593 self .assertNotCalled (self .servers_mock .migrate )
25682594
2569- def test_server_migrate_with_host (self ):
2570- # Tests that --host is not allowed for a cold migration.
2595+ def test_server_migrate_with_host_pre_2_56 (self ):
2596+ # Tests that --host is not allowed for a cold migration
2597+ # before microversion 2.56 (the test defaults to 2.1).
25712598 arglist = [
25722599 '--host' , 'fakehost' , self .server .id ,
25732600 ]
@@ -2585,9 +2612,10 @@ def test_server_migrate_with_host(self):
25852612 parsed_args )
25862613
25872614 # Make sure it's the error we expect.
2588- self .assertIn ("--live-migration must be specified if "
2589- "--block-migration, --disk-overcommit or --host is "
2590- "specified" , six .text_type (ex ))
2615+ self .assertIn ('--os-compute-api-version 2.56 or greater is required '
2616+ 'to use --host without --live-migration.' ,
2617+ six .text_type (ex ))
2618+
25912619 self .servers_mock .get .assert_called_with (self .server .id )
25922620 self .assertNotCalled (self .servers_mock .live_migrate )
25932621 self .assertNotCalled (self .servers_mock .migrate )
0 commit comments