Moti Asayag 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 the
   !X || !Y || !Z 

with

   return X && Y && Z;
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. 
  VmInterfaceType.pciPassthrough == VmInterfaceType.forValue(nic.getType());
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 :)

have you verified this is no Matcher that provides the same functionality ?

maybe such functionality should be added to test utils if it requires by other 
places.
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 <[email protected]>
Gerrit-Reviewer: Moti Asayag <[email protected]>
Gerrit-Reviewer: [email protected]
Gerrit-Reviewer: oVirt Jenkins CI Server
Gerrit-HasComments: Yes
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to