Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
import javax.naming.ConfigurationException;
import javax.persistence.EntityExistsException;

import com.cloud.storage.VolumeApiServiceImpl;
import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
import org.apache.cloudstack.annotation.AnnotationService;
import org.apache.cloudstack.annotation.dao.AnnotationDao;
Expand Down Expand Up @@ -3765,9 +3766,11 @@ public void checkIfCanUpgrade(final VirtualMachine vmInstance, final ServiceOffe

final List<String> currentTags = StringUtils.csvTagsToList(currentDiskOffering.getTags());
final List<String> newTags = StringUtils.csvTagsToList(newDiskOffering.getTags());
if (!newTags.containsAll(currentTags)) {
throw new InvalidParameterValueException("Unable to upgrade virtual machine; the current service offering " + " should have tags as subset of " +
"the new service offering tags. Current service offering tags: " + currentTags + "; " + "new service " + "offering tags: " + newTags);
if (VolumeApiServiceImpl.MatchStoragePoolTagsWithDiskOffering.valueIn(vmInstance.getDataCenterId())) {
if (!VolumeApiServiceImpl.doesNewDiskOfferingHasTagsAsOldDiskOffering(currentDiskOffering, newDiskOffering)) {
throw new InvalidParameterValueException("Unable to upgrade virtual machine; the current service offering " + " should have tags as subset of " +
"the new service offering tags. Current service offering tags: " + currentTags + "; " + "new service " + "offering tags: " + newTags);
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3267,7 +3267,7 @@ private Pair<List<ServiceOfferingJoinVO>, Integer> searchForServiceOfferingsInte
if (currentVmOffering != null) {
DiskOfferingVO diskOffering = _diskOfferingDao.findByIdIncludingRemoved(currentVmOffering.getDiskOfferingId());
List<String> storageTags = com.cloud.utils.StringUtils.csvTagsToList(diskOffering.getTags());
if (!storageTags.isEmpty()) {
if (!storageTags.isEmpty() && VolumeApiServiceImpl.MatchStoragePoolTagsWithDiskOffering.value()) {
SearchBuilder<ServiceOfferingJoinVO> sb = _srvOfferingJoinDao.createSearchBuilder();
for(String tag : storageTags) {
sb.and(tag, sb.entity().getTags(), Op.FIND_IN_SET);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1910,10 +1910,9 @@ private void validateVolumeResizeWithNewDiskOfferingAndLoad(VolumeVO volume, Dis
}

_configMgr.checkDiskOfferingAccess(_accountMgr.getActiveAccountById(volume.getAccountId()), newDiskOffering, _dcDao.findById(volume.getDataCenterId()));

if (newDiskOffering.getDiskSize() > 0 && !newDiskOffering.isComputeOnly()) {
newSize[0] = (Long) newDiskOffering.getDiskSize();
} else if (newDiskOffering.isCustomized()) {
} else if (newDiskOffering.isCustomized() && !newDiskOffering.isComputeOnly()) {
if (newSize[0] == null) {
throw new InvalidParameterValueException("The new disk offering requires that a size be specified.");
}
Expand Down Expand Up @@ -3049,7 +3048,7 @@ public boolean doesTargetStorageSupportDiskOffering(StoragePool destPool, String
return CollectionUtils.isSubCollection(Arrays.asList(newDiskOfferingTagsAsStringArray), Arrays.asList(storageTagsAsStringArray));
}

public boolean doesNewDiskOfferingHasTagsAsOldDiskOffering(DiskOfferingVO oldDO, DiskOfferingVO newDO) {
public static boolean doesNewDiskOfferingHasTagsAsOldDiskOffering(DiskOfferingVO oldDO, DiskOfferingVO newDO) {
String[] oldDOStorageTags = oldDO.getTagsArray();
String[] newDOStorageTags = newDO.getTagsArray();
if (oldDOStorageTags.length == 0) {
Expand Down