Java Code Examples for com.vmware.vim25.VirtualDisk#setKey()
The following examples show how to use
com.vmware.vim25.VirtualDisk#setKey() .
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 |
private VirtualDisk createVirtualDisk(String volumeName, int controllerKey, int unitNumber, int key, VmInputs vmInputs, String parameter) throws Exception { VirtualDiskFlatVer2BackingInfo diskFileBacking = new VirtualDiskFlatVer2BackingInfo(); diskFileBacking.setFileName(volumeName); if (Operation.CREATE.toString().equalsIgnoreCase(parameter)) { diskFileBacking.setDiskMode(DiskMode.PERSISTENT.toString()); } else { diskFileBacking.setDiskMode(DiskMode.getValue(vmInputs.getVmDiskMode())); } VirtualDisk disk = new VirtualDisk(); disk.setBacking(diskFileBacking); disk.setControllerKey(controllerKey); disk.setUnitNumber(unitNumber); disk.setKey(key); disk.setCapacityInKB(vmInputs.getLongVmDiskSize() * DISK_AMOUNT_MULTIPLIER); return disk; }
Example 2
Source File: DiskManager.java From development with Apache License 2.0 | 5 votes |
private VirtualDeviceConfigSpec createNewDataDisk(VirtualDisk vdSystemDisk, long newDiskSpace, int deviceKey, int unitNumber) throws Exception { logger.info("reconfigureDisks() create data disk space with " + newDiskSpace + " KB"); ManagedObjectReference vmDatastore = ((VirtualDeviceFileBackingInfo) vdSystemDisk .getBacking()).getDatastore(); String vmDatastoreName = (String) vmw.getServiceUtil() .getDynamicProperty(vmDatastore, "summary.name"); VirtualDisk vdDataDisk = new VirtualDisk(); VirtualDiskFlatVer2BackingInfo diskfileBacking = new VirtualDiskFlatVer2BackingInfo(); diskfileBacking.setFileName("[" + vmDatastoreName + "]"); diskfileBacking.setDiskMode("persistent"); vdDataDisk.setKey(deviceKey); vdDataDisk.setControllerKey(vdSystemDisk.getControllerKey()); vdDataDisk.setUnitNumber(new Integer(unitNumber)); vdDataDisk.setBacking(diskfileBacking); vdDataDisk.setCapacityInKB(newDiskSpace); VirtualDeviceConfigSpec vmDeviceSpec = new VirtualDeviceConfigSpec(); vmDeviceSpec.setOperation(VirtualDeviceConfigSpecOperation.ADD); vmDeviceSpec .setFileOperation(VirtualDeviceConfigSpecFileOperation.CREATE); vmDeviceSpec.setDevice(vdDataDisk); return vmDeviceSpec; }
Example 3
Source File: VmwareHelper.java From cloudstack with Apache License 2.0 | 5 votes |
public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, int controllerKey, String vmdkDatastorePath, int sizeInMb, ManagedObjectReference morDs, int deviceNumber, int contextNumber) throws Exception { VirtualDisk disk = new VirtualDisk(); VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo(); backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.value()); backingInfo.setThinProvisioned(true); backingInfo.setEagerlyScrub(false); backingInfo.setDatastore(morDs); backingInfo.setFileName(vmdkDatastorePath); disk.setBacking(backingInfo); int ideControllerKey = vmMo.getIDEDeviceControllerKey(); if (controllerKey < 0) controllerKey = ideControllerKey; if (deviceNumber < 0) { deviceNumber = vmMo.getNextDeviceNumber(controllerKey); } disk.setControllerKey(controllerKey); disk.setKey(-contextNumber); disk.setUnitNumber(deviceNumber); disk.setCapacityInKB(sizeInMb * 1024); VirtualDeviceConnectInfo connectInfo = new VirtualDeviceConnectInfo(); connectInfo.setConnected(true); connectInfo.setStartConnected(true); disk.setConnectable(connectInfo); return disk; }
Example 4
Source File: VmwareHelper.java From cloudstack with Apache License 2.0 | 4 votes |
@SuppressWarnings("unchecked") public static VirtualDevice prepareDiskDevice(VirtualMachineMO vmMo, int controllerKey, Pair<String, ManagedObjectReference>[] vmdkDatastorePathChain, int deviceNumber, int contextNumber) throws Exception { assert (vmdkDatastorePathChain != null); assert (vmdkDatastorePathChain.length >= 1); VirtualDisk disk = new VirtualDisk(); VirtualDiskFlatVer2BackingInfo backingInfo = new VirtualDiskFlatVer2BackingInfo(); backingInfo.setDatastore(vmdkDatastorePathChain[0].second()); backingInfo.setFileName(vmdkDatastorePathChain[0].first()); backingInfo.setDiskMode(VirtualDiskMode.PERSISTENT.value()); if (vmdkDatastorePathChain.length > 1) { Pair<String, ManagedObjectReference>[] parentDisks = new Pair[vmdkDatastorePathChain.length - 1]; for (int i = 0; i < vmdkDatastorePathChain.length - 1; i++) parentDisks[i] = vmdkDatastorePathChain[i + 1]; setParentBackingInfo(backingInfo, parentDisks); } disk.setBacking(backingInfo); int ideControllerKey = vmMo.getIDEDeviceControllerKey(); if (controllerKey < 0) controllerKey = ideControllerKey; if (deviceNumber < 0) { deviceNumber = vmMo.getNextDeviceNumber(controllerKey); } disk.setControllerKey(controllerKey); disk.setKey(-contextNumber); disk.setUnitNumber(deviceNumber); VirtualDeviceConnectInfo connectInfo = new VirtualDeviceConnectInfo(); connectInfo.setConnected(true); connectInfo.setStartConnected(true); disk.setConnectable(connectInfo); return disk; }