UserQuotaPlugin

%SHORTDESCRIPTION%

Description

This plugin provides the =| User BaseUserMapping_666 | Usage | Soft Limit | Hard Limit |
Space in GB - - -
Number of Files - - -
= variable which renders a quota report for the currently authenticated user.

The plugin calls an external web service via HTTP POST, passing the login name as a form parameter.

The web service is expected to accept:

POST http://ceph-fe01:8080/
Content-Type: application/x-www-form-urlencoded

user=<loginname>

and return JSON, for example:

{
  "user": "walteste",
  "dataset": "home-pool/home",
  "space_used_bytes": "97393759232",
  "space_quota_bytes": "0",
  "objects_used": "809026",
  "objects_quota": "0"
}

If the user is unknown, the service should return "-" for the numeric fields.

Syntax

%USERQUOTA%

There are currently no parameters.

Output

The variable expands to Foswiki table markup, for example:

| *User* | *Dataset* | *Space used (bytes)* | *Space quota (bytes)* | *Objects used* | *Objects quota* |
| walteste | home-pool/home | 97393759232 | 0 | 809026 | 0 |

If an error occurs or the lookup fails, the plugin renders a single row with "-" values.

Configuration

Use configure to set:

  • {Plugins}{UserQuotaPlugin}{ServiceURL}
    • URL of the quota service (default: http://ceph-fe01:8080/).

Make sure either LWP::UserAgent or HTTP::Tiny and JSON are installed on the Foswiki host.

Installation

  1. Copy the plugin files into place:
    • lib/Foswiki/Plugins/UserQuotaPlugin.pm
    • data/System/UserQuotaPlugin.txt
    • lib/LocalSite.cfg (updated by configure) or via manual edit.
    • lib/Foswiki/Configure/Checkers/Plugins/UserQuotaPlugin.pm (optional)
    • lib/Foswiki/Plugins/UserQuotaPlugin/Config.spec (for configure UI)

  1. Run bin/configure, go to the Extensions tab, enable UserQuotaPlugin and set the Service URL if needed.

  1. Save your changes.

Usage Example

In any topic:

---+ My quota

%USERQUOTA%

This will display a one-row table with the current user's quota information.

Bugs and Limitations

  • No caching is implemented; each expansion calls the web service.
  • If neither LWP::UserAgent nor HTTP::Tiny is available, the plugin will log a warning and output "-" values.

Author and License

  • Author: Your Name
  • License: GPL (same as Foswiki)
Topic revision: r1 - 25 Feb 643670, ProjectContributor
This site is powered by FoswikiCopyright © by the contributing authors. All material on this site is the property of the contributing authors.
Ideas, requests, problems regarding Foswiki? Send feedback