|
72 | 72 | import org.apache.cloudstack.storage.command.DettachCommand; |
73 | 73 | import org.apache.cloudstack.storage.command.TemplateOrVolumePostUploadCommand; |
74 | 74 | import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao; |
75 | | -import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO; |
76 | | -import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao; |
77 | 75 | import org.apache.cloudstack.storage.datastore.db.StoragePoolVO; |
78 | 76 | import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao; |
79 | 77 | import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreVO; |
|
120 | 118 | import com.cloud.storage.Storage.ImageFormat; |
121 | 119 | import com.cloud.storage.dao.DiskOfferingDao; |
122 | 120 | import com.cloud.storage.dao.SnapshotDao; |
| 121 | +import com.cloud.storage.dao.StoragePoolTagsDao; |
123 | 122 | import com.cloud.storage.dao.VMTemplateDao; |
124 | 123 | import com.cloud.storage.dao.VolumeDao; |
125 | 124 | import com.cloud.storage.snapshot.SnapshotApiService; |
@@ -254,7 +253,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic |
254 | 253 | @Inject |
255 | 254 | private StorageManager storageMgr; |
256 | 255 | @Inject |
257 | | - private StoragePoolDetailsDao storagePoolDetailsDao; |
| 256 | + private StoragePoolTagsDao storagePoolTagsDao; |
258 | 257 | @Inject |
259 | 258 | private StorageUtil storageUtil; |
260 | 259 |
|
@@ -2084,11 +2083,12 @@ public Volume migrateVolume(MigrateVolumeCmd cmd) { |
2084 | 2083 | // OfflineVmwareMigration: check storage tags on disk(offering)s in comparison to destination storage pool |
2085 | 2084 | // OfflineVmwareMigration: if no match return a proper error now |
2086 | 2085 | DiskOfferingVO diskOffering = _diskOfferingDao.findById(vol.getDiskOfferingId()); |
2087 | | - if(diskOffering.equals(null)) { |
2088 | | - throw new CloudRuntimeException("volume '" + vol.getUuid() +"', has no diskoffering. Migration target cannot be checked."); |
| 2086 | + if (diskOffering.equals(null)) { |
| 2087 | + throw new CloudRuntimeException("volume '" + vol.getUuid() + "', has no diskoffering. Migration target cannot be checked."); |
2089 | 2088 | } |
2090 | | - if(! doesTargetStorageSupportDiskOffering(destPool, diskOffering)) { |
2091 | | - throw new CloudRuntimeException("Migration target has no matching tags for volume '" +vol.getName() + "(" + vol.getUuid() + ")'"); |
| 2089 | + if (!doesTargetStorageSupportDiskOffering(destPool, diskOffering)) { |
| 2090 | + throw new CloudRuntimeException(String.format("Migration target pool [%s, tags:%s] has no matching tags for volume [%s, uuid:%s, tags:%s]", destPool.getName(), |
| 2091 | + getStoragePoolTags(destPool), vol.getName(), vol.getUuid(), diskOffering.getTags())); |
2092 | 2092 | } |
2093 | 2093 |
|
2094 | 2094 | if (liveMigrateVolume && destPool.getClusterId() != null && srcClusterId != null) { |
@@ -2278,15 +2278,11 @@ public boolean doesTargetStorageSupportDiskOffering(StoragePool destPool, String |
2278 | 2278 | * Retrieves the storage pool tags as a {@link String}. If the storage pool does not have tags we return a null value. |
2279 | 2279 | */ |
2280 | 2280 | protected String getStoragePoolTags(StoragePool destPool) { |
2281 | | - List<StoragePoolDetailVO> storagePoolDetails = storagePoolDetailsDao.listDetails(destPool.getId()); |
2282 | | - if (CollectionUtils.isEmpty(storagePoolDetails)) { |
| 2281 | + List<String> destPoolTags = storagePoolTagsDao.getStoragePoolTags(destPool.getId()); |
| 2282 | + if (CollectionUtils.isEmpty(destPoolTags)) { |
2283 | 2283 | return null; |
2284 | 2284 | } |
2285 | | - String storageTags = ""; |
2286 | | - for (StoragePoolDetailVO storagePoolDetailVO : storagePoolDetails) { |
2287 | | - storageTags = storageTags + storagePoolDetailVO.getName() + ","; |
2288 | | - } |
2289 | | - return storageTags.substring(0, storageTags.length() - 1); |
| 2285 | + return StringUtils.join(destPoolTags, ","); |
2290 | 2286 | } |
2291 | 2287 |
|
2292 | 2288 | private Volume orchestrateMigrateVolume(VolumeVO volume, StoragePool destPool, boolean liveMigrateVolume, DiskOfferingVO newDiskOffering) { |
|
0 commit comments