apps.crc_quota
Command line utility for checking a user’s disk usage.
This application prints a user’s disk usage on multiple CRC file systems.
Disk usage is determined using the df command line utility, which reports
quota limits as the filesystem size when quotas are set on VAST.
The file system paths (and types) are hard coded in this application.
To modify what file systems are examined by the application, see the
CrcQuota.app_logic method.
Module Contents
- NO_QUOTA_MSG = 'No Quota Found, Please contact the CRCD Team to fix this!'
- class AbstractFilesystemUsage(name: str, size_used: int, size_limit: int)
Base class for building object-oriented representations of file system quotas.
- name
- size_used
- size_limit
- to_string(verbose: bool = False) str
Return a string representation of the quota usage
- Parameters:
verbose – Return a more detailed representation
- Returns:
Human readable quota usage information
- _verbose_string() str
- _short_string() str
- static convert_size(size: int) str
Convert the given number of bytes to a human-readable string
- Parameters:
size – An integer number of bytes
- Returns:
A string representation of the given size with units
- class GenericUsage(name: str, size_used: int, size_limit: int)
Bases:
AbstractFilesystemUsageDisk storage quota for a generic file system
- classmethod from_path(name: str, path: str) GenericUsage | None
Return a quota object for a given file path
- Parameters:
name – Name of the file system (e.g., zfs, ix, home)
path – The file path for create a quota for
- Returns:
An instance of the parent class or None if the allocation does not exist
- class IhomeUsage(name: str, size_used: int, size_limit: int, has_quota: bool = True)
Bases:
AbstractFilesystemUsageDisk storage quota for the ihome file system on VAST.
- has_quota = True
- _verbose_string() str
- _short_string() str
- classmethod from_path(name: str, path: str) IhomeUsage | None
Return a quota object for a given file path using os.statvfs.
VAST reports the quota limit as the filesystem size when a quota is set. If no quota is set, it reports the full filesystem size.
To detect if a quota is set, we compare the reported size of the user’s directory against the mount point. If they are within 1% of each other, we assume no quota is configured.
- Parameters:
name – Name of the file system (e.g., ihome)
path – The file path to check quota for
- Returns:
An instance of IhomeUsage or None if the path does not exist
- class VastUsage(name: str, size_used: int, size_limit: int, has_quota: bool = True)
Bases:
AbstractFilesystemUsageDisk storage quota for VAST project storage (/vast).
- has_quota = True
- _verbose_string() str
- _short_string() str
- classmethod from_path(name: str, path: str) VastUsage | None
Return a quota object for a given file path using os.statvfs.
VAST reports the quota limit as the filesystem size when a quota is set. If no quota is set, it reports the full filesystem size.
- Parameters:
name – Name of the file system (e.g., vast)
path – The file path to check quota for
- Returns:
An instance of VastUsage or None if the path does not exist
- class CrcQuota
Bases:
apps.utils.cli.BaseParserDisplay a user’s disk quota.
- static get_user_info(username: str | None = None) Tuple[str, int, str, int, str]
Return system IDs for the current user
- Parameters:
username – The name of the user to get IDs for (defaults to current user)
- Returns:
Tuple with the user’s name, user ID, group name, group ID, and home directory
- static get_group_quotas(group: str) Tuple[GenericUsage, Ellipsis]
Return quota information for the given group
- Parameters:
group – The name of the group
- Returns:
A tuple of
Quotaobjects
- app_logic(args: argparse.Namespace) None
Logic to evaluate when executing the application
- Parameters:
args – Parsed command line arguments