public boolean isPassthrough() { return VmInterfaceType.pciPassthrough.equals(VmInterfaceType.forValue(getType())); } }
@Override public ValidationResult validate(Object value) { VnicProfileView profile = (VnicProfileView) value; if (VmInterfaceType.pciPassthrough.equals(vnicType) && !profile.isPassthrough()) { return ValidationResult.fail(ConstantsManager.getInstance() .getMessages() .vnicTypeDoesntMatchNonPassthroughProfile(vnicType.getDescription())); } if (!VmInterfaceType.pciPassthrough.equals(vnicType) && profile.isPassthrough()) { return ValidationResult.fail(ConstantsManager.getInstance() .getMessages() .vnicTypeDoesntMatchPassthroughProfile(vnicType.getDescription())); } return ValidationResult.ok(); }
private void updateVnicType(VnicProfileView profile, VmNetworkInterface existingVnic, VmNetworkInterface editedVnic) { boolean shouldBePciPassthroughType = profile != null && profile.isPassthrough() && supportedInterfaceTypes != null && supportedInterfaceTypes.contains(VmInterfaceType.pciPassthrough); if (existingVnic == null) { if (shouldBePciPassthroughType) { editedVnic.setType(VmInterfaceType.pciPassthrough.getValue()); } else { editedVnic.setType(defaultType == null ? null : defaultType.getValue()); } } else { VmInterfaceType existingInterfaceType = VmInterfaceType.forValue(existingVnic.getType()); boolean shouldRestoreToDefault = profile != null && !profile.isPassthrough() && VmInterfaceType.pciPassthrough.equals(existingInterfaceType); if (shouldBePciPassthroughType) { existingVnic.setType(VmInterfaceType.pciPassthrough.getValue()); } else if (shouldRestoreToDefault || supportedInterfaceTypes == null || !supportedInterfaceTypes.contains(existingInterfaceType)) { existingVnic.setType(defaultType == null ? null : defaultType.getValue()); } } }
protected void updateLinkChangability() { boolean isNullProfileSelected = getProfile().getSelectedItem() == null; if (isNullProfileSelected) { getLinked().setIsChangeable(false); return; } if (VmInterfaceType.pciPassthrough.equals(getNicType().getSelectedItem()) || getProfile().getSelectedItem().isPassthrough()) { getLinked().setEntity(true); getLinked().setIsChangeable(false); getLinked().setChangeProhibitionReason(ConstantsManager.getInstance() .getConstants() .linkStateUpdateNotSupportedForPassthroughVnic()); return; } getLinked().setIsChangeable(true); }