@@ -0,0 +1,2013 @@
+package com.vmware.vim25.mo.samples.vm;%0A%0Aimport com.vmware.vim25.VirtualDevice;%0Aimport com.vmware.vim25.mo.Folder;%0Aimport com.vmware.vim25.mo.InventoryNavigator;%0Aimport com.vmware.vim25.mo.ServiceInstance;%0Aimport com.vmware.vim25.mo.Task;%0Aimport com.vmware.vim25.mo.VirtualMachine;%0Aimport com.vmware.vim25.mo.samples.SampleUtil;%0Aimport com.vmware.vim25.mox.VirtualMachineDeviceManager;%0A%0Apublic class VmAddCdDriveFromIso %7B%0A%0A   public static void main(String%5B%5D args) throws Exception %7B%0A      ServiceInstance si = SampleUtil.createServiceInstance();%0A%0A      String vmname = %22test_vm%22;%0A      Folder rootFolder = si.getRootFolder();%0A      VirtualMachine vm =%0A            (VirtualMachine) new InventoryNavigator(rootFolder)%0A                  .searchManagedEntity(%22VirtualMachine%22, vmname);%0A%0A      if (vm == null) %7B%0A         System.out.println(%22No VM %22 + vmname + %22 found%22);%0A         si.getServerConnection().logout();%0A         return;%0A      %7D%0A%0A      // method to mount a datastore iso to cd drive%0A      VirtualMachineDeviceManager vmdm = new VirtualMachineDeviceManager(vm);%0A      String isoPath = %22%5BDatastore-154-2%5D iso/ubuntu-12.04.4-desktop-amd64.iso%22;%0A      boolean startConnected = true;%0A      Task task = vmdm.addCdDriveFromIso(isoPath, startConnected);%0A%0A      String result = task.waitForMe();%0A      if (result == Task.SUCCESS) %7B%0A         System.out.println(%22ISO is mounted to cd drive successfully.%22);%0A      %7D else %7B%0A         System.out.println(%22Failed to mount the ISO to cd drive.%22);%0A         si.getServerConnection().logout();%0A         System.exit(1);%0A      %7D%0A%0A      // method to remove the mounted cd drive%0A      VirtualDevice cdrom = vmdm.getDeviceByBackingFileName(isoPath);%0A      vmdm.removeDevice(cdrom, false);%0A%0A      result = task.waitForMe();%0A      if (result == Task.SUCCESS) %7B%0A         System.out.println(%22The mounted cd drive is removed successfully.%22);%0A      %7D else %7B%0A         System.out.println(%22Failed to remove the mounted cd drive.%22);%0A      %7D%0A%0A      si.getServerConnection().logout();%0A   %7D%0A%0A%7D%0A

Add the sample code for mounting a datastore iso