本文整理汇总了Java中com.vmware.vim25.VirtualDevice类的典型用法代码示例。如果您正苦于以下问题:Java VirtualDevice类的具体用法?Java VirtualDevice怎么用?Java VirtualDevice使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
VirtualDevice类属于com.vmware.vim25包,在下文中一共展示了VirtualDevice类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCustomizationAdapterMappings
import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
protected List<CustomizationAdapterMapping> createCustomizationAdapterMappings(
VmwareProcessClient vmwareProcessClient, VirtualMachine machine) {
List<CustomizationAdapterMapping> nicSettingMap = new ArrayList<CustomizationAdapterMapping>();
// VirtualEthernetCardを取得
VirtualMachineConfigInfo configInfo = machine.getConfig();
for (VirtualDevice device : configInfo.getHardware().getDevice()) {
if (device instanceof VirtualEthernetCard) {
VirtualEthernetCard virtualEthernetCard = VirtualEthernetCard.class.cast(device);
CustomizationAdapterMapping mapping = new CustomizationAdapterMapping();
CustomizationIPSettings settings = new CustomizationIPSettings();
// すべてのNICをDHCPにする
CustomizationDhcpIpGenerator dhcpIp = new CustomizationDhcpIpGenerator();
settings.setIp(dhcpIp);
mapping.setMacAddress(virtualEthernetCard.getMacAddress());
mapping.setAdapter(settings);
nicSettingMap.add(mapping);
}
}
return nicSettingMap;
}
示例2: replaceNetworkAdapter
import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
private static void replaceNetworkAdapter(
VirtualMachineConfigSpec vmConfigSpec, VirtualDevice oldNIC,
ManagedObjectReference newNetworkRef, String newNetworkName)
throws Exception {
logger.debug("new network: " + newNetworkName);
VirtualEthernetCardNetworkBackingInfo nicBacking = new VirtualEthernetCardNetworkBackingInfo();
nicBacking.setDeviceName(newNetworkName);
nicBacking.setNetwork(newNetworkRef);
nicBacking.setUseAutoDetect(true);
oldNIC.setBacking(nicBacking);
VirtualDeviceConnectInfo info = new VirtualDeviceConnectInfo();
info.setConnected(true);
info.setStartConnected(true);
info.setAllowGuestControl(true);
oldNIC.setConnectable(info);
// oldNIC.getConnectable().setConnected(true);
// oldNIC.getConnectable().setStartConnected(true);
VirtualDeviceConfigSpec vmDeviceSpec = new VirtualDeviceConfigSpec();
vmDeviceSpec.setOperation(VirtualDeviceConfigSpecOperation.EDIT);
vmDeviceSpec.setDevice(oldNIC);
vmConfigSpec.getDeviceChange().add(vmDeviceSpec);
}
示例3: reconfigureDisks
import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
/**
* Reconfigures VMware system disks and data disks.
*/
public void reconfigureDisks(VirtualMachineConfigSpec vmConfigSpec,
ManagedObjectReference vmwInstance) throws Exception {
logger.debug("");
long systemDiskMB = (long) paramHandler.getConfigDiskSpaceMB();
VirtualMachineConfigInfo configSpec = (VirtualMachineConfigInfo) vmw
.getServiceUtil().getDynamicProperty(vmwInstance, "config");
List<VirtualDevice> devices = configSpec.getHardware().getDevice();
VirtualDisk vdSystemDisk = getVMSystemDisk(devices,
configSpec.getName());
configureSystemDisk(vmConfigSpec, systemDiskMB, vdSystemDisk);
configureDataDisks(vmConfigSpec, devices, vdSystemDisk);
}
示例4: getDataDiskKey
import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
private int getDataDiskKey() throws Exception {
List<VirtualDevice> devices = configSpec.getHardware().getDevice();
int countDisks = 0;
int key = -1;
for (VirtualDevice vdInfo : devices) {
if (vdInfo instanceof VirtualDisk) {
countDisks++;
if (countDisks == 2) {
key = ((VirtualDisk) vdInfo).getKey();
break;
}
}
}
return key;
}
示例5: getDiskSizeInGB
import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
private String getDiskSizeInGB(int disk) throws Exception {
String size = "";
List<VirtualDevice> devices = configSpec.getHardware().getDevice();
int countDisks = 0;
for (VirtualDevice vdInfo : devices) {
if (vdInfo instanceof VirtualDisk) {
countDisks++;
if (countDisks == disk) {
long gigabyte = ((VirtualDisk) vdInfo).getCapacityInKB()
/ 1024 / 1024;
size = Long.toString(gigabyte);
break;
}
}
}
return size;
}
示例6: createCdrom
import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
public static VirtualDeviceConfigSpec createCdrom(VirtualDevice ideController, int unitNumber) {
VirtualCdrom cdrom = new VirtualCdrom();
cdrom.setControllerKey(ideController.getKey());
cdrom.setUnitNumber(unitNumber);
VirtualDeviceConnectInfo info = new VirtualDeviceConnectInfo();
info.setAllowGuestControl(true);
info.setConnected(true);
info.setStartConnected(true);
cdrom.setConnectable(info);
VirtualCdromAtapiBackingInfo backing = new VirtualCdromAtapiBackingInfo();
backing.setDeviceName(String.format("cdrom-%d-%d", ideController.getKey(), unitNumber));
backing.setUseAutoDetect(false);
cdrom.setBacking(backing);
VirtualDeviceConfigSpec spec = new VirtualDeviceConfigSpec();
spec.setDevice(cdrom);
spec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
return spec;
}
示例7: createFloppy
import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
public static VirtualDeviceConfigSpec createFloppy(VirtualDevice sioController, int unitNumber) {
VirtualFloppy floppy = new VirtualFloppy();
floppy.setControllerKey(sioController.getKey());
floppy.setUnitNumber(unitNumber);
VirtualDeviceConnectInfo info = new VirtualDeviceConnectInfo();
info.setAllowGuestControl(true);
info.setConnected(true);
info.setStartConnected(true);
floppy.setConnectable(info);
VirtualFloppyDeviceBackingInfo backing = new VirtualFloppyDeviceBackingInfo();
backing.setDeviceName(String.format("floppy-%d", unitNumber));
floppy.setBacking(backing);
VirtualDeviceConfigSpec spec = new VirtualDeviceConfigSpec();
spec.setDevice(floppy);
spec.setOperation(VirtualDeviceConfigSpecOperation.ADD);
return spec;
}
示例8: updateDiskStateFromVirtualDevice
import com.vmware.vim25.VirtualDevice; //导入依赖的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());
}
}
示例9: updateDiskLinksAfterProvisionSuccess
import com.vmware.vim25.VirtualDevice; //导入依赖的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;
}
示例10: getSCSIController
import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
protected VirtualSCSIController getSCSIController(VirtualMachine machine) {
// 仮想マシンにあるSCSIコントローラのうち、BusNumberが0のものを取得する
VirtualSCSIController scsiController = null;
for (VirtualDevice device : machine.getConfig().getHardware().getDevice()) {
if (device instanceof VirtualSCSIController) {
VirtualSCSIController scsiController2 = VirtualSCSIController.class.cast(device);
if (scsiController2.getBusNumber() == 0) {
scsiController = scsiController2;
break;
}
}
}
if (scsiController == null) {
// SCSIコントローラが見つからない場合
// TODO: SCSIコントローラを作る?
throw new AutoException("EPROCESS-000517", 0);
}
return scsiController;
}
示例11: getVirtualDisk
import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
protected VirtualDisk getVirtualDisk(VirtualMachine machine, Integer scsiId) {
// SCSIコントローラを取得
VirtualSCSIController scsiController = getSCSIController(machine);
// SCSIコントローラとSCSI IDが一致するディスクを取得
VirtualDisk disk = null;
for (VirtualDevice device : machine.getConfig().getHardware().getDevice()) {
if (device instanceof VirtualDisk) {
VirtualDisk tmpDisk = VirtualDisk.class.cast(device);
if (tmpDisk.getControllerKey() != null && tmpDisk.getControllerKey().equals(scsiController.getKey())) {
if (tmpDisk.getUnitNumber() != null && tmpDisk.getUnitNumber().equals(scsiId)) {
disk = tmpDisk;
break;
}
}
}
}
if (disk == null) {
// VirtualDiskが見つからない場合
throw new AutoException("EPROCESS-000518", scsiId);
}
return disk;
}
示例12: findHardDisk
import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
public VirtualDisk findHardDisk(String diskName)
{
VirtualDevice[] devices = getAllVirtualDevices();
for(int i=0; i<devices.length; i++)
{
if(devices[i] instanceof VirtualDisk)
{
VirtualDisk vDisk = (VirtualDisk)devices[i];
if(diskName.equalsIgnoreCase(vDisk.getDeviceInfo().getLabel()))
{
return vDisk;
}
}
}
return null;
}
示例13: getVirtualDevicesOfType
import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public <T extends VirtualDevice> List<T> getVirtualDevicesOfType(Class<T> clazz)
{
List<T> result = new ArrayList<T>();
VirtualDevice[] devices = getAllVirtualDevices();
for(VirtualDevice dev : devices)
{
if(clazz.isInstance(dev)) // dynamic equivalent of instanceof operator
{
result.add((T)dev);
}
}
return result;
}
示例14: getDeviceByBackingFileName
import com.vmware.vim25.VirtualDevice; //导入依赖的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;
}
示例15: createAddCdConfigSpec
import com.vmware.vim25.VirtualDevice; //导入依赖的package包/类
static VirtualDeviceConfigSpec createAddCdConfigSpec(VirtualMachine vm, String dsName, String isoName) throws Exception
{
VirtualDeviceConfigSpec cdSpec = new VirtualDeviceConfigSpec();
cdSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
VirtualCdrom cdrom = new VirtualCdrom();
VirtualCdromIsoBackingInfo cdDeviceBacking = new VirtualCdromIsoBackingInfo();
DatastoreSummary ds = findDatastoreSummary(vm, dsName);
cdDeviceBacking.setDatastore(ds.getDatastore());
cdDeviceBacking.setFileName("[" + dsName +"] "+ vm.getName()
+ "/" + isoName + ".iso");
VirtualDevice vd = getIDEController(vm);
cdrom.setBacking(cdDeviceBacking);
cdrom.setControllerKey(vd.getKey());
cdrom.setUnitNumber(vd.getUnitNumber());
cdrom.setKey(-1);
cdSpec.setDevice(cdrom);
return cdSpec;
}