def delete_virtual_disk(si, vm_obj, disk_number):
 hdd_prefix_label = 'Hard disk '
 hdd_label = (hdd_prefix_label + str(disk_number))
 virtual_hdd_device = None
 for dev in vm_obj.config.hardware.device:
  if (isinstance(dev, vim.vm.device.VirtualDisk) and (dev.deviceInfo.label == hdd_label)):
   virtual_hdd_device = dev
 if (not virtual_hdd_device):
  raise RuntimeError('Virtual {} could not be found.'.format(virtual_hdd_device))
 virtual_hdd_spec = vim.vm.device.VirtualDeviceSpec()
 virtual_hdd_spec.operation = vim.vm.device.VirtualDeviceSpec.Operation.remove
 virtual_hdd_spec.device = virtual_hdd_device
 spec = vim.vm.ConfigSpec()
 spec.deviceChange = [virtual_hdd_spec]
 task = vm_obj.ReconfigVM_Task(spec=spec)
 tasks.wait_for_tasks(si, [task])
 return True

def delete_virtual_disk ( si , vm_obj , disk_number ) : hdd_prefix_label = 'Hard disk ' hdd_label = ( hdd_prefix_label + str ( disk_number ) ) virtual_hdd_device = None for dev in vm_obj . config . hardware . device : if ( isinstance ( dev , vim . vm . device . VirtualDisk ) and ( dev . deviceInfo . label == hdd_label ) ) : virtual_hdd_device = dev if ( not virtual_hdd_device ) : raise RuntimeError ( 'Virtual {} could not be found.' . format ( virtual_hdd_device ) ) virtual_hdd_spec = vim . vm . device . VirtualDeviceSpec ( ) virtual_hdd_spec . operation = vim . vm . device . VirtualDeviceSpec . Operation . remove virtual_hdd_spec . device = virtual_hdd_device spec = vim . vm . ConfigSpec ( ) spec . deviceChange = [ virtual_hdd_spec ] task = vm_obj . ReconfigVM_Task ( spec = spec ) tasks . wait_for_tasks ( si , [ task ] ) return True
deletes virtual disk based on disk number .