Progetto

Generale

Profilo

EnQuotaModule » Cronologia » Versione 5

Versione 4 (Amministratore Truelite, 10-06-2010 17:14) → Versione 5/7 (Simone Piccardi, 22-12-2010 19:10)

h1. 
 h2. Module quota 

 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).  

 


 <pre> 

 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).  

 h2.  


 h3. Installation 

 


 To install the module you need the following steps (provided you have standard development tools installed): 

 
 <pre> 
 
 svn co https://labs.truelite.it/svn/cyrcus/quotamodule 
 cd quotamodule/ 
 python setup.py build 
 </pre> 

 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).  

 h2. 
 <pre> 


 h3. Use 

 


 The module provides the following functions (interface is preliminar, it will be probably changed in future releases): 

 |_.Function |_.Arguments |._Description| ||*Function*||*Arguments*||*Description*|| 
 |@get_user_quota@|@uid@ (integer), @device@ (string)| get user quota| 
 |@get_group_quota@|@gid@ (integer), @device@ (string)| get group quota| 
 |@set_user_block_quota@|@uid@ (integer), @device@ (string), @(soft,hard)@ *tuple of two int | set block user quota| 
 |@set_user_inode_quota@|@uid@ (integer), @device@ (string), @(soft,hard)@ *tuple of two int | set inode user quota| 
 |@set_group_block_quota@|@gid@ (integer), @device@ (string), @(soft,hard)@ *tuple of two int | set block group quota| 
 |@set_group_inode_quota@|@gid@ (integer), @device@ (string), @(soft,hard)@ *tuple of two int | set inode group quota| 

 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.  

 <pre> 
 <pre> 
 <pre> 
 <pre> 
 <pre> 
 <pre> 

 <pre> 

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

 |_.Key|_.Desctiption| ||*Key*||*Desctiption*|| 
 |used| ||used|| integer with the actual usage of the resource (blocks or inodes number)|| 
 |quota| ||quota|| a two integers tuple with the current value of the quota (soft limit, hard limit) || 
 |grace| ||grace|| an integer with the @time_t@ time_t value of the grace expiration (if active)|| 


 h2. 


 h3. Error handling 

 All error in calling the @quotactl@ function will raise an @OSError@ exception passing the error value in @errno@. 


 <pre>