'Attach an interface to the instance.'

def attach_interface(self, context, instance, image_meta, vif):

    vif_model = image_meta.properties.get('hw_vif_model', constants.DEFAULT_VIF_MODEL)
    vif_model = vm_util.convert_vif_model(vif_model)
    vif_info = vmwarevif.get_vif_dict(self._session, self._cluster, vif_model, utils.is_neutron(), 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_attach_port_index(self._session, vm_ref)
        client_factory = self._session.vim.client.factory
        extra_specs = self._get_extra_specs(instance.flavor)
        attach_config_spec = vm_util.get_network_attach_config_spec(client_factory, vif_info, port_index, extra_specs.vif_limits)
        LOG.debug('Reconfiguring    VM    to    attach    interface', instance=instance)
        try:
            vm_util.reconfigure_vm(self._session, vm_ref, attach_config_spec)
        except Exception as e:
            LOG.error('Attaching    network    adapter    failed.    Exception:    %s', e, instance=instance)
            raise exception.InterfaceAttachFailed(instance_uuid=instance.uuid)
        self._network_api.update_instance_vnic_index(context, instance, vif, port_index)
    LOG.debug('Reconfigured    VM    to    attach    interface', instance=instance)
