Refactored quota handling: use of constants.
This commit is contained in:
parent
ffae738ec6
commit
86f2bb47a0
9
hsarback/src/de/hsadmin/hostsharing/QuotaLimit.java
Normal file
9
hsarback/src/de/hsadmin/hostsharing/QuotaLimit.java
Normal file
@ -0,0 +1,9 @@
|
||||
package de.hsadmin.hostsharing;
|
||||
|
||||
public class QuotaLimit {
|
||||
|
||||
public static final double USER_HARD_FACTOR = 1.50;
|
||||
public static final double GROUP_HARD_FACTOR = 1.50;
|
||||
public static final double INODE_LIMIT_FACTOR = 0.25;
|
||||
|
||||
}
|
@ -16,6 +16,7 @@ import de.hsadmin.core.qserv.VelocityProcessor;
|
||||
import de.hsadmin.core.qserv.WaitingTasksProcessor;
|
||||
import de.hsadmin.core.util.PasswordTool;
|
||||
import de.hsadmin.hostsharing.BasePacType;
|
||||
import de.hsadmin.hostsharing.QuotaLimit;
|
||||
import de.hsadmin.mods.user.UnixUser;
|
||||
|
||||
|
||||
@ -143,13 +144,13 @@ public class PacProcessorFactory implements EntityProcessorFactory {
|
||||
BaseComponent baseComponent = pacComponent.getBaseComponent();
|
||||
String feature = baseComponent.getFeature();
|
||||
if ("QUOTA".equals(feature)) {
|
||||
quota = pacComponent.getQuantity();
|
||||
quota = pacComponent.getQuantity() * 1024;
|
||||
}
|
||||
}
|
||||
int blocksSoft = quota * 1024;
|
||||
int blocksHard = quota * 1024 * 2;
|
||||
int inodesSoft = blocksSoft / 4;
|
||||
int inodesHard = blocksHard / 4;
|
||||
int blocksSoft = quota;
|
||||
int blocksHard = ((Double) (quota * QuotaLimit.GROUP_HARD_FACTOR)).intValue();
|
||||
int inodesSoft = ((Double) (quota * QuotaLimit.INODE_LIMIT_FACTOR)).intValue();
|
||||
int inodesHard = ((Double) (quota * QuotaLimit.INODE_LIMIT_FACTOR)).intValue();
|
||||
return new ShellProcessor("setquota -g " + pac.getName() + " "
|
||||
+ blocksSoft + " " + blocksHard + " "
|
||||
+ inodesSoft + " " + inodesHard + " "
|
||||
|
@ -7,6 +7,7 @@ import de.hsadmin.core.qserv.CompoundProcessor;
|
||||
import de.hsadmin.core.qserv.EntityProcessorFactory;
|
||||
import de.hsadmin.core.qserv.Processor;
|
||||
import de.hsadmin.core.qserv.ShellProcessor;
|
||||
import de.hsadmin.hostsharing.QuotaLimit;
|
||||
|
||||
/**
|
||||
* Factory class which creates Processor instances for dealing with UNIX user
|
||||
@ -73,25 +74,29 @@ public class UnixUserProcessorFactory implements EntityProcessorFactory {
|
||||
|
||||
private void appendSetQuotaProcessor(CompoundProcessor aCP, UnixUser user) {
|
||||
Integer quotaSoft = user.getQuotaSoftlimit();
|
||||
if (quotaSoft == null || quotaSoft.intValue() == 0) {
|
||||
if (quotaSoft == null) {
|
||||
quotaSoft = new Integer(0);
|
||||
} else {
|
||||
quotaSoft = quotaSoft * 1024;
|
||||
}
|
||||
if (quotaSoft.intValue() == 0) {
|
||||
aCP.appendProcessor(new ShellProcessor("setquota -u "
|
||||
+ user.getName() + " 0 0 0 0 "
|
||||
+ "`df /home/pacs/ | tail -n1 | cut -d' ' -f1`"));
|
||||
return;
|
||||
}
|
||||
Integer userSoftQuota = quotaSoft * 1024;
|
||||
Integer quotaHard = user.getQuotaHardlimit();
|
||||
if (quotaHard == null) {
|
||||
quotaHard = new Integer(0);
|
||||
}
|
||||
Integer userHardQuota = quotaHard * 1024;
|
||||
if (userHardQuota.intValue() < userSoftQuota.intValue()) {
|
||||
// set default value
|
||||
userHardQuota = ((Double) (userSoftQuota * 1.5 + 32)).intValue();
|
||||
} else {
|
||||
quotaHard = quotaHard * 1024;
|
||||
}
|
||||
if (quotaHard.intValue() < quotaSoft.intValue()) {
|
||||
quotaHard = ((Double) (quotaSoft * QuotaLimit.USER_HARD_FACTOR)).intValue();
|
||||
}
|
||||
aCP.appendProcessor(new ShellProcessor("setquota -u "
|
||||
+ user.getName() + " " + userSoftQuota + " "
|
||||
+ userHardQuota + " 0 0 "
|
||||
+ user.getName() + " " + quotaSoft + " "
|
||||
+ quotaHard + " 0 0 "
|
||||
+ "`df /home/pacs/ | tail -n1 | cut -d' ' -f1`"));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user