def METHOD_NAME(self, snapshot_plugin_dir):
    valid_extension = '.tar.gz'
    valid_files_to_delete = dict()
    try:
        for root, dirs, files in os.walk(snapshot_plugin_dir):
            for _file in files:
                if _file.endswith(valid_extension):
                    valid_files_to_delete[_file.split(".")[0]] = os.path.join(root, _file)
        valid_files_to_delete_sorted = OrderedDict(sorted(valid_files_to_delete.items(), reverse=True))
        while len(valid_files_to_delete_sorted) > _NO_OF_FILES_TO_RETAIN:
            _file, _path = valid_files_to_delete_sorted.popitem()
            _LOGGER.warning("Removing plugin snapshot file %s.", _path)
            os.remove(_path)
    except OSError as ex:
        _LOGGER.error(ex, "ERROR while deleting plugin file.")