com.vmware.vim25.mox
Class VirtualMachineDeviceManager

java.lang.Object
  extended by com.vmware.vim25.mox.VirtualMachineDeviceManager

public class VirtualMachineDeviceManager
extends Object

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

Author:
Steve Jin (http://www.doublecloud.org)

Nested Class Summary
static class VirtualMachineDeviceManager.VirtualNetworkAdapterType
          Enumeration for all the possible network adapter types
 
Constructor Summary
VirtualMachineDeviceManager(VirtualMachine vm)
           
 
Method Summary
 void addCdDriveFromHost(String hostDevice, boolean startConnected)
           
 void addCdDriveFromIso(String isoPath, boolean startConnected)
           
 Task addFloppyDriveFromHost(String hostDevice, boolean startConnected)
           
 Task addFloppyDriveFromISO(String floppyImagePath, boolean startConnected)
           
 void addHardDisk(String diskFilePath, VirtualDiskMode diskMode)
           
 void addPassthroughDevice()
           
 Task createFloppyDrive(String floppyImagePath, boolean startConnected)
           
 void createHardDisk(int diskSizeMB, VirtualDiskType type, VirtualDiskMode mode)
           
 void createNetworkAdapter(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:56
 VirtualDisk findHardDisk(String diskName)
           
 VirtualDevice[] getAllVirtualDevices()
          Get all the virtual devices of a virtual machine
 VirtualDevice getDeviceByBackingFileName(String name)
           
 String getPassThroughDevice(String type)
           
<T extends VirtualDevice>
List<T>
getVirtualDevicesOfType(Class<T> clazz)
           
 VirtualMachine getVM()
           
 Task removeDevice(VirtualDevice device, boolean destroyDeviceBacking)
          Remove the device.
 Task removeDevices(List<VirtualDevice> deviceList, boolean destroyDeviceBacking)
          Remove all devices as listed in the deviceList.
 void removePassthroughDevice()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VirtualMachineDeviceManager

public VirtualMachineDeviceManager(VirtualMachine vm)
Method Detail

getVM

public VirtualMachine 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:
InvalidName
VmConfigFault
DuplicateName
TaskInProgress
FileFault
InvalidState
ConcurrentAccess
InvalidDatastore
InsufficientResourcesFault
RuntimeFault
RemoteException

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:
InvalidName
VmConfigFault
DuplicateName
TaskInProgress
FileFault
InvalidState
ConcurrentAccess
InvalidDatastore
InsufficientResourcesFault
RuntimeFault
RemoteException

createFloppyDrive

public Task createFloppyDrive(String floppyImagePath,
                              boolean startConnected)
                       throws InvalidName,
                              VmConfigFault,
                              DuplicateName,
                              TaskInProgress,
                              FileFault,
                              InvalidState,
                              ConcurrentAccess,
                              InvalidDatastore,
                              InsufficientResourcesFault,
                              RuntimeFault,
                              RemoteException
Throws:
InvalidName
VmConfigFault
DuplicateName
TaskInProgress
FileFault
InvalidState
ConcurrentAccess
InvalidDatastore
InsufficientResourcesFault
RuntimeFault
RemoteException

getPassThroughDevice

public String getPassThroughDevice(String type)

addPassthroughDevice

public void addPassthroughDevice()

removePassthroughDevice

public void removePassthroughDevice()

addCdDriveFromIso

public void addCdDriveFromIso(String isoPath,
                              boolean startConnected)
                       throws InvalidProperty,
                              RuntimeFault,
                              RemoteException,
                              InterruptedException
Throws:
InvalidProperty
RuntimeFault
RemoteException
InterruptedException

addCdDriveFromHost

public void addCdDriveFromHost(String hostDevice,
                               boolean startConnected)
                        throws InvalidProperty,
                               RuntimeFault,
                               RemoteException,
                               InterruptedException
Throws:
InvalidProperty
RuntimeFault
RemoteException
InterruptedException

createHardDisk

public void createHardDisk(int diskSizeMB,
                           VirtualDiskType type,
                           VirtualDiskMode mode)
                    throws Exception
Throws:
Exception

addHardDisk

public void addHardDisk(String diskFilePath,
                        VirtualDiskMode diskMode)
                 throws Exception
Throws:
Exception

findHardDisk

public VirtualDisk findHardDisk(String diskName)

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

Throws:
InvalidProperty
RuntimeFault
RemoteException
InterruptedException

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!

Throws:
InvalidName
VmConfigFault
DuplicateName
TaskInProgress
FileFault
InvalidState
ConcurrentAccess
InvalidDatastore
InsufficientResourcesFault
RuntimeFault
RemoteException

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!

Throws:
InvalidName
VmConfigFault
DuplicateName
TaskInProgress
FileFault
InvalidState
ConcurrentAccess
InvalidDatastore
InsufficientResourcesFault
RuntimeFault
RemoteException

getAllVirtualDevices

public VirtualDevice[] getAllVirtualDevices()
Get all the virtual devices of a virtual machine

Returns:
VirtualDevice[]

getVirtualDevicesOfType

public <T extends VirtualDevice> List<T> getVirtualDevicesOfType(Class<T> clazz)

getDeviceByBackingFileName

public VirtualDevice getDeviceByBackingFileName(String name)


Copyright © 2011-2012. All Rights Reserved.