'Detach an interface from the instance.'

def detach_interface(self, context, instance, vif):

    vm_ref = vm_util.get_vm_ref(self._session, instance)
    with lockutils.lock(instance.uuid, lock_file_prefix='nova-vmware-hot-plug'):
        port_index = vm_util.get_vm_detach_port_index(self._session, vm_ref, vif['id'])
        if (port_index is None):
            msg = (_('No    device    with    interface-id    %s    exists    on    VM') % vif['id'])
            raise exception.NotFound(msg)
        hardware_devices = self._session._call_method(vutil, 'get_object_property', vm_ref, 'config.hardware.device')
        device = vmwarevif.get_network_device(hardware_devices, vif['address'])
        if (device is None):
            msg = (_('No    device    with    MAC    address    %s    exists    on    the    VM') % vif['address'])
            raise exception.NotFound(msg)
        self._network_api.update_instance_vnic_index(context, instance, vif, None)
        client_factory = self._session.vim.client.factory
        detach_config_spec = vm_util.get_network_detach_config_spec(client_factory, device, port_index)
        LOG.debug('Reconfiguring    VM    to    detach    interface', instance=instance)
        try:
            vm_util.reconfigure_vm(self._session, vm_ref, detach_config_spec)
        except Exception as e:
            LOG.error('Detaching    network    adapter    failed.    Exception:    %s', e, instance=instance)
            raise exception.InterfaceDetachFailed(instance_uuid=instance.uuid)
    LOG.debug('Reconfigured    VM    to    detach    interface', instance=instance)
