The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Quota::OO - Perl extension for Object Oriented Quota Management and reporting

SYNOPSIS

    use Quota::OO;
    my $quo = Quota::OO->new();

    my $mount_entities_hr = $quo->get_mntent_hash();

DESCRIPTION

Object oriented interface to the Quota module. It has a method for each function that Quota has. All take the same arguments and return the same results, except for sync() (see below).

In addition it has new methods to make it easier to obtain certain info and do certain tasks. See the METHODS section below.

METHODS

new()

Takes either no arguments or a single argument that is a hashref with the following optional keys:

    'dev' => DEV,
    'uid' => UID,
    'gid' => GID,

Each takes the same value and has the same defaults as the corresponding set_ method.

$quo->get_* and $quo->set_* methods

$quo->get_dev(), $quo->get_uid(), and $quo->get_gid() each return their respective part of the current object.

$quo->set_dev( $dev )

Sets the current device to given argument. Sets it to the $quo->getqcarg() of your argument.

$quo->set_uid( $uid )

Sets current UID to given argument. If not numeric defaults to effective UID of the script.

$quo->set_gid( $gid )

Sets current GID to given argument. If not numeric defaults to the GID of the UID.

$quo->get_query($id, $id_is_grp)

Returns an array (in list context) or array ref (in scalar context).

Defaults to $id being the UID and not GID, returns same array as Quota::query()

$quo->get_uid_query($uid)

Same as get_query() but force user context

$quo->get_gid_query($gid)

Same as get_query() but force group context

$quo->get_query_hash($id, $id_is_grp)

Same as get_query but returns a hash (in list context) or a hashref (in scalar context) with the following keys:

    'block_current' 
    'block_soft' 
    'block_hard'
    'block_timelimit'
    'inode_current' 
    'inode_soft'
    'inode_hard'
    'inode_timelimit'

$quo->get_uid_query_hash($uid)

Same as get_query_hash() but force user context

$quo->get_gid_query_hash($gid)

Same as get_query_hash() but force group context

$quo->set_quota_limit()

Takes a single argument, a hashref with the following keys:

    'dev'          # defaults to object's device
    'id'           # defaults to object's UID
    'block_soft'   
    'block_hard'
    'inode_soft' 
    'inode_hard'
    'time_limit'   # defaults to 0
    'id_is_gid'    # defaults to 0

$quo->set_uid_quota_limit()

Same as $quo->set_quota_limit() except force user context.

$quo->set_gid_quota_limit()

Same as $quo->set_quota_limit() except force group context.

$quo->sync()

sync device given as argument or the object's device if no arguments

$quo->sync_all()

Same as Quota::sync with no arguments.

$quo->get_mntent_hash()

Returns a hash (in list context) or a hashref (in scalar context) where each key is a device and its value is a hashref with the keys 'path', 'type', 'opts'.

The device key and hash keys correspond to Quota::getmntent()'s return values.

$quo->get_errstr()

Alias to $quo->errstr()

rpc*

These all have get_ and set_ methods and can be passed as keys of the hashref argument to new() and the methods below.

The corresponding location in the original calls are noted in the comments after each one, the method name and its location in the argument list

    'rpc_host'    # rpcquery(0), rpcauth(2)
    'rpc_path'    # rpcquery(1)
    'rpc_port'    # rpcpeer(0)
    'rpc_uid'     # rpcquery(2), rpcauth(0)
    'rpc_gid'     # rpcauth(1)
    'rpc_use_tcp' # rpcpeer(1)
    'rpc_timeout' # rpcpeer(2)

$quo->get_rpc_query()

Can take a single hashref with any or all of the keys described above.

Returns the same array as $quo->get_query();

$quo->get_rpc_query_hash()

Can take a single hashref with any or all of the keys described above.

Returns the same hash[ref] as $quo->get_query_hash();

SEE ALSO

All heavy lifting is done by:

Quota

TODO

test test test :) Feedback always welcome, we want useful stuff afterall right?

AUTHOR

Daniel Muey, http://drmuey.com/cpan_contact.pl

COPYRIGHT AND LICENSE

Copyright (C) 2006 by Daniel Muey

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.