/** * Computes the maximum allowed number of vCPUs that can be assigned * to a VM according to the specified compatibility level. * * @param vmTemplate The VM template for which we want to know the maximum * @param compatibilityVersion The compatibility level * @return The maximum supported number of vCPUs */ public static Integer calcMaxVCpu(VmTemplate vmTemplate, Version compatibilityVersion) { return calcMaxVCpu(vmTemplate, compatibilityVersion, architectureFamily(vmTemplate)); }
@Override protected Integer maxNumOfVcpus() { return VmCpuCountHelper.calcMaxVCpu(vm, getVersion()); }
@Override protected Integer maxNumOfVcpus() { return VmCpuCountHelper.calcMaxVCpu(template, getVersion()); }
@Override protected Integer maxNumOfVcpus() { return VmCpuCountHelper.calcMaxVCpu(vm, getVersion()); }
@Override protected Integer maxNumOfVcpus() { return VmCpuCountHelper.calcMaxVCpu(vmTemplate, getVersion()); }
/** * Computes the maximum allowed number of vCPUs that can be assigned * to a VM according to the specified compatibility level. * * @param vm The VM for which we want to know the maximum * @param compatibilityVersion The compatibility level * @return The maximum supported number of vCPUs */ public static Integer calcMaxVCpu(VM vm, Version compatibilityVersion) { return calcMaxVCpu(vm.getStaticData(), compatibilityVersion, architectureFamily(vm)); }
@Test public void test256() { Integer maxVCpu = VmCpuCountHelper.calcMaxVCpu(null, new Integer(16), new Integer(288), 2, 8); assertEquals(new Integer(240), maxVCpu); }
@Test public void testPowerOf2() { Integer maxVCpu = VmCpuCountHelper.calcMaxVCpu(null, new Integer(16), new Integer(288), 2, 4); assertEquals(new Integer(128), maxVCpu); }
@Test public void testCommonX86() { Integer maxVCpu = VmCpuCountHelper.calcMaxVCpu(ArchitectureType.x86, new Integer(16), new Integer(288), 2, 12); assertEquals(new Integer(192), maxVCpu); }
@Test public void test256Ppc() { Integer maxVCpu = VmCpuCountHelper.calcMaxVCpu(ArchitectureType.ppc, new Integer(16), new Integer(288), 2, 8); assertEquals(new Integer(256), maxVCpu); }
@Test public void testPowerOf2X86() { Integer maxVCpu = VmCpuCountHelper.calcMaxVCpu(ArchitectureType.x86, new Integer(16), new Integer(288), 2, 4); assertEquals(new Integer(128), maxVCpu); }
@Test public void testPowerOf2Ppc() { Integer maxVCpu = VmCpuCountHelper.calcMaxVCpu(ArchitectureType.ppc, new Integer(16), new Integer(288), 2, 4); assertEquals(new Integer(128), maxVCpu); }
@Test public void testCommon() { Integer maxVCpu = VmCpuCountHelper.calcMaxVCpu(null, new Integer(16), new Integer(288), 2, 12); assertEquals(new Integer(192), maxVCpu); }
@Test public void testLimit() { Integer maxVCpu = VmCpuCountHelper.calcMaxVCpu(null, new Integer(16), new Integer(100), 2, 8); assertEquals(new Integer(96), maxVCpu); }
@Test public void test256X86() { Integer maxVCpu = VmCpuCountHelper.calcMaxVCpu(ArchitectureType.x86, new Integer(16), new Integer(288), 2, 8); assertEquals(new Integer(240), maxVCpu); }
@Test public void testAtLimitX86() { Integer maxVCpu = VmCpuCountHelper.calcMaxVCpu(ArchitectureType.x86, new Integer(16), new Integer(240), 2, 8); assertEquals(new Integer(240), maxVCpu); }
@Test public void testLimitX86() { Integer maxVCpu = VmCpuCountHelper.calcMaxVCpu(ArchitectureType.x86, new Integer(16), new Integer(240), 2, 16); assertEquals(new Integer(224), maxVCpu); }
@Test public void testCommonPpc() { Integer maxVCpu = VmCpuCountHelper.calcMaxVCpu(ArchitectureType.ppc, new Integer(16), new Integer(288), 2, 12); assertEquals(new Integer(288), maxVCpu); }
@Test public void testLimitPpc() { Integer maxVCpu = VmCpuCountHelper.calcMaxVCpu(ArchitectureType.x86, new Integer(16), new Integer(240), 2, 16); assertEquals(new Integer(224), maxVCpu); } }
/** * Computes the maximum allowed number of vCPUs that can be assigned * to a VM according to the specified compatibility level. * * @param vm The VM for which we want to know the maximum * @param compatibilityVersion The compatibility level * @param architecture Architecture family of the VM * @return The maximum supported number of vCPUs */ private static Integer calcMaxVCpu(VmBase vm, Version compatibilityVersion, ArchitectureType architecture) { Integer maxSockets = Config.<Integer>getValue( ConfigValues.MaxNumOfVmSockets, compatibilityVersion.getValue()); Integer maxVCpus = Config.<Integer>getValue( ConfigValues.MaxNumOfVmCpus, compatibilityVersion.getValue()); int threadsPerCore = vm.getThreadsPerCpu(); int cpuPerSocket = vm.getCpuPerSocket(); return calcMaxVCpu(architecture, maxSockets, maxVCpus, threadsPerCore, cpuPerSocket); }