mirror of https://github.com/apache/cloudstack.git
Allow scaling VM to a service offering having different storage tags (#5996)
This commit is contained in:
parent
72a77d553d
commit
d311f88d35
|
|
@ -45,6 +45,7 @@ import javax.inject.Inject;
|
|||
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;
|
||||
|
|
@ -3765,9 +3766,11 @@ public class VirtualMachineManagerImpl extends ManagerBase implements VirtualMac
|
|||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -3267,7 +3267,7 @@ public class QueryManagerImpl extends MutualExclusiveIdsManagerBase implements Q
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -1910,10 +1910,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
}
|
||||
|
||||
_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.");
|
||||
}
|
||||
|
|
@ -3049,7 +3048,7 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
|||
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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue