Muli Salem has posted comments on this change.
Change subject: engine: Validate Dup MAC Addresses upon Iface Plug
......................................................................
Patch Set 1: (3 inline comments)
....................................................
File
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/network/vm/ActivateDeactivateVmNicCommand.java
Line 159: Boolean allowDupMacs = Config.<Boolean>
GetValue(ConfigValues.AllowDuplicateMacAddresses);
Line 160: if (allowDupMacs ||
!existsPluggedInterfaceWithSameMac(vmNetworkInterface)) {
Line 161: return ValidationResult.VALID;
Line 162: } else {
Line 163: return new
ValidationResult(VdcBllMessages.NETWORK_MAC_ADDRESS_IN_USE);
Sure, in a future patch.
Line 164: }
Line 165: }
Line 166:
Line 167: private boolean
existsPluggedInterfaceWithSameMac(VmNetworkInterface interfaceToPlug) {
Line 167: private boolean
existsPluggedInterfaceWithSameMac(VmNetworkInterface interfaceToPlug) {
Line 168: List<VmNetworkInterface> vmNetworkIntrefaces =
Line 169:
getDbFacade().getVmNetworkInterfaceDao().getAllForMac(interfaceToPlug.getMacAddress());
Line 170: for (VmNetworkInterface vmNetworkInterface :
vmNetworkIntrefaces) {
Line 171: if
(!interfaceToPlug.getId().equals(vmNetworkInterface.getId()) &&
vmNetworkInterface.isPlugged()) {
I prefer to leave it more generic, and since we should expect a small result
set, I don't see a problem with iterating over them.
Line 172: return true;
Line 173: }
Line 174: }
Line 175: return false;
....................................................
File
backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/VmNetworkInterfaceDaoTest.java
Line 279:
Line 280: @Test
Line 281: public void testGetAllForMac() throws Exception {
Line 282: List<VmNetworkInterface> result =
dao.getAllForMac(FixturesTool.MAC_ADDRESS);
Line 283: assertEquals(1, result.size());
Not sure what you are aiming for, please elaborate.
The way it is written at the moment, we verify that the result has exactly one
result, and that the result is the one we expect.
Line 284: assertEquals(FixturesTool.VM_NETWORK_INTERFACE2,
result.get(0).getId());
Line 285: }
Line 286:
Line 287: private void
assertCorrectResultForTemplate(List<VmNetworkInterface> result) {
--
To view, visit http://gerrit.ovirt.org/12242
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: comment
Gerrit-Change-Id: If1476e8bec112c0c592e5cc16deefcf67076f5dc
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Muli Salem <[email protected]>
Gerrit-Reviewer: Mike Kolesnik <[email protected]>
Gerrit-Reviewer: Moti Asayag <[email protected]>
Gerrit-Reviewer: Muli Salem <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches