Package com.vmware.vim25.mox
Class VirtualMachineDeviceManager
java.lang.Object
com.vmware.vim25.mox.VirtualMachineDeviceManager
VirtualMachineDeviceManager manages the virtual devices in a much
simplified way than using the reconfigVM_Task() method defined in
VirtualMachine managed object.
Devices it manages include: FloppyDrive, CdDrive, NetworkAdapter, UsbDevice, HardDisk Operations include: create -- create something new add -- add something existing but not yet attached to the virtual machine remove -- remove the device(s) from the virtual machine get -- retrieve the device(s) from the virtual machine update -- update the existing device with new configuration
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration for all the possible network adapter types -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddCdDriveFromHost(String hostDevice, boolean startConnected) addCdDriveFromIso(String isoPath, boolean startConnected) addFloppyDriveFromHost(String hostDevice, boolean startConnected) addFloppyDriveFromISO(String floppyImagePath, boolean startConnected) voidaddHardDisk(String diskFilePath, VirtualDiskMode diskMode) voidcreateFloppyDrive(String floppyImagePath, boolean startConnected) voidcreateHardDisk(int diskSizeMB, VirtualDiskType type, VirtualDiskMode mode) voidcreateNetworkAdapter(VirtualMachineDeviceManager.VirtualNetworkAdapterType type, String networkName, String macAddress, boolean wakeOnLan, boolean startConnected) Create a new virtual network adapter on the VM Your MAC address should start with 00:50:56findHardDisk(String diskName) Get all the virtual devices of a virtual machinegetPassThroughDevice(String type) <T extends VirtualDevice>
List<T> getVirtualDevicesOfType(Class<T> clazz) getVM()removeDevice(VirtualDevice device, boolean destroyDeviceBacking) Remove the device.removeDevices(List<VirtualDevice> deviceList, boolean destroyDeviceBacking) Remove all devices as listed in the deviceList.void
-
Constructor Details
-
VirtualMachineDeviceManager
-
-
Method Details
-
getVM
-
addFloppyDriveFromISO
public Task addFloppyDriveFromISO(String floppyImagePath, boolean startConnected) throws InvalidName, VmConfigFault, DuplicateName, TaskInProgress, FileFault, InvalidState, ConcurrentAccess, InvalidDatastore, InsufficientResourcesFault, RuntimeFault, RemoteException - Parameters:
floppyImagePath- - i.e. "[storage1] myVM/myFloppy.flp" Note: there is a space after ].- Throws:
InvalidNameVmConfigFaultDuplicateNameTaskInProgressFileFaultInvalidStateConcurrentAccessInvalidDatastoreInsufficientResourcesFaultRuntimeFaultRemoteException
-
addFloppyDriveFromHost
public Task addFloppyDriveFromHost(String hostDevice, boolean startConnected) throws InvalidName, VmConfigFault, DuplicateName, TaskInProgress, FileFault, InvalidState, ConcurrentAccess, InvalidDatastore, InsufficientResourcesFault, RuntimeFault, RemoteException - Parameters:
hostDevice- - i.e. "/dev/fd0"- Throws:
InvalidNameVmConfigFaultDuplicateNameTaskInProgressFileFaultInvalidStateConcurrentAccessInvalidDatastoreInsufficientResourcesFaultRuntimeFaultRemoteException
-
createFloppyDrive
public Task createFloppyDrive(String floppyImagePath, boolean startConnected) throws InvalidName, VmConfigFault, DuplicateName, TaskInProgress, FileFault, InvalidState, ConcurrentAccess, InvalidDatastore, InsufficientResourcesFault, RuntimeFault, RemoteException -
getPassThroughDevice
-
addPassthroughDevice
public void addPassthroughDevice() -
removePassthroughDevice
public void removePassthroughDevice() -
addCdDriveFromIso
public Task addCdDriveFromIso(String isoPath, boolean startConnected) throws InvalidProperty, RuntimeFault, RemoteException, InterruptedException -
addCdDriveFromHost
public Task addCdDriveFromHost(String hostDevice, boolean startConnected) throws InvalidProperty, RuntimeFault, RemoteException, InterruptedException -
createHardDisk
public void createHardDisk(int diskSizeMB, VirtualDiskType type, VirtualDiskMode mode) throws Exception - Throws:
Exception
-
addHardDisk
- Throws:
Exception
-
findHardDisk
-
createNetworkAdapter
public void createNetworkAdapter(VirtualMachineDeviceManager.VirtualNetworkAdapterType type, String networkName, String macAddress, boolean wakeOnLan, boolean startConnected) throws InvalidProperty, RuntimeFault, RemoteException, InterruptedException Create a new virtual network adapter on the VM Your MAC address should start with 00:50:56 -
removeDevice
public Task removeDevice(VirtualDevice device, boolean destroyDeviceBacking) throws InvalidName, VmConfigFault, DuplicateName, TaskInProgress, FileFault, InvalidState, ConcurrentAccess, InvalidDatastore, InsufficientResourcesFault, RuntimeFault, RemoteException Remove the device. Make sure the VM is powered off before calling this method. If destroyDeviceBacking is true, it deletes backings for example files in datastore. BE CAREFUL! -
removeDevices
public Task removeDevices(List<VirtualDevice> deviceList, boolean destroyDeviceBacking) throws InvalidName, VmConfigFault, DuplicateName, TaskInProgress, FileFault, InvalidState, ConcurrentAccess, InvalidDatastore, InsufficientResourcesFault, RuntimeFault, RemoteException Remove all devices as listed in the deviceList. These devices can be different types. Make sure the VM is powered off before calling this method. If destroyDeviceBacking is true, it deletes backings for example files in datastore. BE CAREFUL! -
getAllVirtualDevices
Get all the virtual devices of a virtual machine- Returns:
- VirtualDevice[]
-
getVirtualDevicesOfType
-
getDeviceByBackingFileName
-