Skip to content

Commit

Permalink
Update 8808: check disk offering tags
Browse files Browse the repository at this point in the history
  • Loading branch information
weizhouapache committed Apr 2, 2024
1 parent ef6d167 commit ffe9c96
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,9 @@ public VolumeResponse importVolume(ImportVolumeCmd cmd) {
if (diskOffering.isCustomized()) {
volumeApiService.validateCustomDiskOfferingSizeRange(volume.getVirtualSize() / ByteScaleUtils.GiB);
}
if (!volumeApiService.doesTargetStorageSupportDiskOffering(pool, diskOffering.getTags())) {
logFailureAndThrowException(String.format("Disk offering: %s storage tags are not compatible with selected storage pool: %s", diskOffering.getUuid(), pool.getUuid()));
}

// 7. create records
String volumeName = StringUtils.isNotBlank(cmd.getName()) ? cmd.getName().trim() : volumePath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ public void testImportVolumeAllGood() throws ResourceAllocationException {
when(diskOffering.isCustomized()).thenReturn(true);
doReturn(diskOffering).when(volumeImportUnmanageManager).getOrCreateDiskOffering(account, diskOfferingId, zoneId, isLocal);
doNothing().when(volumeApiService).validateCustomDiskOfferingSizeRange(anyLong());
doReturn(true).when(volumeApiService).doesTargetStorageSupportDiskOffering(any(), isNull());
doReturn(diskProfile).when(volumeManager).importVolume(any(), anyString(), any(), eq(virtualSize), isNull(), isNull(), anyLong(),
any(), isNull(), isNull(), any(), isNull(), anyLong(), anyString(), isNull());
when(diskProfile.getVolumeId()).thenReturn(volumeId);
Expand Down

0 comments on commit ffe9c96

Please sign in to comment.