def snapshot_factory(request):
    """
    Snapshot factory. Calling this fixture creates a volume snapshot from the
    specified PVC

    """
    instances = []

    def factory(
        pvc_obj,
        wait=True,
        snapshot_name=None
    ):
        """
        Args:
            pvc_obj (PVC): PVC object from which snapshot has to be created
            wait (bool): True to wait for snapshot to be ready, False otherwise
            snapshot_name (str): Name to be provided for snapshot

        Returns:
            OCS: OCS instance of kind VolumeSnapshot

        """
        snap_obj = pvc_obj.create_snapshot(snapshot_name=snapshot_name, wait=wait)
        return snap_obj

    def finalizer():
        """
        Delete the snapshots

        """
        for instance in instances:
            if not instance.is_deleted:
                instance.delete()
                instance.ocp.wait_for_delete(instance.name)

    request.addfinalizer(finalizer)
    return factory