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);
}
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;
}
}
}
}
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);
}
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));
}
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));
}
Aggregations