Search in sources :

Example 11 with MacPool

use of org.ovirt.engine.core.common.businessentities.MacPool in project ovirt-engine by oVirt.

the class SharedMacPoolListModel method removeMacPools.

private void removeMacPools() {
    ConfirmationModel model = new ConfirmationModel();
    model.setTitle(ConstantsManager.getInstance().getConstants().removeSharedMacPoolsTitle());
    // $NON-NLS-1$
    model.setHashName("remove_shared_mac_pools");
    model.setHelpTag(HelpTag.remove_shared_mac_pools);
    UICommand tempVar = UICommand.createDefaultOkUiCommand(CMD_REMOVE, this);
    model.getCommands().add(tempVar);
    // $NON-NLS-1$
    UICommand tempVar2 = UICommand.createCancelUiCommand(CMD_CANCEL, this);
    model.getCommands().add(tempVar2);
    List<String> macPoolNames = new ArrayList<>();
    for (MacPool macPool : getSelectedItems()) {
        macPoolNames.add(macPool.getName());
    }
    model.setItems(macPoolNames);
    setConfirmWindow(model);
}
Also used : MacPool(org.ovirt.engine.core.common.businessentities.MacPool) ArrayList(java.util.ArrayList) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) ConfirmationModel(org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)

Example 12 with MacPool

use of org.ovirt.engine.core.common.businessentities.MacPool in project ovirt-engine by oVirt.

the class ClusterModel method initSelectedMacPool.

private void initSelectedMacPool() {
    Collection<MacPool> allMacPools = getMacPoolListModel().getItems();
    Cluster cluster = getEntity();
    if (allMacPools != null && cluster != null) {
        Guid macPoolId = cluster.getMacPoolId();
        for (MacPool macPool : allMacPools) {
            if (macPool.getId().equals(macPoolId)) {
                getMacPoolListModel().setSelectedItem(macPool);
                break;
            }
        }
    }
}
Also used : MacPool(org.ovirt.engine.core.common.businessentities.MacPool) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Guid(org.ovirt.engine.core.compat.Guid)

Example 13 with MacPool

use of org.ovirt.engine.core.common.businessentities.MacPool in project ovirt-engine by oVirt.

the class MacPoolPerClusterTest method testModifyOfNotExistingMacPool.

@Test
public void testModifyOfNotExistingMacPool() throws Exception {
    macPoolPerCluster.initialize();
    expectedException.expect(IllegalStateException.class);
    MacPool macPool = createMacPool(null, null);
    Guid macPoolId = macPool.getId();
    expectedException.expectMessage(macPoolPerCluster.createExceptionMessageMacPoolHavingIdDoesNotExist(macPoolId));
    macPoolPerCluster.modifyPool(macPool);
}
Also used : MacPool(org.ovirt.engine.core.common.businessentities.MacPool) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 14 with MacPool

use of org.ovirt.engine.core.common.businessentities.MacPool in project ovirt-engine by oVirt.

the class MacsUsedAcrossWholeSystemTest method testGetMacsForMacPool.

