7070import org .apache .cloudstack .storage .datastore .db .StoragePoolVO ;
7171import org .apache .cloudstack .storage .to .PrimaryDataStoreTO ;
7272import org .apache .cloudstack .storage .to .VolumeObjectTO ;
73- import org .apache .commons .collections .MapUtils ;
7473import org .apache .commons .lang3 .StringUtils ;
7574import org .apache .log4j .Logger ;
7675
8281import com .cloud .agent .api .ModifyTargetsAnswer ;
8382import com .cloud .agent .api .ModifyTargetsCommand ;
8483import com .cloud .agent .api .PrepareForMigrationCommand ;
85- import com .cloud .agent .api .storage .CheckStorageAvailabilityCommand ;
8684import com .cloud .agent .api .storage .CopyVolumeAnswer ;
8785import com .cloud .agent .api .storage .CopyVolumeCommand ;
8886import com .cloud .agent .api .storage .MigrateVolumeAnswer ;
@@ -1909,7 +1907,7 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
19091907 throw new CloudRuntimeException ("Invalid hypervisor type (only KVM supported for this operation at the time being)" );
19101908 }
19111909
1912- verifyLiveMigrationForKVM (volumeDataStoreMap , destHost );
1910+ verifyLiveMigrationForKVM (volumeDataStoreMap );
19131911
19141912 VMInstanceVO vmInstance = _vmDao .findById (vmTO .getId ());
19151913 vmTO .setState (vmInstance .getState ());
@@ -1983,8 +1981,8 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
19831981
19841982 MigrateCommand .MigrateDiskInfo migrateDiskInfo ;
19851983
1986- boolean isNonManagedNfsToNfsOrSharedMountPointToNfs = supportStoragePoolType (sourceStoragePool .getPoolType ()) && destStoragePool .getPoolType () == StoragePoolType .NetworkFilesystem && !managedStorageDestination ;
1987- if (isNonManagedNfsToNfsOrSharedMountPointToNfs ) {
1984+ boolean isNonManagedToNfs = supportStoragePoolType (sourceStoragePool .getPoolType (), StoragePoolType . Filesystem ) && destStoragePool .getPoolType () == StoragePoolType .NetworkFilesystem && !managedStorageDestination ;
1985+ if (isNonManagedToNfs ) {
19881986 migrateDiskInfo = new MigrateCommand .MigrateDiskInfo (srcVolumeInfo .getPath (),
19891987 MigrateCommand .MigrateDiskInfo .DiskType .FILE ,
19901988 MigrateCommand .MigrateDiskInfo .DriverType .QCOW2 ,
@@ -2363,9 +2361,8 @@ protected void prepareDiskWithSecretConsumerDetail(VirtualMachineTO vmTO, Volume
23632361 * At a high level: The source storage cannot be managed and
23642362 * the destination storages can be all managed or all not managed, not mixed.
23652363 */
2366- protected void verifyLiveMigrationForKVM (Map <VolumeInfo , DataStore > volumeDataStoreMap , Host destHost ) {
2364+ protected void verifyLiveMigrationForKVM (Map <VolumeInfo , DataStore > volumeDataStoreMap ) {
23672365 Boolean storageTypeConsistency = null ;
2368- Map <String , Storage .StoragePoolType > sourcePools = new HashMap <>();
23692366 for (Map .Entry <VolumeInfo , DataStore > entry : volumeDataStoreMap .entrySet ()) {
23702367 VolumeInfo volumeInfo = entry .getKey ();
23712368
@@ -2392,47 +2389,6 @@ protected void verifyLiveMigrationForKVM(Map<VolumeInfo, DataStore> volumeDataSt
23922389 } else if (storageTypeConsistency != destStoragePoolVO .isManaged ()) {
23932390 throw new CloudRuntimeException ("Destination storage pools must be either all managed or all not managed" );
23942391 }
2395-
2396- addSourcePoolToPoolsMap (sourcePools , srcStoragePoolVO , destStoragePoolVO );
2397- }
2398- verifyDestinationStorage (sourcePools , destHost );
2399- }
2400-
2401- /**
2402- * Adds source storage pool to the migration map if the destination pool is not managed and it is NFS.
2403- */
2404- protected void addSourcePoolToPoolsMap (Map <String , Storage .StoragePoolType > sourcePools , StoragePoolVO srcStoragePoolVO , StoragePoolVO destStoragePoolVO ) {
2405- if (destStoragePoolVO .isManaged () || !StoragePoolType .NetworkFilesystem .equals (destStoragePoolVO .getPoolType ())) {
2406- LOGGER .trace (String .format ("Skipping adding source pool [%s] to map due to destination pool [%s] is managed or not NFS." , srcStoragePoolVO , destStoragePoolVO ));
2407- return ;
2408- }
2409-
2410- String sourceStoragePoolUuid = srcStoragePoolVO .getUuid ();
2411- if (!sourcePools .containsKey (sourceStoragePoolUuid )) {
2412- sourcePools .put (sourceStoragePoolUuid , srcStoragePoolVO .getPoolType ());
2413- }
2414- }
2415-
2416- /**
2417- * Perform storage validation on destination host for KVM live storage migrations.
2418- * Validate that volume source storage pools are mounted on the destination host prior the migration
2419- * @throws CloudRuntimeException if any source storage pool is not mounted on the destination host
2420- */
2421- private void verifyDestinationStorage (Map <String , Storage .StoragePoolType > sourcePools , Host destHost ) {
2422- if (MapUtils .isNotEmpty (sourcePools )) {
2423- LOGGER .debug ("Verifying source pools are already available on destination host " + destHost .getUuid ());
2424- CheckStorageAvailabilityCommand cmd = new CheckStorageAvailabilityCommand (sourcePools );
2425- try {
2426- Answer answer = agentManager .send (destHost .getId (), cmd );
2427- if (answer == null || !answer .getResult ()) {
2428- throw new CloudRuntimeException ("Storage verification failed on host "
2429- + destHost .getUuid () +": " + answer .getDetails ());
2430- }
2431- } catch (AgentUnavailableException | OperationTimedoutException e ) {
2432- e .printStackTrace ();
2433- throw new CloudRuntimeException ("Cannot perform storage verification on host " + destHost .getUuid () +
2434- "due to: " + e .getMessage ());
2435- }
24362392 }
24372393 }
24382394
0 commit comments