Yevgeny Zaspitsky has uploaded a new change for review. Change subject: engine,webadmin: Plugging of an unlinked ext VM net interface is blocked ......................................................................
engine,webadmin: Plugging of an unlinked ext VM net interface is blocked Plugged and unlinked VM network interface is not supported for an external network, thus the action is blocked. Change-Id: Ia944ca7e0430adc54a6cae6cb65b8a1df4e88d24 Bug-Url: https://bugzilla.redhat.com/1077796 Signed-off-by: Yevgeny Zaspitsky <yzasp...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmNicValidator.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/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties 6 files changed, 49 insertions(+), 7 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/32/32032/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java index 417a34c..9174ccc 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/UpdateVmInterfaceCommand.java @@ -210,7 +210,8 @@ || !validate(nicValidator.isCompatibleWithOs()) || !validate(nicValidator.emptyNetworkValid()) || !validate(nicValidator.hotUpdatePossible()) - || !validate(nicValidator.profileValid(getVm().getVdsGroupId()))) { + || !validate(nicValidator.profileValid(getVm().getVdsGroupId())) + || !validate(nicValidator.canExternalNetworkVnicBePlugged())) { return false; } @@ -375,5 +376,25 @@ ? ValidationResult.VALID : new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_BE_REWIRED); } + + public ValidationResult canExternalNetworkVnicBePlugged() { + if (RequiredAction.PLUG.equals(getRequiredAction()) && !nic.isLinked()) { + final boolean vnicAttachedToExternalNetwork = isVnicAttachedToExternalNetwork(); + if (validationResult != ValidationResult.VALID) { + return validationResult; + } + + if (vnicAttachedToExternalNetwork) { + return new ValidationResult(VdcBllMessages.PLUGGED_UNLINKED_EXTERNAL_VM_INTERFACE_IS_NOT_SUPPORTED); + } + } + + return ValidationResult.VALID; + } + + private boolean isVnicAttachedToExternalNetwork() { + final Network network = findVnicNetwork(); + return (network != null && network.isExternal()); + } } } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmNicValidator.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmNicValidator.java index 50fcc10..8ecbbb8 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmNicValidator.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmNicValidator.java @@ -30,6 +30,8 @@ protected int osId; + protected ValidationResult validationResult = ValidationResult.VALID; + public VmNicValidator(VmNic nic, Version version) { this.nic = nic; this.version = version; @@ -69,14 +71,11 @@ */ public ValidationResult profileValid(Guid clusterId) { if (nic.getVnicProfileId() != null) { - // Check that the profile exists - VnicProfile vnicProfile = getDbFacade().getVnicProfileDao().get(nic.getVnicProfileId()); - if (vnicProfile == null) { - return new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_VNIC_PROFILE_NOT_EXISTS); + final Network network = findVnicNetwork(); + if (validationResult != ValidationResult.VALID) { + return validationResult; } - // Check that the network exists in current cluster - Network network = getNetworkByVnicProfile(vnicProfile); if (network == null || !isNetworkInCluster(network, clusterId)) { return new ValidationResult(VdcBllMessages.NETWORK_NOT_EXISTS_IN_CURRENT_CLUSTER); } @@ -122,4 +121,19 @@ protected DbFacade getDbFacade() { return DbFacade.getInstance(); } + + protected Network findVnicNetwork() { + if (nic.getVnicProfileId() == null) { + return null; + } + + // Check that the profile exists + VnicProfile vnicProfile = getDbFacade().getVnicProfileDao().get(nic.getVnicProfileId()); + if (vnicProfile == null) { + validationResult = new ValidationResult(VdcBllMessages.ACTION_TYPE_FAILED_VNIC_PROFILE_NOT_EXISTS); + return null; + } + + return getNetworkByVnicProfile(vnicProfile); + } } 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 fac5612..d0825d4 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 @@ -776,6 +776,7 @@ ACTION_TYPE_FAILED_HOST_NETWORK_QOS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED), ACTION_TYPE_FAILED_HOST_NETWORK_LABELS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED), HOT_VM_INTERFACE_UPDATE_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED), + PLUGGED_UNLINKED_EXTERNAL_VM_INTERFACE_IS_NOT_SUPPORTED(ErrorType.NOT_SUPPORTED), ACTION_TYPE_FAILED_VM_INTERFACE_TYPE_IS_NOT_SUPPORTED_BY_OS(ErrorType.INCOMPATIBLE_VERSION), CANNOT_PERFORM_HOT_UPDATE(ErrorType.CONFLICT), CANNOT_PERFORM_HOT_UPDATE_WITH_PORT_MIRRORING(ErrorType.CONFLICT), 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 c5b3ff3..4b594d6 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AppErrors.properties @@ -617,6 +617,7 @@ ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_HAVE_MTU=Cannot ${action} ${type}. External network cannot have MTU set. ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_REQUIRED=Cannot ${action} ${type}. The management network '${NetworkName}' must be required, please change the network to be required and try again. ACTION_TYPE_FAILED_NETWORK_ADDRESS_CANNOT_BE_CHANGED=Cannot ${action} ${type}. The address of the network '${ACTION_TYPE_FAILED_NETWORK_ADDRESS_CANNOT_BE_CHANGED_LIST}' cannot be modified without reinstalling the host, since this address was used to create the host's certification. +PLUGGED_UNLINKED_EXTERNAL_VM_INTERFACE_IS_NOT_SUPPORTED=Plugged and unlinked VM network interface with external network is not supported. CANNOT_PREVIEW_ACTIVE_SNAPSHOT=Cannot preview Active VM snapshot. CONFIG_UNKNOWN_KEY=Illegal configuration entry.\n\ -Please check configuration entry name. 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 09726cb..0ef95a9 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 @@ -3369,4 +3369,8 @@ @DefaultStringValue("Cannot ${action} ${type}. Target cluster belongs to different Data Center.") String VDS_CLUSTER_ON_DIFFERENT_STORAGE_POOL(); + + @DefaultStringValue("Plugged and unlinked VM network interface with external network is not supported.") + String PLUGGED_UNLINKED_EXTERNAL_VM_INTERFACE_IS_NOT_SUPPORTED(); + } 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 410811f..00083a9 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 @@ -620,6 +620,7 @@ ACTION_TYPE_FAILED_EXTERNAL_NETWORK_CANNOT_HAVE_MTU=Cannot ${action} ${type}. External network cannot have MTU set. ACTION_TYPE_FAILED_MANAGEMENT_NETWORK_REQUIRED=Cannot ${action} ${type}. The management network '${NetworkName}' must be required, please change the network to be required and try again. ACTION_TYPE_FAILED_NETWORK_ADDRESS_CANNOT_BE_CHANGED=Cannot ${action} ${type}. The address of the network '${ACTION_TYPE_FAILED_NETWORK_ADDRESS_CANNOT_BE_CHANGED_LIST}' cannot be modified without reinstalling the host, since this address was used to create the host's certification. +PLUGGED_UNLINKED_EXTERNAL_VM_INTERFACE_IS_NOT_SUPPORTED=Plugged and unlinked VM network interface with external network is not supported. CANNOT_PREVIEW_ACTIVE_SNAPSHOT=Cannot preview Active VM snapshot. CONFIG_UNKNOWN_KEY=Illegal configuration entry.\n\ -Please check configuration entry name. -- To view, visit http://gerrit.ovirt.org/32032 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ia944ca7e0430adc54a6cae6cb65b8a1df4e88d24 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yevgeny Zaspitsky <yzasp...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches