Alona Kaplan has uploaded a new change for review. Change subject: webadmin: sr-iov validation on vnic profile ......................................................................
webadmin: sr-iov validation on vnic profile 1. Passthrough profile can be attached 1.1 just if it is compatable with the cluster version. 1.2 the vnic type is pci-passthrough. 2. non-passthrough profile cannor be used if the vnic type is pci-passthrough. Change-Id: Ib2d0d834d0bab6e2490279fef8f1140edcdfdcb1 Signed-off-by: Alona Kaplan <alkap...@redhat.com> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceModel.java A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/validation/VnicProfileValidation.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java 3 files changed, 68 insertions(+), 0 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/01/36101/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceModel.java index 6b75b58..46ee398 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInterfaceModel.java @@ -27,6 +27,7 @@ import org.ovirt.engine.ui.uicommonweb.validation.MacAddressValidation; import org.ovirt.engine.ui.uicommonweb.validation.NoSpecialCharactersWithDotValidation; import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation; +import org.ovirt.engine.ui.uicommonweb.validation.VnicProfileValidation; import org.ovirt.engine.ui.uicompat.ConstantsManager; import org.ovirt.engine.ui.uicompat.Event; import org.ovirt.engine.ui.uicompat.EventArgs; @@ -370,6 +371,9 @@ getNicType().validateSelectedItem(new IValidation[] { new NotEmptyValidation() }); + getProfile().validateSelectedItem(new IValidation[] { new VnicProfileValidation(clusterCompatibilityVersion.toString(), + getNicType().getEntity()) }); + getMAC().setIsValid(true); if (getMAC().getIsChangable()) { diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/validation/VnicProfileValidation.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/validation/VnicProfileValidation.java new file mode 100644 index 0000000..6302f64 --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/validation/VnicProfileValidation.java @@ -0,0 +1,55 @@ +package org.ovirt.engine.ui.uicommonweb.validation; + +import org.ovirt.engine.core.common.businessentities.network.VmInterfaceType; +import org.ovirt.engine.core.common.businessentities.network.VnicProfileView; +import org.ovirt.engine.core.common.queries.ConfigurationValues; +import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; +import org.ovirt.engine.ui.uicompat.ConstantsManager; + +public class VnicProfileValidation implements IValidation { + + private String clusterCompatabilityVersion; + private VmInterfaceType vnicType; + + public VnicProfileValidation(String clusterCompatabilityVersion, VmInterfaceType vnicType) { + this.clusterCompatabilityVersion = clusterCompatabilityVersion; + this.vnicType = vnicType; + } + + @Override + public ValidationResult validate(Object value) { + ValidationResult result = new ValidationResult(); + VnicProfileView profile = (VnicProfileView) value; + + boolean isPassthroughSupported = + (Boolean) AsyncDataProvider.getInstance() + .getConfigValuePreConverted(ConfigurationValues.NetworkSriovSupported, + clusterCompatabilityVersion); + + if (profile.isPassthrough() && !isPassthroughSupported) { + result.getReasons().add(ConstantsManager.getInstance() + .getMessages() + .passthroughNotSupported(clusterCompatabilityVersion)); + } + + result.setSuccess(false); + result.getReasons().add(ConstantsManager.getInstance().getConstants().thisFieldCantBeEmptyInvalidReason()); + + if (VmInterfaceType.pciPassthrough.equals(vnicType) && !profile.isPassthrough()) { + result.setSuccess(false); + result.getReasons().add(ConstantsManager.getInstance() + .getMessages() + .vnicTypeDoesntMatchPassthroughProfile(vnicType.getDescription())); + } + + if (!VmInterfaceType.pciPassthrough.equals(vnicType) && profile.isPassthrough()) { + result.setSuccess(false); + result.getReasons().add(ConstantsManager.getInstance() + .getMessages() + .vnicTypeDoesntMatchNonPassthroughProfile(vnicType.getDescription())); + } + + return result; + } + +} diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java index cb3329d..a830efa 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java @@ -403,4 +403,13 @@ @DefaultMessage("Default ({0})") String defaultMtu(int mtu); + + @DefaultMessage("The selected Profile is passthrough. SR-IOV passthrough is not supported for Cluster version {0}") + String passthroughNotSupported(String version); + + @DefaultMessage("Passthrough profile cannot be attached to a VM of type {0}") + String vnicTypeDoesntMatchPassthroughProfile(String type); + + @DefaultMessage("Non-Passthrough profile cannot be attached to a VM of type {0}") + String vnicTypeDoesntMatchNonPassthroughProfile(String type); } -- To view, visit http://gerrit.ovirt.org/36101 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ib2d0d834d0bab6e2490279fef8f1140edcdfdcb1 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alona Kaplan <alkap...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches