Gilad Chaplik has uploaded a new change for review. Change subject: core: sanity check for cluster's quota ......................................................................
core: sanity check for cluster's quota If quota mode is enforced, we should fail action in case no quota is provided. This bug was hidden from UI, and discovered via REST, since there is a client validation for it. The original bug was opened only for AddVmFromScratch, Added this missing check also to: *AddVm *AddVmFromTemplate *AddVmFromSnapshot *AddVmTemplate Change-Id: I0ef84ca9603a16014edaa4ddf99dfaa2f31744d4 Bug-Url: https://bugzilla.redhat.com/909749 Signed-off-by: Gilad Chaplik <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java 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/AddVmTemplateCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java 4 files changed, 47 insertions(+), 9 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/12/12012/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java index 4257992..f015aaf 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmCommand.java @@ -13,8 +13,10 @@ import org.ovirt.engine.core.bll.job.ExecutionHandler; import org.ovirt.engine.core.bll.network.MacPoolManager; import org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter; +import org.ovirt.engine.core.bll.quota.QuotaSanityParameter; import org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter; import org.ovirt.engine.core.bll.quota.QuotaStorageDependent; +import org.ovirt.engine.core.bll.quota.QuotaVdsDependent; import org.ovirt.engine.core.bll.snapshots.SnapshotsManager; import org.ovirt.engine.core.bll.utils.PermissionSubject; import org.ovirt.engine.core.bll.utils.VmDeviceUtils; @@ -70,7 +72,7 @@ @DisableInPrepareMode @LockIdNameAttribute public class AddVmCommand<T extends VmManagementParametersBase> extends VmManagementCommandBase<T> - implements QuotaStorageDependent { + implements QuotaStorageDependent, QuotaVdsDependent { protected HashMap<Guid, DiskImage> diskInfoDestinationMap; protected Map<Guid, storage_domains> destStorages = new HashMap<Guid, storage_domains>(); @@ -797,4 +799,11 @@ } return list; } + + @Override + public List<QuotaConsumptionParameter> getQuotaVdsConsumptionParameters() { + List<QuotaConsumptionParameter> list = new ArrayList<QuotaConsumptionParameter>(); + list.add(new QuotaSanityParameter(getQuotaId(), null)); + return list; + } } 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 ad160eb..0ae9c5a 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 @@ -6,8 +6,11 @@ import java.util.Map; import org.apache.commons.lang.StringUtils; -import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter; +import org.ovirt.engine.core.bll.quota.QuotaSanityParameter; +import org.ovirt.engine.core.bll.quota.QuotaVdsDependent; import org.ovirt.engine.core.bll.utils.PermissionSubject; +import org.ovirt.engine.core.common.AuditLogType; import org.ovirt.engine.core.common.VdcObjectType; import org.ovirt.engine.core.common.action.AddVmPoolWithVmsParameters; import org.ovirt.engine.core.common.businessentities.VmPool; @@ -17,7 +20,8 @@ @DisableInPrepareMode @NonTransactiveCommandAttribute(forceCompensation = true) -public class AddVmPoolWithVmsCommand<T extends AddVmPoolWithVmsParameters> extends CommonVmPoolWithVmsCommand<T> { +public class AddVmPoolWithVmsCommand<T extends AddVmPoolWithVmsParameters> extends CommonVmPoolWithVmsCommand<T> + implements QuotaVdsDependent { /** * Constructor for command creation when compensation is applied on startup @@ -100,4 +104,16 @@ } return jobProperties; } + + private Guid getQuotaId() { + return getParameters().getVmStaticData().getQuotaId(); + } + + @Override + public List<QuotaConsumptionParameter> getQuotaVdsConsumptionParameters() { + List<QuotaConsumptionParameter> list = new ArrayList<QuotaConsumptionParameter>(); + list.add(new QuotaSanityParameter(getQuotaId(), null)); + return list; + } + } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java index 3c30fa5..81db848 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/AddVmTemplateCommand.java @@ -10,8 +10,10 @@ import org.ovirt.engine.core.bll.job.ExecutionHandler; import org.ovirt.engine.core.bll.quota.QuotaConsumptionParameter; +import org.ovirt.engine.core.bll.quota.QuotaSanityParameter; import org.ovirt.engine.core.bll.quota.QuotaStorageConsumptionParameter; import org.ovirt.engine.core.bll.quota.QuotaStorageDependent; +import org.ovirt.engine.core.bll.quota.QuotaVdsDependent; import org.ovirt.engine.core.bll.snapshots.SnapshotsValidator; import org.ovirt.engine.core.bll.storage.StoragePoolValidator; import org.ovirt.engine.core.bll.utils.PermissionSubject; @@ -49,7 +51,7 @@ @DisableInPrepareMode @NonTransactiveCommandAttribute(forceCompensation = true) public class AddVmTemplateCommand<T extends AddVmTemplateParameters> extends VmTemplateCommand<T> - implements QuotaStorageDependent { + implements QuotaStorageDependent, QuotaVdsDependent { private final List<DiskImage> mImages = new ArrayList<DiskImage>(); private List<PermissionSubject> permissionCheckSubject; @@ -497,4 +499,15 @@ } return list; } + + private Guid getQuotaId() { + return getParameters().getMasterVm().getQuotaId(); + } + + @Override + public List<QuotaConsumptionParameter> getQuotaVdsConsumptionParameters() { + List<QuotaConsumptionParameter> list = new ArrayList<QuotaConsumptionParameter>(); + list.add(new QuotaSanityParameter(getQuotaId(), null)); + return list; + } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java index ed6cd19..476144b 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java @@ -7,9 +7,9 @@ public enum VdcActionType { Unknown(0, QuotaDependency.NONE), // Vm Commands - AddVm(1, ActionGroup.CREATE_VM, QuotaDependency.STORAGE), - AddVmFromTemplate(2, ActionGroup.CREATE_VM, QuotaDependency.STORAGE), - AddVmFromScratch(3, ActionGroup.CREATE_VM, QuotaDependency.NONE), + AddVm(1, ActionGroup.CREATE_VM, QuotaDependency.BOTH), + AddVmFromTemplate(2, ActionGroup.CREATE_VM, QuotaDependency.BOTH), + AddVmFromScratch(3, ActionGroup.CREATE_VM, QuotaDependency.BOTH), RemoveVm(4, ActionGroup.DELETE_VM, QuotaDependency.STORAGE), UpdateVm(5, ActionGroup.EDIT_VM_PROPERTIES, QuotaDependency.VDS_GROUP), StopVm(7, ActionGroup.VM_BASIC_OPERATIONS, QuotaDependency.BOTH), @@ -54,7 +54,7 @@ // powerclient 4.2 PowerClientMigrateOnConnectCheck(50, QuotaDependency.NONE), SetDedicatedVm(51, QuotaDependency.NONE), - AddVmFromSnapshot(52, ActionGroup.CREATE_VM, QuotaDependency.STORAGE), + AddVmFromSnapshot(52, ActionGroup.CREATE_VM, QuotaDependency.BOTH), // VdsCommands AddVds(101, ActionGroup.CREATE_HOST, QuotaDependency.NONE), UpdateVds(102, ActionGroup.EDIT_HOST_CONFIGURATION, false, QuotaDependency.NONE), @@ -89,7 +89,7 @@ CommitNetworkChanges(157, ActionGroup.CONFIGURE_HOST_NETWORK, QuotaDependency.NONE), SetupNetworks(158, ActionGroup.CONFIGURE_HOST_NETWORK, QuotaDependency.NONE), // VmTemplatesCommand - AddVmTemplate(201, ActionGroup.CREATE_TEMPLATE, QuotaDependency.STORAGE), + AddVmTemplate(201, ActionGroup.CREATE_TEMPLATE, QuotaDependency.BOTH), UpdateVmTemplate(202, ActionGroup.EDIT_TEMPLATE_PROPERTIES, QuotaDependency.VDS_GROUP), RemoveVmTemplate(203, ActionGroup.DELETE_TEMPLATE, QuotaDependency.STORAGE), MoveOrCopyTemplate(226, ActionGroup.COPY_TEMPLATE, QuotaDependency.STORAGE), -- To view, visit http://gerrit.ovirt.org/12012 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I0ef84ca9603a16014edaa4ddf99dfaa2f31744d4 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Gilad Chaplik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
