GutoVeronezi commented on code in PR #6269:
URL: https://github.com/apache/cloudstack/pull/6269#discussion_r870437985
##########
server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java:
##########
@@ -3801,7 +3804,18 @@ protected void updateOfferingTagsIfIsNotNull(String
tags, DiskOfferingVO diskOff
for (StoragePoolVO storagePoolVO : pools) {
List<String> tagsOnPool =
storagePoolTagDao.getStoragePoolTags(storagePoolVO.getId());
if (CollectionUtils.isEmpty(tagsOnPool) ||
!tagsOnPool.containsAll(listOfTags)) {
- throw new
InvalidParameterValueException(String.format("There are active volumes using
offering [%s], and the pools [%s] don't have the new tags",
diskOffering.getId(), pools));
+ DiskOfferingVO offeringToRetrieveInfo =
_diskOfferingDao.findById(diskOffering.getId());
+ List<VolumeVO> volumes =
_volumeDao.findByDiskOfferingId(diskOffering.getId());
+ List<String> listOfVolumesNamesAndUuid = new
ArrayList<>();
+
+ String diskOfferingInfo =
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(offeringToRetrieveInfo,
"name", "uuid");
+ String poolInfo =
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(storagePoolVO, "name",
"uuid");
+
+ for (VolumeVO volumeVO : volumes)
+
listOfVolumesNamesAndUuid.add(ReflectionToStringBuilderUtils.reflectOnlySelectedFields(volumeVO,
"name", "uuid"));
Review Comment:
As `ReflectionToStringBuilderUtils` can reflect collections too, we can
remove the loop through the `volumes` and reflect the whole collection:
```suggestion
List<VolumeVO> volumes =
_volumeDao.findByDiskOfferingId(diskOffering.getId());
String listOfVolumesNamesAndUuid =
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(volumes, "name",
"uuid");
String diskOfferingInfo =
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(offeringToRetrieveInfo,
"name", "uuid");
String poolInfo =
ReflectionToStringBuilderUtils.reflectOnlySelectedFields(storagePoolVO, "name",
"uuid");
```
##########
engine/schema/src/main/java/com/cloud/storage/dao/VolumeDao.java:
##########
@@ -131,4 +131,12 @@ public interface VolumeDao extends GenericDao<VolumeVO,
Long>, StateDao<Volume.S
* Updates the disk offering for the given volume.
*/
void updateDiskOffering(long volumeId, long diskOfferingId);
+
+ /**
+ * Gets volumes by the disk offering ID.
Review Comment:
```suggestion
* Retrieves volumes that use the disk offering passed as parameter.
```
--
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]