本文整理汇总了Java中com.vmware.vim25.VirtualDeviceFileBackingInfo类的典型用法代码示例。如果您正苦于以下问题:Java VirtualDeviceFileBackingInfo类的具体用法?Java VirtualDeviceFileBackingInfo怎么用?Java VirtualDeviceFileBackingInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VirtualDeviceFileBackingInfo类属于com.vmware.vim25包,在下文中一共展示了VirtualDeviceFileBackingInfo类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateDiskStateFromVirtualDevice
import com.vmware.vim25.VirtualDeviceFileBackingInfo; //导入依赖的package包/类
/**
* Capture virtual cdrom attributes in the disk state for reference.
*/
public static void updateDiskStateFromVirtualDevice(VirtualDevice vd, DiskService.DiskState
disk, VirtualDeviceBackingInfo backing) {
fillInControllerUnitNumber(disk, vd.getUnitNumber());
if (backing != null && backing instanceof VirtualDeviceFileBackingInfo) {
disk.sourceImageReference = VimUtils
.datastorePathToUri(((VirtualDeviceFileBackingInfo) backing).getFileName());
}
disk.status = DiskService.DiskStatus.ATTACHED;
CustomProperties.of(disk)
.put(PROVIDER_DISK_UNIQUE_ID, vd.getDeviceInfo().getLabel());
if (vd.getConnectable() != null) {
CustomProperties.of(disk)
.put(DEVICE_CONNECTED, vd.getConnectable().isConnected())
.put(DEVICE_STATUS, vd.getConnectable().getStatus());
}
}
示例2: updateDiskLinksAfterProvisionSuccess
import com.vmware.vim25.VirtualDeviceFileBackingInfo; //导入依赖的package包/类
/**
* Update the details of the disk into compute state after the provisioning is successful
*/
private void updateDiskLinksAfterProvisionSuccess(ComputeState state, List<VirtualDevice> disks,
ProvisionContext ctx) {
ArrayList<String> diskLinks = new ArrayList<>(disks.size());
// Fill in the disk links from the input to the ComputeState, as it may contain non hdd
// disk as well. For ex, Floppy or CD-Rom
ctx.disks.stream().forEach(ds -> diskLinks.add(ds.documentSelfLink));
// Handle all the HDD disk
for (VirtualDevice disk : disks) {
DiskStateExpanded matchedDs = findMatchingDiskState(disk, ctx.disks);
if (disk.getBacking() instanceof VirtualDeviceFileBackingInfo) {
handleVirtualDiskUpdate(matchedDs, (VirtualDisk) disk, diskLinks, ctx);
} else if (disk instanceof VirtualCdrom) {
handleVirtualDeviceUpdate(matchedDs, DiskType.CDROM, disk, diskLinks, ctx);
} else if (disk instanceof VirtualFloppy) {
handleVirtualDeviceUpdate(matchedDs, DiskType.FLOPPY, disk, diskLinks, ctx);
} else {
continue;
}
}
state.diskLinks = diskLinks;
}
示例3: getDeviceByBackingFileName
import com.vmware.vim25.VirtualDeviceFileBackingInfo; //导入依赖的package包/类
public VirtualDevice getDeviceByBackingFileName(String name)
{
if(name==null)
{
throw new IllegalArgumentException("name must not be null!");
}
VirtualDevice[] devices = this.getAllVirtualDevices();
for(VirtualDevice device : devices)
{
VirtualDeviceBackingInfo bi = device.getBacking();
if(bi instanceof VirtualDeviceFileBackingInfo)
{
String fileName = ((VirtualDeviceFileBackingInfo)bi).getFileName();
if(name.equals(fileName))
return device;
}
}
return null;
}
示例4: createNewDataDisk
import com.vmware.vim25.VirtualDeviceFileBackingInfo; //导入依赖的package包/类
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;
}
示例5: handleVirtualDiskUpdate
import com.vmware.vim25.VirtualDeviceFileBackingInfo; //导入依赖的package包/类
/**
* Process VirtualDisk and update the details in the diskLinks of the provisioned compute
*/
private void handleVirtualDiskUpdate(DiskStateExpanded matchedDs, VirtualDisk disk,
ArrayList<String> diskLinks, ProvisionContext ctx) {
VirtualDeviceFileBackingInfo backing = (VirtualDeviceFileBackingInfo) disk.getBacking();
if (matchedDs == null) {
// This is the new disk, hence add it to the list
DiskState ds = new DiskState();
ds.documentSelfLink = UriUtils.buildUriPath(
DiskService.FACTORY_LINK, getHost().nextUUID());
ds.name = disk.getDeviceInfo().getLabel();
ds.creationTimeMicros = Utils.getNowMicrosUtc();
ds.type = DiskType.HDD;
ds.regionId = ctx.parent.description.regionId;
ds.capacityMBytes = disk.getCapacityInKB() / 1024;
ds.sourceImageReference = VimUtils.datastorePathToUri(backing.getFileName());
updateDiskStateFromVirtualDisk(disk, ds);
if (disk.getStorageIOAllocation() != null) {
StorageIOAllocationInfo storageInfo = disk.getStorageIOAllocation();
CustomProperties.of(ds)
.put(SHARES, storageInfo.getShares().getShares())
.put(LIMIT_IOPS, storageInfo.getLimit())
.put(SHARES_LEVEL, storageInfo.getShares().getLevel().value());
}
fillInControllerUnitNumber(ds, disk.getUnitNumber());
createDiskOnDemand(ds);
diskLinks.add(ds.documentSelfLink);
} else {
// This is known disk, hence update with the provisioned attributes.
matchedDs.sourceImageReference = VimUtils.datastorePathToUri(backing.getFileName());
updateDiskStateFromVirtualDisk(disk, matchedDs);
createDiskPatch(matchedDs);
}
}
示例6: attachDisk
import com.vmware.vim25.VirtualDeviceFileBackingInfo; //导入依赖的package包/类
/**
* 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);
}
示例7: updateSiocInfoForWorkerVM
import com.vmware.vim25.VirtualDeviceFileBackingInfo; //导入依赖的package包/类
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);
}