Vered Volansky has uploaded a new change for review. Change subject: core: Adding a pool with vm storage allocation ......................................................................
core: Adding a pool with vm storage allocation In the current situation, allocation checks are done on the template disk, which may be of the wrong storage type/format. Updating the image's data to support the allocation validations. Change-Id: Ia46bef12bbc0462bb42956f95bdff1855631e7b6 Bug-Url: https://bugzilla.redhat.com/1178021 Signed-off-by: Vered Volansky <vvola...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmPoolWithVmsCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java 2 files changed, 35 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/53/36553/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmPoolWithVmsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmPoolWithVmsCommand.java index 27e26fc..4ce62e3 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmPoolWithVmsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmPoolWithVmsCommand.java @@ -136,6 +136,17 @@ for (int i = 0; i < numOfVms; ++i) { disksList.addAll(diskInfoDestinationMap.values()); } + // At this point the disks are the template's, which could have another volume type/format + // This change is for storage allocation validations, "real" override for these values is done in CreateSnapshotCommand. + /*for (DiskImage diskImage : disksList) { + diskImage.setVolumeType(VolumeType.Sparse); + destStorages + if (dest storage is block){ + diskImage.setvolumeFormat(VolumeFormat.COW); + } else { //really needed? + diskImage.setvolumeFormat(VolumeFormat.RAW); + } + }*/ Guid spId = getVmTemplate().getStoragePoolId(); Set<Guid> sdIds = destStorages.keySet(); MultipleStorageDomainsValidator storageDomainsValidator = getStorageDomainsValidator(spId, sdIds); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java index a1d1997..acc8666 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/CommonVmPoolWithVmsCommand.java @@ -32,6 +32,8 @@ import org.ovirt.engine.core.common.businessentities.VmStatic; import org.ovirt.engine.core.common.businessentities.VmTemplate; import org.ovirt.engine.core.common.businessentities.VmType; +import org.ovirt.engine.core.common.businessentities.VolumeFormat; +import org.ovirt.engine.core.common.businessentities.VolumeType; import org.ovirt.engine.core.common.config.Config; import org.ovirt.engine.core.common.config.ConfigValues; import org.ovirt.engine.core.common.errors.VdcBllMessages; @@ -345,6 +347,7 @@ storageIds.add(storageId); for (DiskImage image : getVmTemplate().getDiskTemplateMap().values()) { image.setStorageIds(storageIds); + setDestTypeAndFormat(image); diskInfoDestinationMap.put(image.getId(), image); } } else { @@ -359,7 +362,19 @@ addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_MISSED_STORAGES_FOR_SOME_DISKS); return false; } + for (DiskImage diskImage : diskInfoDestinationMap.values()) { + setDestTypeAndFormat(diskImage); + } return true; + } + + private void setDestTypeAndFormat(DiskImage diskImage) { + diskImage.setVolumeType(VolumeType.Sparse); + if (getDiskStorageDomain(diskImage).getStorageType().isBlockDomain()) { + diskImage.setvolumeFormat(VolumeFormat.COW); + } else { + diskImage.setvolumeFormat(VolumeFormat.RAW); + } } public boolean checkDestDomains() { @@ -386,6 +401,15 @@ return true; } + private StorageDomain getDiskStorageDomain(DiskImage diskImage) { + Guid domainId = diskImage.getStorageIds().get(0); + StorageDomain domain = destStorages.get(domainId); + if (domain == null) { + domain = getStorageDomainDAO().getForStoragePool(domainId, getVmTemplate().getStoragePoolId()); + } + return domain; + } + private int getBlockSparseInitSizeInGB() { return Config.<Integer> getValue(ConfigValues.InitStorageSparseSizeInGB).intValue(); } -- To view, visit http://gerrit.ovirt.org/36553 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia46bef12bbc0462bb42956f95bdff1855631e7b6 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Vered Volansky <vvola...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches