Mike Kolesnik has posted comments on this change.
Change subject: engine: Validate Dup MAC Addresses upon Iface Plug
......................................................................
Patch Set 1: (3 inline comments)
I think there should be such a commit also for VM running, since you can
stumble across this situation there as well.
....................................................
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);
Perhaps it would be beneficial to add the mac address as a replacement in this
message (in a separate 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()) {
Why not sent the plugged as condition to filter by in the query?
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());
Perhaps it's better to just iterate over the list and make sure the MAC address
is as expected.
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]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches