Arik Hadas has uploaded a new change for review. Change subject: core: improve boot sequence validation on run VM ......................................................................
core: improve boot sequence validation on run VM Change-Id: I456ce87acb67ad9d9e2de988088c3ff0c7463d46 Signed-off-by: Arik Hadas <aha...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/RunVmValidator.java 1 file changed, 22 insertions(+), 25 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/38/17938/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/RunVmValidator.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/RunVmValidator.java index 44569e8..c924ac1 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/RunVmValidator.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/RunVmValidator.java @@ -68,28 +68,25 @@ Guid storagePoolId = vm.getStoragePoolId(); // Block from running a VM with no HDD when its first boot device is // HD and no other boot devices are configured - if (boot_sequence == BootSequence.C && vmDisks.size() == 0) { + if (boot_sequence == BootSequence.C && vmDisks.isEmpty()) { return new ValidationResult(VdcBllMessages.VM_CANNOT_RUN_FROM_DISK_WITHOUT_DISK); - } else { - // If CD appears as first and there is no ISO in storage - // pool/ISO inactive - - // you cannot run this VM - - if (boot_sequence == BootSequence.CD - && getIsoDomainListSyncronizer().findActiveISODomain(storagePoolId) == null) { - return new ValidationResult(VdcBllMessages.VM_CANNOT_RUN_FROM_CD_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO); - } else { - // if there is network in the boot sequence, check that the - // vm has network, - // otherwise the vm cannot be run in vdsm - if (boot_sequence == BootSequence.N - && getVmNicDao().getAllForVm(vm.getId()).size() == 0) { - return new ValidationResult(VdcBllMessages.VM_CANNOT_RUN_FROM_NETWORK_WITHOUT_NETWORK); - } - } } - return ValidationResult.VALID; + // If CD appears as first and there is no ISO in storage + // pool/ISO inactive - you cannot run this VM + if (boot_sequence == BootSequence.CD + && getIsoDomainListSyncronizer().findActiveISODomain(storagePoolId) == null) { + return new ValidationResult(VdcBllMessages.VM_CANNOT_RUN_FROM_CD_WITHOUT_ACTIVE_STORAGE_DOMAIN_ISO); + } + + // if there is network in the boot sequence, check that the + // vm has network, otherwise the vm cannot be run in vdsm + if (boot_sequence == BootSequence.N + && getVmNicDao().getAllForVm(vm.getId()).isEmpty()) { + return new ValidationResult(VdcBllMessages.VM_CANNOT_RUN_FROM_NETWORK_WITHOUT_NETWORK); + } + + return ValidationResult.VALID; } /** @@ -186,19 +183,19 @@ } public ValidationResult vmDuringInitialization(VM vm) { - boolean isVmDuringInit = isVmDuringInitiating(vm); - if (vm.isRunning() || vm.getStatus() == VMStatus.NotResponding || isVmDuringInit) { + if (vm.isRunning() || vm.getStatus() == VMStatus.NotResponding || + isVmDuringInitiating(vm)) { return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_VM_IS_RUNNING); } return ValidationResult.VALID; } protected boolean isVmDuringInitiating(VM vm) { - return ((Boolean) getBackend() + return (Boolean) getBackend() .getResourceManager() .RunVdsCommand(VDSCommandType.IsVmDuringInitiating, new IsVmDuringInitiatingVDSCommandParameters(vm.getId())) - .getReturnValue()).booleanValue(); + .getReturnValue(); } public ValidationResult validateVdsStatus(VM vm) { @@ -214,8 +211,8 @@ } public ValidationResult validateStatelessVm(VM vm, List<Disk> plugDisks, Boolean stateless) { - boolean isStatelessVm = stateless != null ? stateless : vm.isStateless(); - if (!isStatelessVm) { + // if the VM is not stateless, there is nothing to check + if (stateless != null ? !stateless : !vm.isStateless()) { return ValidationResult.VALID; } -- To view, visit http://gerrit.ovirt.org/17938 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I456ce87acb67ad9d9e2de988088c3ff0c7463d46 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <aha...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches