Alona Kaplan has posted comments on this change. Change subject: engine: passthrough validation to add/updateVm/TemplateInterface commands ......................................................................
Patch Set 4: (3 comments) https://gerrit.ovirt.org/#/c/38118/4/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/template/AddVmTemplateInterfaceCommand.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/template/AddVmTemplateInterfaceCommand.java: Line 81: } Line 82: Line 83: Version clusterCompatibilityVersion = getVdsGroup().getCompatibilityVersion(); Line 84: VmNicValidator nicValidator = new VmNicValidator(getParameters().getInterface(), clusterCompatibilityVersion, getVmTemplate().getOsId()); Line 85: > i don't know how we got so far, but maybe it would be simpler to replace th Fixed in a new patch (the next one). Line 86: if (!validate(nicValidator.linkedCorrectly()) Line 87: || !validate(nicValidator.isCompatibleWithOs()) Line 88: || !validate(nicValidator.emptyNetworkValid()) Line 89: || !validate(nicValidator.profileValid(getVmTemplate().getVdsGroupId())) https://gerrit.ovirt.org/#/c/38118/4/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmNicValidator.java File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/validator/VmNicValidator.java: Line 116: } Line 117: Line 118: public ValidationResult typeMatchesProfile() { Line 119: boolean profilePassthrough = getVnicProfile() != null && getVnicProfile().isPassthrough(); Line 120: boolean typePassthrough = VmInterfaceType.pciPassthrough.equals(VmInterfaceType.forValue(nic.getType())); > you can compare enums by reference. Done Line 121: return ValidationResult.failWith(VdcBllMessages.ACTION_TYPE_FAILED_VM_INTERFACE_TYPE_NOT_MATCH_PROFILE) Line 122: .when(profilePassthrough ^ typePassthrough); Line 123: } Line 124: https://gerrit.ovirt.org/#/c/38118/4/backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/VmNicValidatorTest.java File backend/manager/modules/bll/src/test/java/org/ovirt/engine/core/bll/validator/VmNicValidatorTest.java: Line 268: when(vnicProfile.isPassthrough()).thenReturn(profilePassthorugh); Line 269: } Line 270: Line 271: when(nic.getType()).thenReturn(typePassthorugh ? VmInterfaceType.pciPassthrough.getValue() Line 272: : ((VmInterfaceType) anyEnumBut(VmInterfaceType.pciPassthrough)).getValue()); > anyEnumBut - nice :) Yes, I verified. Where are the test utils? (I will move it to the utils (after you'll tell me where are they) in a new patch). Line 273: } Line 274: Line 275: private <T extends Enum<?>> Enum<?> anyEnumBut(T excludeEnum) { Line 276: Enum<?> returnEnum = excludeEnum; -- To view, visit https://gerrit.ovirt.org/38118 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: I3424259005dc8559b714d3c891e5e7b9368e07d9 Gerrit-PatchSet: 4 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alona Kaplan <alkap...@redhat.com> Gerrit-Reviewer: Alona Kaplan <alkap...@redhat.com> Gerrit-Reviewer: Moti Asayag <masa...@redhat.com> Gerrit-Reviewer: automat...@ovirt.org Gerrit-Reviewer: oVirt Jenkins CI Server Gerrit-HasComments: Yes _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches