Search in sources :

Example 6 with MacPool

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;
}
Also used : MacPool(org.ovirt.engine.core.common.businessentities.MacPool)

Example 7 with MacPool

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));
}
Also used : MacPool(org.ovirt.engine.core.common.businessentities.MacPool) MacRange(org.ovirt.engine.core.common.businessentities.MacRange) EngineException(org.ovirt.engine.core.common.errors.EngineException) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Test(org.junit.Test)

Example 8 with MacPool

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;
}
Also used : MacPool(org.ovirt.engine.core.common.businessentities.MacPool) MacRange(org.ovirt.engine.core.common.businessentities.MacRange)

Example 9 with 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());
}
Also used : MacPool(org.ovirt.engine.core.common.businessentities.MacPool) Test(org.junit.Test)

Example 10 with MacPool

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);
}
Also used : MacPool(org.ovirt.engine.core.common.businessentities.MacPool)

Aggregations

MacPool (org.ovirt.engine.core.common.businessentities.MacPool)20 Test (org.junit.Test)8 Guid (org.ovirt.engine.core.compat.Guid)5 ArrayList (java.util.ArrayList)3 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)3 MacRange (org.ovirt.engine.core.common.businessentities.MacRange)3 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)1 MacPoolParameters (org.ovirt.engine.core.common.action.MacPoolParameters)1 RemoveMacPoolByIdParameters (org.ovirt.engine.core.common.action.RemoveMacPoolByIdParameters)1 VM (org.ovirt.engine.core.common.businessentities.VM)1 VmNetworkInterface (org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface)1 EngineException (org.ovirt.engine.core.common.errors.EngineException)1 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)1 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)1 NewSharedMacPoolModel (org.ovirt.engine.ui.uicommonweb.models.macpool.NewSharedMacPoolModel)1 SharedMacPoolModel (org.ovirt.engine.ui.uicommonweb.models.macpool.SharedMacPoolModel)1