def test_process_fileset_quota_no_store(self, mock_django_pusher): storage_name = VSC_DATA filesystem = 'vulpixdata' fileset = 'gvo00002' quota = QuotaFileset(storage_name, filesystem, fileset) quota.update('gvo00002', used=1230, soft=456, hard=789, doubt=0, expired=(False, None), timestamp=None) storage = mock.MagicMock() filesets = { filesystem: { fileset: { 'path': '/my_path', 'filesetName': fileset, } } } gpfs = mock.MagicMock() gpfs.list_filesets.return_value = filesets client = mock.MagicMock() quota_map = {fileset: quota} tools.process_fileset_quota( storage, gpfs, storage_name, filesystem, quota_map, client, dry_run=False, institute=GENT ) mock_django_pusher.assert_called_once_with('gvo00002', 'gvo00002', quota.quota_map['gvo00002'], shared=False)
def get_mmrepquota_maps(quota_map, storage, filesystem, filesets, replication_factor=1): """Obtain the quota information. This function uses vsc.filesystem.gpfs.GpfsOperations to obtain quota information for all filesystems known to the storage. The returned dictionaries contain all information on a per user and per fileset basis for the given filesystem. Users with multiple quota settings across different filesets are processed correctly. Returns { "USR": user dictionary, "FILESET": fileset dictionary}. @type replication_factor: int, describing the number of copies the FS holds for each file @type metadata_replication_factor: int, describing the number of copies the FS metadata holds for each file """ user_map = {} fs_map = {} timestamp = int(time.time()) logging.info("ordering USR quota for storage %s", storage) # Iterate over a list of named tuples -- GpfsQuota for (user, gpfs_quota) in quota_map['USR'].items(): user_quota = user_map.get(user, QuotaUser(storage, filesystem, user)) user_map[user] = _update_quota_entity( filesets, user_quota, filesystem, gpfs_quota, timestamp, replication_factor ) logging.info("ordering FILESET quota for storage %s", storage) # Iterate over a list of named tuples -- GpfsQuota for (fileset, gpfs_quota) in quota_map['FILESET'].items(): fileset_quota = fs_map.get(fileset, QuotaFileset(storage, filesystem, fileset)) fs_map[fileset] = _update_quota_entity( filesets, fileset_quota, filesystem, gpfs_quota, timestamp, replication_factor ) return {"USR": user_map, "FILESET": fs_map}