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. For most file systems this usage is determined using df command line utility. Disk usage for the ihome file system is fetched from a JSON file generated by an upstream cron job.

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

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: AbstractFilesystemUsage

Disk 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 BeegfsUsage(name: str, size_used: int, size_limit: int, chunk_used: str, chunk_limit: str)

Bases: AbstractFilesystemUsage

Disk storage quota for a BeeGFS file system

chunk_used
chunk_limit
_verbose_string() str
classmethod from_group(name: str, group: str) BeegfsUsage | None

Return a quota object for a given group name

Parameters:
  • name – Name of the file system (e.g., zfs, ix, home)

  • group – The group to 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, files: int, physical: int)

Bases: AbstractFilesystemUsage

Disk storage quota for the ihome file system

files
physical
_verbose_string() str
classmethod from_uid(name: str, uid: int) IhomeUsage | None

Return a quota object for a given user id

Parameters:
  • name – Name of the file system (e.g., zfs, ix, home)

  • uid – The ID of the user

Returns:

An instance of the parent class or None if the allocation does not exist

class CrcQuota

Bases: apps.utils.cli.BaseParser

Display a user’s disk quota.

static get_user_info(username: str | None = None) Tuple[str, int, str, int]

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, and group ID

static get_group_quotas(group: str) Tuple[GenericUsage]

Return quota information for the given group

Parameters:

group – The name of the group

Returns:

A tuple of Quota objects

app_logic(args: argparse.Namespace) None

Logic to evaluate when executing the application

Parameters:

args – Parsed command line arguments