[vhffs-dev] [svn] commit: r269 - in /trunk: vhffs-api/src/Vhffs/Services/ vhffs-panel/admin/repository/ vhffs-robots/src/

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Author: gradator
Date: Tue Oct 31 06:49:06 2006
New Revision: 269

Log:
Now using perl quota module to update used quota in vhffs db, added support to update the quota used by repositories in vhffs db.


Added:
    trunk/vhffs-robots/src/update_quota_used_repository.pl   (with props)
Modified:
    trunk/vhffs-api/src/Vhffs/Services/Repository.pm
    trunk/vhffs-panel/admin/repository/edit.pl
    trunk/vhffs-panel/admin/repository/show.pl
    trunk/vhffs-robots/src/fix_quota.pl
    trunk/vhffs-robots/src/fix_quota_repository.pl
    trunk/vhffs-robots/src/update_quota_used.pl

Modified: trunk/vhffs-api/src/Vhffs/Services/Repository.pm
==============================================================================
--- trunk/vhffs-api/src/Vhffs/Services/Repository.pm (original)
+++ trunk/vhffs-api/src/Vhffs/Services/Repository.pm Tue Oct 31 06:49:06 2006
@@ -163,7 +163,7 @@
 {
 	my $self = shift;
 
-	my $query = "UPDATE vhffs_repository SET name='".$self->{'name'}."', quota='".$self->{'quota'}."' WHERE repository_id='".$self->{'repository_id'}."'";
+	my $query = "UPDATE vhffs_repository SET name='".$self->{'name'}."', quota='".$self->{'quota'}."', quota_used='".$self->{'quota_used'}."' WHERE repository_id='".$self->{'repository_id'}."'";
 
 	my $request = $self->{'db'}->{'DB_WRITE'}->prepare($query);
 	$request->execute or return -1;
@@ -254,13 +254,13 @@
 	$self->{'quota'} = $value;
 }
 
-sub get_quotaused
+sub get_quota_used
 {
 	my $self = shift;
 	return $self->{'quota_used'};
 }
 
