Progetto

Generale

Profilo

EnQuotaModule » Cronologia » Versione 3

Amministratore Truelite, 10-06-2010 17:14

1 1 Amministratore Truelite
== Module quota ==
2
3
This is a simple wrapper for the {{{quotactl}}} system call, allowing getting and setting quota directly from python (no need to call an external program and parse its output).
4
5
It's still extremely primordial, providing limited functionality and working only with Linux quota version 2. It has been tested on Debian Etch and Lenny. As my first attempt to write a module it is also very far from elegance (and no pythonic at all). 
6
7
=== Installation ===
8
9
To install the module you need the following steps (provided you have standard development tools installed):
10
{{{
11
svn co https://labs.truelite.it/svn/cyrcus/quotamodule
12
cd quotamodule/
13
python setup.py build
14
}}}
15 3 Amministratore Truelite
then you can copy the {{{quota.so}}} module (look inside the created {{{build}}} directory) to its destination (if you want to just check it with python you can use your current working directory).
16 1 Amministratore Truelite
17
=== Use ===
18
19
The module provides the following functions (interface is preliminar, it will be probably changed in future releases):
20
21
||'''Function'''||'''Arguments'''||'''Description'''||
22
||{{{get_user_quota}}}||{{{uid}}} (integer), {{{device}}} (string)|| get user quota||
23
||{{{get_group_quota}}}||{{{gid}}} (integer), {{{device}}} (string)|| get group quota||
24
||{{{set_user_block_quota}}}||{{{uid}}} (integer), {{{device}}} (string), {{{(soft,hard)}}} *tuple of two int || set block user quota||
25
||{{{set_user_inode_quota}}}||{{{uid}}} (integer), {{{device}}} (string), {{{(soft,hard)}}} *tuple of two int || set inode user quota||
26
||{{{set_group_block_quota}}}||{{{gid}}} (integer), {{{device}}} (string), {{{(soft,hard)}}} *tuple of two int || set block group quota||
27
||{{{set_group_inode_quota}}}||{{{gid}}} (integer), {{{device}}} (string), {{{(soft,hard)}}} *tuple of two int || set inode group quota||
28
29
User or group can be only specified by numeric ID (uid or gid). The {{{device}}} string must be the device pathname for the filesystem on which we want to operate. 
30
31
When setting quotas they must be provided as a tuple of two integer values (first for soft limit, second for hard limit). They will be applied to inode/block, user/group according to the chosen function. 
32
 
33
Reading quota will give back a tuple of two dictionaries. First dictionary is for block quota data, second for inode quota data. Both dictionaries will have the same string keys according to the following table:
34
35
||'''Key'''||'''Desctiption'''||
36 2 Amministratore Truelite
||used|| integer with the actual usage of the resource (blocks or inodes number)||
37 1 Amministratore Truelite
||quota|| a two integers tuple with the current value of the quota (soft limit, hard limit) ||
38
||grace|| an integer with the time_t value of the grace expiration (if active)||
39
40
=== Error handling ===
41
42
All error in calling the {{{quotactl}}} function will raise a {{{OSError}}} exception passing the error value in {{{errno}}}.