use of org.ovirt.engine.core.common.businessentities.MacPool in project ovirt-engine by oVirt.
the class MacsUsedAcrossWholeSystemTest method createMacPool.
private MacPool createMacPool() {
MacPool result = new MacPool();
result.setId(Guid.newGuid());
return result;
}
use of org.ovirt.engine.core.common.businessentities.MacPool in project ovirt-engine by oVirt.
the class MacPoolPerClusterTest method testModifyOfExistingMacPool.
@Test
public void testModifyOfExistingMacPool() throws Exception {
final String macAddress1 = "00:00:00:00:00:01";
final String macAddress2 = "00:00:00:00:00:02";
MacPool macPool = createMacPool(macAddress1, macAddress1);
Cluster cluster = createCluster(macPool);
mockCluster(cluster);
mockGettingAllMacPools(macPool);
macPoolPerCluster.initialize();
assertThat(getMacPool(cluster.getId()).addMac(MAC_FROM), is(true));
assertThat(getMacPool(cluster.getId()).addMac(MAC_FROM), is(false));
final String allocatedMac = allocateMac(cluster);
/*needed due to implementation of modifyPool;
modify assumes, that all allocated macs is used for vmNics. If allocatedMac succeeded it's expected that all
vmNics were also successfully persisted to db or all allocated macs were returned to the pool. So after
allocation we need to mock db, otherwise re-init in modifyPool would return improper results.*/
mockUsedMacsInSystem(getMacPool(cluster.getId()).getId(), allocatedMac, MAC_FROM);
assertThat(allocatedMac, is(macAddress1));
try {
allocateMac(cluster);
fail("this allocation should not succeed, MAC should be full.");
} catch (EngineException e) {
// ok, this exception should occur.
}
macPool.setAllowDuplicateMacAddresses(true);
final MacRange macRange = new MacRange();
macRange.setMacFrom(macAddress1);
macRange.setMacTo(macAddress2);
macPool.setRanges(Collections.singletonList(macRange));
macPoolPerCluster.modifyPool(macPool);
assertThat(getMacPool(cluster.getId()).addMac(MAC_FROM), is(true));
assertThat(allocateMac(cluster), is(macAddress2));
}
use of org.ovirt.engine.core.common.businessentities.MacPool in project ovirt-engine by oVirt.
the class MacPoolPerClusterTest method createMacPool.
private MacPool createMacPool(String macFrom, String macTo) {
final MacRange macRange = new MacRange();
macRange.setMacFrom(macFrom);
macRange.setMacTo(macTo);
final MacPool macPool = new MacPool();
macPool.setId(Guid.newGuid());
macPool.setRanges(Collections.singletonList(macRange));
return macPool;
}
use of org.ovirt.engine.core.common.businessentities.MacPool in project ovirt-engine by oVirt.
the class UpdateMacPoolCommandTest method testValidateDefaultFlagIsNotChangedWhenFlagNotChanged.
@Test
public void testValidateDefaultFlagIsNotChangedWhenFlagNotChanged() throws Exception {
final MacPool macPool1 = new MacPool();
final MacPool macPool2 = new MacPool();
assertThat(UpdateMacPoolCommand.validateDefaultFlagIsNotChanged(macPool1, macPool2), isValid());
}
use of org.ovirt.engine.core.common.businessentities.MacPool in project ovirt-engine by oVirt.
the class SharedMacPoolListModel method updateActionAvailability.
private void updateActionAvailability() {
getEditCommand().setIsExecutionAllowed(getSelectedItems() != null && getSelectedItems().size() == 1);
boolean removeAllowed = true;
if (getSelectedItems() == null || getSelectedItems().isEmpty()) {
removeAllowed = false;
} else {
for (MacPool macPool : getSelectedItems()) {
if (macPool.isDefaultPool()) {
removeAllowed = false;
break;
}
}
}
getRemoveCommand().setIsExecutionAllowed(removeAllowed);
}
Aggregations