use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class VmNumaNodeDaoTest method testMassUpdateNumaNode.
@Test
public void testMassUpdateNumaNode() {
List<VmNumaNode> result = vmNumaNodeDao.getAllVmNumaNodeByVmId(ANOTHER_EXISTING_VM_ID);
assertNotNull(result);
assertEquals(0, result.size());
Guid vmNumaNode1 = Guid.newGuid();
Guid vmNumaNode2 = Guid.newGuid();
List<VmNumaNode> newVmNode = new ArrayList<>();
VmNumaNode newVmNumaNode = new VmNumaNode();
newVmNumaNode.setCpuIds(generateCpuList(0, 4));
newVmNumaNode.setId(vmNumaNode1);
newVmNumaNode.setIndex(0);
newVmNumaNode.getVdsNumaNodeList().add(0);
newVmNode.add(newVmNumaNode);
newVmNumaNode = new VmNumaNode();
newVmNumaNode.setCpuIds(generateCpuList(4, 4));
newVmNumaNode.setId(vmNumaNode2);
newVmNumaNode.setIndex(1);
newVmNumaNode.getVdsNumaNodeList().add(1);
newVmNode.add(newVmNumaNode);
vmNumaNodeDao.massSaveNumaNode(newVmNode, ANOTHER_EXISTING_VM_ID);
result = vmNumaNodeDao.getAllVmNumaNodeByVmId(ANOTHER_EXISTING_VM_ID);
assertNotNull(result);
assertEquals(2, result.size());
Map<Guid, VmNumaNode> nodes = new HashMap<>(2);
nodes.put(result.get(0).getId(), result.get(0));
nodes.put(result.get(1).getId(), result.get(1));
nodes.get(vmNumaNode1).getVdsNumaNodeList().clear();
nodes.get(vmNumaNode1).getVdsNumaNodeList().add(1);
nodes.get(vmNumaNode2).getVdsNumaNodeList().clear();
nodes.get(vmNumaNode2).getVdsNumaNodeList().add(0);
newVmNode.clear();
newVmNode.add(nodes.get(vmNumaNode1));
newVmNode.add(nodes.get(vmNumaNode2));
vmNumaNodeDao.massUpdateNumaNode(newVmNode);
result = vmNumaNodeDao.getAllVmNumaNodeByVmId(ANOTHER_EXISTING_VM_ID);
assertNotNull(result);
assertEquals(2, result.size());
nodes.clear();
nodes.put(result.get(0).getId(), result.get(0));
nodes.put(result.get(1).getId(), result.get(1));
assertTrue(nodes.containsKey(vmNumaNode1));
assertTrue(nodes.containsKey(vmNumaNode2));
assertEquals(1, nodes.get(vmNumaNode1).getVdsNumaNodeList().size());
assertEquals(1, nodes.get(vmNumaNode1).getVdsNumaNodeList().get(0).intValue());
assertEquals(1, nodes.get(vmNumaNode2).getVdsNumaNodeList().size());
assertEquals(0, nodes.get(vmNumaNode2).getVdsNumaNodeList().get(0).intValue());
List<Guid> vmNodeList = new ArrayList<>();
vmNodeList.add(vmNumaNode1);
vmNodeList.add(vmNumaNode2);
vmNumaNodeDao.massRemoveNumaNodeByNumaNodeId(vmNodeList);
result = vmNumaNodeDao.getAllVmNumaNodeByVmId(ANOTHER_EXISTING_VM_ID);
assertNotNull(result);
assertEquals(0, result.size());
}
use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class VmNumaNodeDaoTest method testGetAllVmNumaNodeByVmId.
@Test
public void testGetAllVmNumaNodeByVmId() {
List<VmNumaNode> result = vmNumaNodeDao.getAllVmNumaNodeByVmId(EXISTING_VM_ID);
assertNotNull(result);
assertEquals(2, result.size());
Guid vmNumaNode1 = new Guid("3c2b81e6-5080-4ad1-86a1-cf513b15b517");
Guid vmNumaNode2 = new Guid("3c2b81e6-5080-4ad1-86a1-cf513b15b518");
Map<Guid, VmNumaNode> nodes = new HashMap<>(2);
nodes.put(result.get(0).getId(), result.get(0));
nodes.put(result.get(1).getId(), result.get(1));
assertTrue(nodes.containsKey(vmNumaNode1));
assertTrue(nodes.containsKey(vmNumaNode2));
assertEquals(2, nodes.get(vmNumaNode1).getVdsNumaNodeList().size());
assertTrue(nodes.get(vmNumaNode1).getVdsNumaNodeList().contains(0));
assertTrue(nodes.get(vmNumaNode1).getVdsNumaNodeList().contains(1));
assertEquals(0, nodes.get(vmNumaNode2).getVdsNumaNodeList().size());
}
use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class VmInfoBuildUtils method getVmNumaNodes.
public List<VmNumaNode> getVmNumaNodes(VM vm) {
List<VmNumaNode> vmNumaNodes = vmNumaNodeDao.getAllVmNumaNodeByVmId(vm.getId());
if (!vmNumaNodes.isEmpty()) {
return vmNumaNodes;
}
// create a default one with one guest numa node
if (FeatureSupported.hotPlugMemory(vm.getCompatibilityVersion(), vm.getClusterArch())) {
VmNumaNode vmNode = new VmNumaNode();
vmNode.setIndex(0);
vmNode.setMemTotal(vm.getMemSizeMb());
for (int i = 0; i < vm.getNumOfCpus(); i++) {
vmNode.getCpuIds().add(i);
}
return Collections.singletonList(vmNode);
}
// no need to send numa if memory hotplug not supported
return Collections.emptyList();
}
use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class NumaTestUtils method createVmNumaNode.
public static VmNumaNode createVmNumaNode(int index) {
VmNumaNode vmNumaNode = new VmNumaNode();
vmNumaNode.setIndex(index);
vmNumaNode.setMemTotal(1000);
return vmNumaNode;
}
use of org.ovirt.engine.core.common.businessentities.VmNumaNode in project ovirt-engine by oVirt.
the class NumaTestUtils method createVmNumaNodeWithId.
public static VmNumaNode createVmNumaNodeWithId(int index, Guid guid) {
final VmNumaNode numaNode = createVmNumaNode(index);
numaNode.setId(guid);
return numaNode;
}
Aggregations