com.vmware.vim25.VirtualDeviceFileBackingInfo Java Examples
The following examples show how to use
com.vmware.vim25.VirtualDeviceFileBackingInfo.
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: 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 #2
Source File: VmwareDiskProcess.java From primecloud-controller with GNU General Public License v2.0 | 4 votes |
/** * TODO: メソッドコメントを記述 * * @param vmwareProcessClient * @param instanceNo * @param diskNo */ public void attachDisk(VmwareProcessClient vmwareProcessClient, Long instanceNo, Long diskNo) { VmwareDisk vmwareDisk = vmwareDiskDao.read(diskNo); if (BooleanUtils.isTrue(vmwareDisk.getAttached())) { // ディスクがアタッチ済みの場合はスキップ return; } VmwareInstance vmwareInstance = vmwareInstanceDao.read(instanceNo); //イベントログ出力 Component component = componentDao.read(vmwareDisk.getComponentNo()); Instance instance = instanceDao.read(instanceNo); Platform platform = platformDao.read(vmwareProcessClient.getPlatformNo()); if (StringUtils.isEmpty(vmwareDisk.getFileName())) { processLogger.debug(component, instance, "VmwareDiskCreate", new Object[] { platform.getPlatformName() }); } else { processLogger.debug(component, instance, "VmwareDiskAttach", new Object[] { platform.getPlatformName(), vmwareDisk.getFileName() }); } // ディスクのアタッチ VirtualDisk disk = vmwareProcessClient.attachDisk(vmwareInstance.getMachineName(), vmwareDisk.getScsiId(), vmwareDisk.getSize(), vmwareDisk.getFileName()); // ディスク情報の取得 VirtualDeviceFileBackingInfo backingInfo = VirtualDeviceFileBackingInfo.class.cast(disk.getBacking()); Datastore datastore = new Datastore( vmwareProcessClient.getVmwareClient().getServiceInstance().getServerConnection(), backingInfo.getDatastore()); //イベントログ出力 if (StringUtils.isEmpty(vmwareDisk.getFileName())) { processLogger.debug(component, instance, "VmwareDiskCreateFinish", new Object[] { platform.getPlatformName(), backingInfo.getFileName(), vmwareDisk.getSize() }); } else { processLogger.debug(component, instance, "VmwareDiskAttachFinish", new Object[] { platform.getPlatformName(), vmwareDisk.getFileName(), vmwareDisk.getSize() }); } // データベース更新 vmwareDisk = vmwareDiskDao.read(diskNo); vmwareDisk.setAttached(true); vmwareDisk.setDatastore(datastore.getName()); vmwareDisk.setFileName(backingInfo.getFileName()); vmwareDiskDao.update(vmwareDisk); }
Example #3
Source File: SiocManagerImpl.java From cloudstack with Apache License 2.0 | 4 votes |
private ResultWrapper updateSiocInfoForWorkerVM(VMwareUtil.VMwareConnection connection, ManagedObjectReference morVm, String datastoreName, int limitIopsPerGB) throws Exception { int limitIopsTotal = 0; List<ManagedObjectReference> tasks = new ArrayList<>(); VirtualMachineConfigInfo vmci = (VirtualMachineConfigInfo)VMwareUtil.getEntityProps(connection, morVm, new String[] { "config" }).get("config"); List<VirtualDevice> devices = vmci.getHardware().getDevice(); for (VirtualDevice device : devices) { if (device instanceof VirtualDisk) { VirtualDisk disk = (VirtualDisk)device; if (disk.getBacking() instanceof VirtualDeviceFileBackingInfo) { VirtualDeviceFileBackingInfo backingInfo = (VirtualDeviceFileBackingInfo)disk.getBacking(); if (backingInfo.getFileName().contains(datastoreName)) { boolean diskUpdated = false; StorageIOAllocationInfo sioai = disk.getStorageIOAllocation(); long currentLimitIops = sioai.getLimit() != null ? sioai.getLimit() : Long.MIN_VALUE; long newLimitIops = getNewLimitIopsBasedOnVolumeSize(disk.getCapacityInBytes(), limitIopsPerGB); limitIopsTotal += newLimitIops; if (currentLimitIops != newLimitIops) { sioai.setLimit(newLimitIops); diskUpdated = true; } if (diskUpdated) { VirtualDeviceConfigSpec vdcs = new VirtualDeviceConfigSpec(); vdcs.setDevice(disk); vdcs.setOperation(VirtualDeviceConfigSpecOperation.EDIT); VirtualMachineConfigSpec vmcs = new VirtualMachineConfigSpec(); vmcs.getDeviceChange().add(vdcs); try { ManagedObjectReference task = VMwareUtil.reconfigureVm(connection, morVm, vmcs); tasks.add(task); LOGGER.info(getInfoMsgForWorkerVm(newLimitIops)); } catch (Exception ex) { throw new Exception("Error: " + ex.getMessage()); } } } } } } return new ResultWrapper(limitIopsTotal, tasks); }