'Attach the snapshot.'

def _attach_snapshot(self, ctxt, snapshot, properties):

    model_update = None
    try:
        LOG.debug('Snapshot    %s:    creating    export.', snapshot.id)
        model_update = self.create_export_snapshot(ctxt, snapshot, properties)
        if model_update:
            snapshot.provider_location = model_update.get('provider_location', None)
            snapshot.provider_auth = model_update.get('provider_auth', None)
            snapshot.save()
    except exception.CinderException as ex:
        if model_update:
            LOG.exception('Failed    updating    model    of    snapshot    %(snapshot_id)s    with    driver    provided    model    %(model)s.', {'snapshot_id': snapshot.id, 'model': model_update})
            raise exception.ExportFailure(reason=ex)
    try:
        conn = self.initialize_connection_snapshot(snapshot, properties)
    except Exception as err:
        try:
            err_msg = (_('Unable    to    fetch    connection    information    from    backend:    %(err)s') % {'err': six.text_type(err)})
            LOG.error(err_msg)
            LOG.debug('Cleaning    up    failed    connect    initialization.')
            self.remove_export_snapshot(ctxt, snapshot)
        except Exception as ex:
            ex_msg = (_('Error    encountered    during    cleanup    of    a    failed    attach:    %(ex)s') % {'ex': six.text_type(ex)})
            LOG.error(err_msg)
            raise exception.VolumeBackendAPIException(data=ex_msg)
        raise exception.VolumeBackendAPIException(data=err_msg)
    return conn