@Test
public void testGetMacsForMacPool() {
    MacPool macPool = createMacPool();
    String mac1 = "mac1";
    String mac2 = "mac2";
    String mac31 = "mac31";
    String mac32 = "mac32";
    String mac41 = "mac41";
    String mac42 = "mac42";
    String mac51 = "mac51";
    String mac52 = "mac52";
    String mac61 = "mac61";
    String mac62 = "mac62";
    String mac7 = "mac7";
    String mac8 = "mac8";
    Cluster cluster1 = createCluster(macPool);
    VmNetworkInterface nic1 = createNic(mac1);
    VM vm1 = createVm(cluster1, nic1);
    Cluster cluster2 = createCluster(macPool);
    VmNetworkInterface nic2 = createNic(mac2);
    VmNetworkInterface nic2_fromSnapshot = createNic(mac2, nic2.getId());
    VM vm2 = createVm(cluster2, nic2);
    VM snapshot2 = createSnapshot(cluster2, vm2, nic2_fromSnapshot);
    Cluster cluster3 = createCluster(macPool);
    Guid nic3Id = Guid.newGuid();
    VmNetworkInterface nic3 = createNic(mac31, nic3Id);
    VM vm3 = createVm(cluster3, nic3);
    VmNetworkInterface nic3_fromSnapshot = createNic(mac32, nic3Id);
    VM snapshot3 = createSnapshot(cluster3, vm3, nic3_fromSnapshot);
    Cluster cluster4 = createCluster(macPool);
    VmNetworkInterface nic41 = createNic(mac42);
    VmNetworkInterface nic41_fromSnapshot = createNic(mac41);
    VmNetworkInterface nic42 = createNic(mac41);
    VM vm4 = createVm(cluster4, nic41, nic42);
    VM snapshot4 = createSnapshot(cluster4, vm4, nic41_fromSnapshot);
    Cluster cluster5 = createCluster(macPool);
    VmNetworkInterface nic5 = createNic(mac51);
    VmNetworkInterface nic5_fromSnapshot = createNic(mac52);
    VM notRunningVm = createVm(cluster5, Guid.newGuid(), false, true, nic5);
    VM snapshot5 = createSnapshot(cluster5, notRunningVm, nic5_fromSnapshot);
    VmNetworkInterface nic6 = createNic(mac61);
    VmNetworkInterface nic6_fromSnapshot = createNic(mac62);
    VM notStatelessVm = createVm(cluster5, Guid.newGuid(), true, false, nic6);
    VM snapshot6 = createSnapshot(cluster5, notStatelessVm, nic6_fromSnapshot);
    Cluster cluster6 = createCluster(macPool);
    VmNetworkInterface nic71 = createNic(mac7);
    VmNetworkInterface nic72 = createNic(mac7);
    VM vmWithDuplicates = createVm(cluster6, nic71, nic72);
    VmNetworkInterface nic81 = createNic(mac8);
    VmNetworkInterface nic82 = createNic(mac8);
    VmNetworkInterface nic83 = createNic(mac8);
    VM vmHavingSnapshotWithDuplicates = createVm(cluster6, nic83);
    VM snapshot7 = createSnapshot(cluster6, vmHavingSnapshotWithDuplicates, nic81, nic82);
    // mocking:
    when(clusterDao.getAllClustersByMacPoolId(macPool.getId())).thenReturn(Arrays.asList(cluster1, cluster2, cluster3, cluster4, cluster5, cluster6));
    mockClusterVms(cluster1, vm1);
    mockClusterVms(cluster2, vm2);
    mockClusterVms(cluster3, vm3);
    mockClusterVms(cluster4, vm4);
    mockClusterVms(cluster5, notRunningVm, notStatelessVm);
    mockClusterVms(cluster6, vmWithDuplicates, vmHavingSnapshotWithDuplicates);
    mockVmSnapshots(vm1, Optional.empty());
    mockVmSnapshots(vm2, Optional.of(snapshot2));
    mockVmSnapshots(vm3, Optional.of(snapshot3));
    mockVmSnapshots(vm4, Optional.of(snapshot4));
    mockVmSnapshots(notRunningVm, Optional.of(snapshot5));
    mockVmSnapshots(notStatelessVm, Optional.of(snapshot6));
    mockVmSnapshots(vmHavingSnapshotWithDuplicates, Optional.of(snapshot7));
    // verifying
    List<String> macsForMacPool = underTest.getMacsForMacPool(macPool.getId());
    assertThat(macsForMacPool, Matchers.containsInAnyOrder(mac1, mac2, mac31, mac32, mac41, mac42, mac51, mac61, mac7, mac7, mac8, mac8));
}
Also used : MacPool(org.ovirt.engine.core.common.businessentities.MacPool) VmNetworkInterface(org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface) VM(org.ovirt.engine.core.common.businessentities.VM) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) Guid(org.ovirt.engine.core.compat.Guid) Test(org.junit.Test)

Example 15 with MacPool

use of org.ovirt.engine.core.common.businessentities.MacPool in project ovirt-engine by oVirt.

the class MacPoolDaoTest method testGetDefaultPool.

@Test
public void testGetDefaultPool() throws Exception {
    final MacPool defaultPool = dao.getDefaultPool();
    assertThat(defaultPool, notNullValue());
    assertThat(defaultPool.getId(), is(FixturesTool.DEFAULT_MAC_POOL_ID));
    assertThat(defaultPool.isDefaultPool(), is(true));
}
Also used : MacPool(org.ovirt.engine.core.common.businessentities.MacPool) Test(org.junit.Test)

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