def del_nic(si, vm, nic_number):
 nic_prefix_label = 'Network adapter '
 nic_label = (nic_prefix_label + str(nic_number))
 virtual_nic_device = None
 for dev in vm.config.hardware.device:
  if (isinstance(dev, vim.vm.device.VirtualEthernetCard) and (dev.deviceInfo.label == nic_label)):
   virtual_nic_device = dev
 if (not virtual_nic_device):
  raise RuntimeError('Virtual {} could not be found.'.format(nic_label))
 virtual_nic_spec = vim.vm.device.VirtualDeviceSpec()
 virtual_nic_spec.operation = vim.vm.device.VirtualDeviceSpec.Operation.remove
 virtual_nic_spec.device = virtual_nic_device
 spec = vim.vm.ConfigSpec()
 spec.deviceChange = [virtual_nic_spec]
 task = vm.ReconfigVM_Task(spec=spec)
 tasks.wait_for_tasks(si, [task])
 return True

def del_nic ( si , vm , nic_number ) : nic_prefix_label = 'Network adapter ' nic_label = ( nic_prefix_label + str ( nic_number ) ) virtual_nic_device = None for dev in vm . config . hardware . device : if ( isinstance ( dev , vim . vm . device . VirtualEthernetCard ) and ( dev . deviceInfo . label == nic_label ) ) : virtual_nic_device = dev if ( not virtual_nic_device ) : raise RuntimeError ( 'Virtual {} could not be found.' . format ( nic_label ) ) virtual_nic_spec = vim . vm . device . VirtualDeviceSpec ( ) virtual_nic_spec . operation = vim . vm . device . VirtualDeviceSpec . Operation . remove virtual_nic_spec . device = virtual_nic_device spec = vim . vm . ConfigSpec ( ) spec . deviceChange = [ virtual_nic_spec ] task = vm . ReconfigVM_Task ( spec = spec ) tasks . wait_for_tasks ( si , [ task ] ) return True
deletes virtual nic based on nic number .