@@ -1723,9 +1723,10 @@ def test_volume_migrate(self):
17231723 host = "host@backend-name#pool" ,
17241724 force_host_copy = False ,
17251725 lock_volume = False ,
1726+ cluster = None ,
17261727 )
17271728
1728- def test_volume_migrate_with_option (self ):
1729+ def test_volume_migrate_with_host (self ):
17291730 arglist = [
17301731 "--force-host-copy" ,
17311732 "--lock-volume" ,
@@ -1752,9 +1753,66 @@ def test_volume_migrate_with_option(self):
17521753 host = "host@backend-name#pool" ,
17531754 force_host_copy = True ,
17541755 lock_volume = True ,
1756+ cluster = None ,
17551757 )
17561758
1757- def test_volume_migrate_without_host (self ):
1759+ def test_volume_migrate_with_cluster (self ):
1760+ self .set_volume_api_version ('3.16' )
1761+ arglist = [
1762+ "--cluster" ,
1763+ "cluster@backend-name#pool" ,
1764+ self .volume .id ,
1765+ ]
1766+ verifylist = [
1767+ (
1768+ "cluster" ,
1769+ "cluster@backend-name#pool" ,
1770+ ),
1771+ ("volume" , self .volume .id ),
1772+ ]
1773+
1774+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
1775+
1776+ result = self .cmd .take_action (parsed_args )
1777+ self .assertIsNone (result )
1778+
1779+ self .volume_sdk_client .find_volume .assert_called_with (
1780+ self .volume .id , ignore_missing = False
1781+ )
1782+ self .volume_sdk_client .migrate_volume .assert_called_once_with (
1783+ self .volume .id ,
1784+ host = None ,
1785+ force_host_copy = False ,
1786+ lock_volume = False ,
1787+ cluster = "cluster@backend-name#pool" ,
1788+ )
1789+
1790+ def test_volume_migrate_with_cluster_pre_v316 (self ):
1791+ self .set_volume_api_version ('3.15' )
1792+ arglist = [
1793+ "--cluster" ,
1794+ "cluster@backend-name#pool" ,
1795+ self .volume .id ,
1796+ ]
1797+ verifylist = [
1798+ (
1799+ "cluster" ,
1800+ "cluster@backend-name#pool" ,
1801+ ),
1802+ ("volume" , self .volume .id ),
1803+ ]
1804+
1805+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
1806+
1807+ self .assertRaises (
1808+ exceptions .CommandError ,
1809+ self .cmd .take_action ,
1810+ parsed_args ,
1811+ )
1812+
1813+ self .volume_sdk_client .migrate_volume .assert_not_called ()
1814+
1815+ def test_volume_migrate_without_host_and_cluster (self ):
17581816 arglist = [
17591817 self .volume .id ,
17601818 ]
@@ -1771,7 +1829,6 @@ def test_volume_migrate_without_host(self):
17711829 arglist ,
17721830 verifylist ,
17731831 )
1774-
17751832 self .volume_sdk_client .find_volume .assert_not_called ()
17761833 self .volume_sdk_client .migrate_volume .assert_not_called ()
17771834
0 commit comments