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 .logging .log4j .Logger ;
7675import org .apache .logging .log4j .LogManager ;
8382import com .cloud .agent .api .ModifyTargetsAnswer ;
8483import com .cloud .agent .api .ModifyTargetsCommand ;
8584import com .cloud .agent .api .PrepareForMigrationCommand ;
86- import com .cloud .agent .api .storage .CheckStorageAvailabilityCommand ;
8785import com .cloud .agent .api .storage .CopyVolumeAnswer ;
8886import com .cloud .agent .api .storage .CopyVolumeCommand ;
8987import com .cloud .agent .api .storage .MigrateVolumeAnswer ;
@@ -1910,7 +1908,7 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
19101908 throw new CloudRuntimeException ("Invalid hypervisor type (only KVM supported for this operation at the time being)" );
19111909 }
19121910
1913- verifyLiveMigrationForKVM (volumeDataStoreMap , destHost );
1911+ verifyLiveMigrationForKVM (volumeDataStoreMap );
19141912
19151913 VMInstanceVO vmInstance = _vmDao .findById (vmTO .getId ());
19161914 vmTO .setState (vmInstance .getState ());
@@ -1984,8 +1982,8 @@ public void copyAsync(Map<VolumeInfo, DataStore> volumeDataStoreMap, VirtualMach
19841982
19851983 MigrateCommand .MigrateDiskInfo migrateDiskInfo ;
19861984
1987- boolean isNonManagedNfsToNfsOrSharedMountPointToNfs = supportStoragePoolType (sourceStoragePool .getPoolType ()) && destStoragePool .getPoolType () == StoragePoolType .NetworkFilesystem && !managedStorageDestination ;
1988- if (isNonManagedNfsToNfsOrSharedMountPointToNfs ) {
1985+ boolean isNonManagedToNfs = supportStoragePoolType (sourceStoragePool .getPoolType (), StoragePoolType . Filesystem ) && destStoragePool .getPoolType () == StoragePoolType .NetworkFilesystem && !managedStorageDestination ;
1986+ if (isNonManagedToNfs ) {
19891987 migrateDiskInfo = new MigrateCommand .MigrateDiskInfo (srcVolumeInfo .getPath (),
19901988 MigrateCommand .MigrateDiskInfo .DiskType .FILE ,
19911989 MigrateCommand .MigrateDiskInfo .DriverType .QCOW2 ,
@@ -2364,9 +2362,8 @@ protected void prepareDiskWithSecretConsumerDetail(VirtualMachineTO vmTO, Volume
23642362 * At a high level: The source storage cannot be managed and
23652363 * the destination storages can be all managed or all not managed, not mixed.
23662364 */
2367- protected void verifyLiveMigrationForKVM (Map <VolumeInfo , DataStore > volumeDataStoreMap , Host destHost ) {
2365+ protected void verifyLiveMigrationForKVM (Map <VolumeInfo , DataStore > volumeDataStoreMap ) {
23682366 Boolean storageTypeConsistency = null ;
2369- Map <String , Storage .StoragePoolType > sourcePools = new HashMap <>();
23702367 for (Map .Entry <VolumeInfo , DataStore > entry : volumeDataStoreMap .entrySet ()) {
23712368 VolumeInfo volumeInfo = entry .getKey ();
23722369
@@ -2393,47 +2390,6 @@ protected void verifyLiveMigrationForKVM(Map<VolumeInfo, DataStore> volumeDataSt
23932390 } else if (storageTypeConsistency != destStoragePoolVO .isManaged ()) {
23942391 throw new CloudRuntimeException ("Destination storage pools must be either all managed or all not managed" );
23952392 }
2396-
2397- addSourcePoolToPoolsMap (sourcePools , srcStoragePoolVO , destStoragePoolVO );
2398- }
2399- verifyDestinationStorage (sourcePools , destHost );
2400- }
2401-
2402- /**
2403- * Adds source storage pool to the migration map if the destination pool is not managed and it is NFS.
2404- */
2405- protected void addSourcePoolToPoolsMap (Map <String , Storage .StoragePoolType > sourcePools , StoragePoolVO srcStoragePoolVO , StoragePoolVO destStoragePoolVO ) {
2406- if (destStoragePoolVO .isManaged () || !StoragePoolType .NetworkFilesystem .equals (destStoragePoolVO .getPoolType ())) {
2407- logger .trace (String .format ("Skipping adding source pool [%s] to map due to destination pool [%s] is managed or not NFS." , srcStoragePoolVO , destStoragePoolVO ));
2408- return ;
2409- }
2410-
2411- String sourceStoragePoolUuid = srcStoragePoolVO .getUuid ();
2412- if (!sourcePools .containsKey (sourceStoragePoolUuid )) {
2413- sourcePools .put (sourceStoragePoolUuid , srcStoragePoolVO .getPoolType ());
2414- }
2415- }
2416-
2417- /**
2418- * Perform storage validation on destination host for KVM live storage migrations.
2419- * Validate that volume source storage pools are mounted on the destination host prior the migration
2420- * @throws CloudRuntimeException if any source storage pool is not mounted on the destination host
2421- */
2422- private void verifyDestinationStorage (Map <String , Storage .StoragePoolType > sourcePools , Host destHost ) {
2423- if (MapUtils .isNotEmpty (sourcePools )) {
2424- logger .debug ("Verifying source pools are already available on destination host " + destHost .getUuid ());
2425- CheckStorageAvailabilityCommand cmd = new CheckStorageAvailabilityCommand (sourcePools );
2426- try {
2427- Answer answer = agentManager .send (destHost .getId (), cmd );
2428- if (answer == null || !answer .getResult ()) {
2429- throw new CloudRuntimeException ("Storage verification failed on host "
2430- + destHost .getUuid () +": " + answer .getDetails ());
2431- }
2432- } catch (AgentUnavailableException | OperationTimedoutException e ) {
2433- e .printStackTrace ();
2434- throw new CloudRuntimeException ("Cannot perform storage verification on host " + destHost .getUuid () +
2435- "due to: " + e .getMessage ());
2436- }
24372393 }
24382394 }
24392395
0 commit comments