-sub set_quotaused
+sub set_quota_used
 {
 	my ($self , $value) = @_;	
 	$self->{'quota_used'} = $value;

Modified: trunk/vhffs-panel/admin/repository/edit.pl
==============================================================================
--- trunk/vhffs-panel/admin/repository/edit.pl (original)
+++ trunk/vhffs-panel/admin/repository/edit.pl Tue Oct 31 06:49:06 2006
@@ -106,7 +106,7 @@
 	$template->param( VALUE_GROUP => Vhffs::Group::get_name_by_gid( $vhffs , $object->get_ownergid ));
 	$template->param( VALUE_OWNER => Vhffs::User::get_name_by_uid( $vhffs , $object->get_owneruid ));
 	$template->param( VALUE_QUOTA => $object->get_quota);
-	$template->param( VALUE_QUOTAUSED => $object->get_quotaused);
+	$template->param( VALUE_QUOTAUSED => $object->get_quota_used);
 
 	my $oid = $object->{'object_id'};
 	$template->param( VALUE_HISTORY => "/history.pl?OID=$oid" );

Modified: trunk/vhffs-panel/admin/repository/show.pl
==============================================================================
--- trunk/vhffs-panel/admin/repository/show.pl (original)
+++ trunk/vhffs-panel/admin/repository/show.pl Tue Oct 31 06:49:06 2006
@@ -105,7 +105,7 @@
 	$template->param( VALUE_OWNER => Vhffs::User::get_name_by_uid( $vhffs , $object->get_owneruid ));
 	$template->param( VALUE_STATUS => Vhffs::Functions::status_string_from_status_id ($object->get_status) );
 	$template->param( VALUE_QUOTA => $object->get_quota);
-	$template->param( VALUE_QUOTAUSED => $object->get_quotaused);
+	$template->param( VALUE_QUOTAUSED => $object->get_quota_used);
 
 	my $oid = $object->{'object_id'};
 	$template->param( VALUE_HISTORY => "/history.pl?OID=$oid" );

Modified: trunk/vhffs-robots/src/fix_quota.pl
==============================================================================
--- trunk/vhffs-robots/src/fix_quota.pl (original)
+++ trunk/vhffs-robots/src/fix_quota.pl Tue Oct 31 06:49:06 2006
@@ -50,7 +50,6 @@
 my $user;
 my $users;
 my $inodes;
-my $cmd;
 my $dev = Quota::getqcarg($vhffs->get_config->get_datadir);
 
 foreach $group ( @{$groups} )

Modified: trunk/vhffs-robots/src/fix_quota_repository.pl
==============================================================================
--- trunk/vhffs-robots/src/fix_quota_repository.pl (original)
+++ trunk/vhffs-robots/src/fix_quota_repository.pl Tue Oct 31 06:49:06 2006
@@ -49,7 +49,6 @@
 my $quota;
 my $blocks;
 my $inodes;
-my $cmd;
 my $repos;
 my $repo;
 my $users;

Modified: trunk/vhffs-robots/src/update_quota_used.pl
==============================================================================
--- trunk/vhffs-robots/src/update_quota_used.pl (original)
+++ trunk/vhffs-robots/src/update_quota_used.pl Tue Oct 31 06:49:06 2006
@@ -34,8 +34,9 @@
 use POSIX;
 use locale;
 use Locale::gettext;
+use Quota;
 use Vhffs::Main;
-use Vhffs::Robots qw( Vhffs::Robots::vhffs_log lock unlock);
+use Vhffs::Robots;
 use Vhffs::Group;
 
 
@@ -47,59 +48,22 @@
 my $group;
 my $blocks;
 my $inodes;
-my $cmd;
-my $quota;
-my $line;
-
-#$bu is the blocks used
-my $bu;
-
-#$su is the space used
 my $su;
-
+my $dev = Quota::getqcarg($vhffs->get_config->get_datadir);
 
 foreach $group ( @{$groups} )
 {
 	if( $group->fetch > 0 )
 	{
-		$bu = undef;
-		$blocks = $group->get_quota * 1024;
-		$inodes = $group->get_quota * 1126400 / 100;
-		if( -x "/usr/bin/quota" )
+		($blocks,undef,undef,undef,$inodes,undef,undef,undef) = Quota::query($dev, $group->get_gid, 1);
+		if ( defined $blocks )
 		{
-			open( CMD , "/usr/bin/quota -g ".$group->get_gid."  |" );
-
-			while( $line =  <CMD> )
+			$su = ($blocks+1024-($blocks%1024))/1024;
+			$group->set_quota_used( $su );
+			if( $group->commit > 0 )
 			{
-		        	if( $line =~ /^\s+.+\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d*)/ )
-		        	{
-		                	($bu) = ( $line =~ /^\s+.+\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d*)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d*)/ );
-			        }
+				Vhffs::Robots::vhffs_log( sprintf( "Update quota used for group %s set %s" , $group->get_groupname , $su ) );
 			}
-			close CMD;	
-
-			if( defined( $bu ) && ( $bu > 0 ) )
-			{
-				$su = $bu * 1024;
-				$su /= 1024;
-				$su /= 1024;
-
-				if( $su =~ /\./ )
-				{
-					( $su ) = ( $su =~ /(\d+)\./ );
-				}
-				$group->set_quota_used( $su );
-
-				if( $group->commit > 0 )
-				{
-					Vhffs::Robots::vhffs_log( sprintf( "Update quota used for group %s set %s" , $group->get_groupname , $su ) );
-					Vhffs::Robots::vhffs_log( sprintf( "Update quota used for group %s " , $group->get_groupname ) );
-				}
-			}
-		}
-		else
-		{
-			Vhffs::Robots::vhffs_log( "Error, quota command not found" );
 		}
 	}
 }




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/