@@ -996,6 +996,96 @@ def test_volume_list_negative_limit(self):
996996 self .cmd , arglist , verifylist )
997997
998998
999+ class TestVolumeMigrate (TestVolume ):
1000+
1001+ _volume = volume_fakes .FakeVolume .create_one_volume ()
1002+
1003+ def setUp (self ):
1004+ super (TestVolumeMigrate , self ).setUp ()
1005+
1006+ self .volumes_mock .get .return_value = self ._volume
1007+ self .volumes_mock .migrate_volume .return_value = None
1008+ # Get the command object to test
1009+ self .cmd = volume .MigrateVolume (self .app , None )
1010+
1011+ def test_volume_migrate (self ):
1012+ arglist = [
1013+ "--host" , "host@backend-name#pool" ,
1014+ self ._volume .id ,
1015+ ]
1016+ verifylist = [
1017+ ("force_host_copy" , False ),
1018+ ("lock_volume" , False ),
1019+ ("unlock_volume" , False ),
1020+ ("host" , "host@backend-name#pool" ),
1021+ ("volume" , self ._volume .id ),
1022+ ]
1023+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
1024+
1025+ result = self .cmd .take_action (parsed_args )
1026+ self .volumes_mock .get .assert_called_once_with (self ._volume .id )
1027+ self .volumes_mock .migrate_volume .assert_called_once_with (
1028+ self ._volume .id , "host@backend-name#pool" , False , False )
1029+ self .assertIsNone (result )
1030+
1031+ def test_volume_migrate_with_option (self ):
1032+ arglist = [
1033+ "--force-host-copy" ,
1034+ "--lock-volume" ,
1035+ "--host" , "host@backend-name#pool" ,
1036+ self ._volume .id ,
1037+ ]
1038+ verifylist = [
1039+ ("force_host_copy" , True ),
1040+ ("lock_volume" , True ),
1041+ ("unlock_volume" , False ),
1042+ ("host" , "host@backend-name#pool" ),
1043+ ("volume" , self ._volume .id ),
1044+ ]
1045+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
1046+
1047+ result = self .cmd .take_action (parsed_args )
1048+ self .volumes_mock .get .assert_called_once_with (self ._volume .id )
1049+ self .volumes_mock .migrate_volume .assert_called_once_with (
1050+ self ._volume .id , "host@backend-name#pool" , True , True )
1051+ self .assertIsNone (result )
1052+
1053+ def test_volume_migrate_with_unlock_volume (self ):
1054+ arglist = [
1055+ "--unlock-volume" ,
1056+ "--host" , "host@backend-name#pool" ,
1057+ self ._volume .id ,
1058+ ]
1059+ verifylist = [
1060+ ("force_host_copy" , False ),
1061+ ("lock_volume" , False ),
1062+ ("unlock_volume" , True ),
1063+ ("host" , "host@backend-name#pool" ),
1064+ ("volume" , self ._volume .id ),
1065+ ]
1066+ parsed_args = self .check_parser (self .cmd , arglist , verifylist )
1067+
1068+ result = self .cmd .take_action (parsed_args )
1069+ self .volumes_mock .get .assert_called_once_with (self ._volume .id )
1070+ self .volumes_mock .migrate_volume .assert_called_once_with (
1071+ self ._volume .id , "host@backend-name#pool" , False , False )
1072+ self .assertIsNone (result )
1073+
1074+ def test_volume_migrate_without_host (self ):
1075+ arglist = [
1076+ self ._volume .id ,
1077+ ]
1078+ verifylist = [
1079+ ("force_host_copy" , False ),
1080+ ("lock_volume" , False ),
1081+ ("unlock_volume" , False ),
1082+ ("volume" , self ._volume .id ),
1083+ ]
1084+
1085+ self .assertRaises (tests_utils .ParserException , self .check_parser ,
1086+ self .cmd , arglist , verifylist )
1087+
1088+
9991089class TestVolumeSet (TestVolume ):
10001090
10011091 def setUp (self ):
0 commit comments