code: public void createHardDisk(int diskSizeMB, VirtualDiskType type, VirtualDiskMode mode) throws Exception {
          VirtualMachineConfigSpec vmConfigSpec = new VirtualMachineConfigSpec();
          VirtualDeviceConfigSpec diskSpec = new VirtualDeviceConfigSpec();
  
          VirtualDiskFlatVer2BackingInfo diskfileBacking = new VirtualDiskFlatVer2BackingInfo();
          diskfileBacking.setFileName("");
          diskfileBacking.setDiskMode(mode.toString());
          diskfileBacking.setThinProvisioned(type == VirtualDiskType.thin);
  
          VirtualSCSIController scsiController = getFirstAvailableController(VirtualSCSIController.class);
          int unitNumber = getFirstFreeUnitNumberForController(scsiController);
          VirtualDisk disk = new VirtualDisk();
          disk.setControllerKey(scsiController.key);
          disk.setUnitNumber(unitNumber);
          disk.setBacking(diskfileBacking);
          disk.setCapacityInKB(1024 * diskSizeMB);
          disk.setKey(-1);
  
          diskSpec.setOperation(VirtualDeviceConfigSpecOperation.add);
          diskSpec.setFileOperation(VirtualDeviceConfigSpecFileOperation.create);
          diskSpec.setDevice(disk);
          VirtualDeviceConfigSpec[] vdiskSpecArray = {diskSpec};
  
          vmConfigSpec.setDeviceChange(vdiskSpecArray);
          Task task = vm.reconfigVM_Task(vmConfigSpec);
  
          task.waitForTask(200, 100);
      }
docs: /*############################################################
  Hard Disk Management
  ############################################################