DaanHoogland commented on code in PR #7359:
URL: https://github.com/apache/cloudstack/pull/7359#discussion_r1146249750
##########
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java:
##########
@@ -2022,6 +1980,31 @@ private void
validateVolumeResizeWithNewDiskOfferingAndLoad(VolumeVO volume, Dis
newHypervisorSnapshotReserve[0] =
volume.getHypervisorSnapshotReserve() != null ?
newDiskOffering.getHypervisorSnapshotReserve() : null;
}
+ if (existingDiskOffering.getId() == newDiskOffering.getId() &&
+ (!newDiskOffering.isCustomized() ||
(newDiskOffering.isCustomized() && Objects.equals(volume.getSize(), newSize[0]
<< 30)))) {
+ throw new InvalidParameterValueException(String.format("Volume %s
is already having disk offering %s", volume, newDiskOffering.getUuid()));
+ }
+
+ if (existingDiskOffering.getDiskSizeStrictness() !=
newDiskOffering.getDiskSizeStrictness()) {
+ throw new InvalidParameterValueException("Disk offering size
strictness does not match with new disk offering.");
+ }
+
+ if
(MatchStoragePoolTagsWithDiskOffering.valueIn(volume.getDataCenterId())) {
+ if
(!doesNewDiskOfferingHasTagsAsOldDiskOffering(existingDiskOffering,
newDiskOffering)) {
+ throw new
InvalidParameterValueException(String.format("Selected disk offering %s does
not have tags as in existing disk offering of volume %s",
existingDiskOffering.getUuid(), volume.getUuid()));
+ }
+ }
+ Long instanceId = volume.getInstanceId();
+ VMInstanceVO vmInstanceVO = _vmInstanceDao.findById(instanceId);
+ if (volume.getVolumeType().equals(Volume.Type.ROOT)) {
+ ServiceOfferingVO serviceOffering =
_serviceOfferingDao.findById(vmInstanceVO.getServiceOfferingId());
+ if (serviceOffering != null &&
serviceOffering.getDiskOfferingStrictness()) {
+ throw new InvalidParameterValueException(String.format("Cannot
resize ROOT volume [%s] with new disk offering since existing disk offering is
strictly assigned to the ROOT volume.", volume.getName()));
+ }
+ }
Review Comment:
can these go to separate methods?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]