Gustavo Frederico Temple Pedrosa has uploaded a new change for review. Change subject: engine: OS type validation ......................................................................
engine: OS type validation This change displays an error if the selected operating system of the VM or Template is not compatible with its architecture. Change-Id: I2ff3fbada65e72e6fbb944cb56fb35d5acc88a89 Signed-off-by: Gustavo Pedrosa <gustavo.pedr...@eldorado.org.br> --- 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/AddVmTemplateCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidationUtils.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java M backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties M frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java M frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties M frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 11 files changed, 65 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/47/18347/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 ce3499b..07905ed 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 @@ -377,6 +377,12 @@ return false; } + // check if the OS type is supported + if (!VmHandler.isOsTypeSupported(vmFromParams.getOs(), vmFromParams.getArchitecture(), + getReturnValue().getCanDoActionMessages())) { + return false; + } + // check cpuPinning if the check haven't failed yet if (!isCpuPinningValid(vmFromParams.getCpuPinning(), vmFromParams.getStaticData())) { return false; 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 146335b..1c426d5 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 @@ -257,6 +257,12 @@ getReturnValue().getCanDoActionMessages(), getVdsGroup().getcompatibility_version())) { return false; } + + if (!VmHandler.isOsTypeSupported(getParameters().getMasterVm().getOsId(), + getParameters().getMasterVm().getArchitecture(), getReturnValue().getCanDoActionMessages())) { + return false; + } + if (!IsVmPriorityValueLegal(getParameters().getMasterVm().getPriority(), getReturnValue() .getCanDoActionMessages())) { return false; diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java index bc17e60..c893426 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmCommand.java @@ -259,6 +259,11 @@ return false; } + if (!VmHandler.isOsTypeSupported(vmFromParams.getOs(), + vmFromParams.getArchitecture(), getReturnValue().getCanDoActionMessages())) { + return false; + } + if (vmFromParams.getSingleQxlPci() && !VmHandler.isSingleQxlDeviceLegal(vmFromParams.getDefaultDisplayType(), vmFromParams.getOs(), diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java index e192aea..1327713 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmTemplateCommand.java @@ -91,6 +91,11 @@ returnValue = VmHandler.isUsbPolicyLegal(getParameters().getVmTemplateData().getUsbPolicy(), getParameters().getVmTemplateData().getOsId(), getVdsGroup(), getReturnValue().getCanDoActionMessages()); } + // Check if the OS type is supported + if (returnValue) { + returnValue = VmHandler.isOsTypeSupported(getParameters().getVmTemplateData().getOsId(), getParameters().getVmTemplateData().getArchitecture(), getReturnValue().getCanDoActionMessages()); + } + if (returnValue) { returnValue = AddVmCommand.CheckCpuSockets(getParameters().getVmTemplateData().getNumOfSockets(), getParameters().getVmTemplateData().getCpuPerSocket(), getVdsGroup().getcompatibility_version() diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java index 29fe362..76be736 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java @@ -12,6 +12,7 @@ import org.ovirt.engine.core.bll.validator.VmValidationUtils; import org.ovirt.engine.core.common.FeatureSupported; import org.ovirt.engine.core.common.backendinterfaces.BaseHandler; +import org.ovirt.engine.core.common.businessentities.ArchitectureType; import org.ovirt.engine.core.common.businessentities.Disk; import org.ovirt.engine.core.common.businessentities.DiskImage; import org.ovirt.engine.core.common.businessentities.DisplayType; @@ -336,6 +337,28 @@ } /** + * Check if the OS type is supported. + * + * @param osId + * Type of the OS. + * @param architectureType + * The architecture type. + * @param reasons + * The reasons.VdsGroups + * @return + */ + public static boolean isOsTypeSupported(int osId, + ArchitectureType architectureType, + List<String> reasons) { + boolean result = VmValidationUtils.isOsTypeSupported(osId, architectureType); + if (!result) { + reasons.add(VdcBllMessages.ACTION_TYPE_FAILED_ILLEGAL_OS_TYPE_IS_NOT_SUPPORTED_BY_ARCHITECTURE_TYPE + .toString()); + } + return result; + } + + /** * Check if the interface name is not duplicate in the list of interfaces. * * @param interfaces diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidationUtils.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidationUtils.java index cfa9951..95aed84 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidationUtils.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmValidationUtils.java @@ -1,5 +1,6 @@ package org.ovirt.engine.core.bll.validator; +import org.ovirt.engine.core.common.businessentities.ArchitectureType; import org.ovirt.engine.core.common.osinfo.OsRepository; import org.ovirt.engine.core.common.utils.SimpleDependecyInjector; import org.ovirt.engine.core.compat.Version; @@ -20,6 +21,18 @@ } /** + * Check if the OS type is supported by the architecture type (as per the configuration). + * + * @param osId The OS identifier. + * @param architectureType The architecture type to validate. + * + * @return If the OS type is supported. + */ + public static boolean isOsTypeSupported(int osId, ArchitectureType architectureType) { + return architectureType == (SimpleDependecyInjector.getInstance().get(OsRepository.class).getArchitectureFromOS(osId)); + } + + /** * Get the configured minimum VM memory size allowed. * * @return The minimum VM memory size allowed (as per configuration). diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java index 276e24f..07c156d 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/errors/VdcBllMessages.java @@ -191,6 +191,7 @@ ACTION_TYPE_FAILED_ILLEGAL_MEMORY_SIZE(ErrorType.CONSTRAINT_VIOLATION), ACTION_TYPE_FAILED_ILLEGAL_NUM_OF_MONITORS(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_DISPLAY_TYPE(ErrorType.BAD_PARAMETERS), + ACTION_TYPE_FAILED_ILLEGAL_OS_TYPE_IS_NOT_SUPPORTED_BY_ARCHITECTURE_TYPE(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_OS_TYPE(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_INCOMPATIBLE_VERSION(ErrorType.BAD_PARAMETERS), ACTION_TYPE_FAILED_ILLEGAL_DOMAIN_NAME(ErrorType.BAD_PARAMETERS), diff --git a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties index 47cb478..d6ac286 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -551,6 +551,7 @@ ACTION_TYPE_FAILED_ILLEGAL_NUM_OF_MONITORS=Cannot ${action} ${type}. Illegal number of monitors is provided, max allowed number of monitors is 1 for VNC and the max number in the ValidNumOfMonitors configuration variable for SPICE. ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_OS_TYPE=Cannot ${action} ${type}. Cannot set single display device to non Linux operating system. ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_DISPLAY_TYPE=Cannot ${action} ${type}. Cannot set single display device via VNC display. +ACTION_TYPE_FAILED_ILLEGAL_OS_TYPE_IS_NOT_SUPPORTED_BY_ARCHITECTURE_TYPE=Cannot ${action} ${type}. Selected operating system is not supported by the architecture. ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_INCOMPATIBLE_VERSION=Cannot ${action} ${type}. Cluster does not support Single Qxl Pci devices. ACTION_TYPE_FAILED_ILLEGAL_DOMAIN_NAME=Cannot ${action} ${type}. Illegal Domain name: ${Domain}. Domain name has unsupported special character ${Char}. ACTION_TYPE_FAILED_CANNOT_DECREASE_COMPATIBILITY_VERSION=Cannot decrease data center compatibility version. diff --git a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java index 6f30ea8..11cadd3 100644 --- a/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java +++ b/frontend/webadmin/modules/frontend/src/main/java/org/ovirt/engine/ui/frontend/AppErrors.java @@ -1492,6 +1492,9 @@ @DefaultStringValue("Cannot ${action} ${type}. Cannot set single display device via VNC display.") String ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_DISPLAY_TYPE(); + @DefaultStringValue("Cannot ${action} ${type}. Selected operating system is not supported by the architecture.") + String ACTION_TYPE_FAILED_ILLEGAL_OS_TYPE_IS_NOT_SUPPORTED_BY_ARCHITECTURE_TYPE(); + @DefaultStringValue("Cannot ${action} ${type}. Cannot set single display device to non Linux operating system.") String ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_OS_TYPE(); diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index 8adafcf..6f427d7 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -537,6 +537,7 @@ ACTION_TYPE_FAILED_ILLEGAL_NUM_OF_MONITORS=Cannot ${action} ${type}. Illegal number of monitors is provided, max allowed number of monitors is 1 for VNC and the max number in the ValidNumOfMonitors configuration variable for SPICE. ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_OS_TYPE=Cannot ${action} ${type}. Cannot set single display device to non Linux operating system. ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_DISPLAY_TYPE=Cannot ${action} ${type}. Cannot set single display device via VNC display. +ACTION_TYPE_FAILED_ILLEGAL_OS_TYPE_IS_NOT_SUPPORTED_BY_ARCHITECTURE_TYPE=Cannot ${action} ${type}. Selected operating system is not supported by the architecture. ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_INCOMPATIBLE_VERSION=Cannot ${action} ${type}. Cluster does not support Single Qxl Pci devices. ACTION_TYPE_FAILED_ILLEGAL_DOMAIN_NAME=Cannot ${action} ${type}. Illegal Domain name: ${Domain}. Domain name has unsupported special character ${Char}. ACTION_TYPE_FAILED_CANNOT_DECREASE_COMPATIBILITY_VERSION=Cannot decrease data center compatibility version. diff --git a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties index c60e334..ac47ad1 100644 --- a/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties +++ b/frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties @@ -555,6 +555,7 @@ ACTION_TYPE_FAILED_ILLEGAL_NUM_OF_MONITORS=Cannot ${action} ${type}. Illegal number of monitors is provided, max allowed number of monitors is 1 for VNC and the max number in the ValidNumOfMonitors configuration variable for SPICE. ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_OS_TYPE=Cannot ${action} ${type}. Cannot set single display device to non Linux operating system. ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_DISPLAY_TYPE=Cannot ${action} ${type}. Cannot set single display device via VNC display. +ACTION_TYPE_FAILED_ILLEGAL_OS_TYPE_IS_NOT_SUPPORTED_BY_ARCHITECTURE_TYPE=Cannot ${action} ${type}. Selected operating system is not supported by the architecture. ACTION_TYPE_FAILED_ILLEGAL_SINGLE_DEVICE_INCOMPATIBLE_VERSION=Cannot ${action} ${type}. Cluster does not support Single Qxl Pci devices. ACTION_TYPE_FAILED_ILLEGAL_DOMAIN_NAME=Cannot ${action} ${type}. Illegal Domain name: ${Domain}. Domain name has unsupported special character ${Char}. ACTION_TYPE_FAILED_CANNOT_DECREASE_COMPATIBILITY_VERSION=Cannot decrease data center compatibility version. -- To view, visit http://gerrit.ovirt.org/18347 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I2ff3fbada65e72e6fbb944cb56fb35d5acc88a89 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Gustavo Frederico Temple Pedrosa <gustavo.pedr...@eldorado.org.br> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches