Java Code Examples for com.vmware.vim25.VirtualMachineConfigSpec#setGuestId()
The following examples show how to use
com.vmware.vim25.VirtualMachineConfigSpec#setGuestId() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VmUtils.java From cs-actions with Apache License 2.0 | 6 votes |
VirtualMachineConfigSpec getPopulatedVmConfigSpec(VirtualMachineConfigSpec vmConfigSpec, VmInputs vmInputs, String name) { vmConfigSpec.setName(name); vmConfigSpec.setNumCPUs(vmInputs.getIntNumCPUs()); vmConfigSpec.setMemoryMB(vmInputs.getLongVmMemorySize()); vmConfigSpec.setAnnotation(vmInputs.getDescription()); if (vmInputs.getCoresPerSocket() != null) { vmConfigSpec.setNumCoresPerSocket(InputUtils.getIntInput(vmInputs.getCoresPerSocket(), DEFAULT_CORES_PER_SOCKET)); } if (vmInputs.getGuestOsId() != null) { vmConfigSpec.setGuestId(vmInputs.getGuestOsId()); } return vmConfigSpec; }
Example 2
Source File: VmwareHelper.java From cloudstack with Apache License 2.0 | 5 votes |
public static void setBasicVmConfig(VirtualMachineConfigSpec vmConfig, int cpuCount, int cpuSpeedMHz, int cpuReservedMhz, int memoryMB, int memoryReserveMB, String guestOsIdentifier, boolean limitCpuUse) { // VM config basics vmConfig.setMemoryMB((long)memoryMB); vmConfig.setNumCPUs(cpuCount); ResourceAllocationInfo cpuInfo = new ResourceAllocationInfo(); if (limitCpuUse) { cpuInfo.setLimit(((long)cpuSpeedMHz * cpuCount)); } else { cpuInfo.setLimit(-1L); } cpuInfo.setReservation((long)cpuReservedMhz); vmConfig.setCpuAllocation(cpuInfo); if (cpuSpeedMHz != cpuReservedMhz) { vmConfig.setCpuHotAddEnabled(true); } if (memoryMB != memoryReserveMB) { vmConfig.setMemoryHotAddEnabled(true); } ResourceAllocationInfo memInfo = new ResourceAllocationInfo(); memInfo.setLimit((long)memoryMB); memInfo.setReservation((long)memoryReserveMB); vmConfig.setMemoryAllocation(memInfo); vmConfig.setGuestId(guestOsIdentifier); }
Example 3
Source File: HypervisorHostHelper.java From cloudstack with Apache License 2.0 | 4 votes |
public static VirtualMachineMO createWorkerVM(VmwareHypervisorHost hyperHost, DatastoreMO dsMo, String vmName) throws Exception { // Allow worker VM to float within cluster so that we will have better chance to // create it successfully ManagedObjectReference morCluster = hyperHost.getHyperHostCluster(); if (morCluster != null) hyperHost = new ClusterMO(hyperHost.getContext(), morCluster); VirtualMachineMO workingVM = null; VirtualMachineConfigSpec vmConfig = new VirtualMachineConfigSpec(); vmConfig.setName(vmName); vmConfig.setMemoryMB((long)4); vmConfig.setNumCPUs(1); vmConfig.setGuestId(VirtualMachineGuestOsIdentifier.OTHER_GUEST.value()); VirtualMachineFileInfo fileInfo = new VirtualMachineFileInfo(); fileInfo.setVmPathName(dsMo.getDatastoreRootPath()); vmConfig.setFiles(fileInfo); VirtualLsiLogicController scsiController = new VirtualLsiLogicController(); scsiController.setSharedBus(VirtualSCSISharing.NO_SHARING); scsiController.setBusNumber(0); scsiController.setKey(1); VirtualDeviceConfigSpec scsiControllerSpec = new VirtualDeviceConfigSpec(); scsiControllerSpec.setDevice(scsiController); scsiControllerSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD); vmConfig.getDeviceChange().add(scsiControllerSpec); if (hyperHost.createVm(vmConfig)) { // Ugly work-around, it takes time for newly created VM to appear for (int i = 0; i < 10 && workingVM == null; i++) { workingVM = hyperHost.findVmOnHyperHost(vmName); try { Thread.sleep(1000); } catch (InterruptedException e) { s_logger.debug("[ignored] interupted while waiting to config vm."); } } } if (workingVM != null) { workingVM.setCustomFieldValue(CustomFieldConstants.CLOUD_WORKER, "true"); String workerTag = String.format("%d-%s", System.currentTimeMillis(), hyperHost.getContext().getStockObject("noderuninfo")); workingVM.setCustomFieldValue(CustomFieldConstants.CLOUD_WORKER_TAG, workerTag); } return workingVM; }