hsarback/src/de/hsadmin/hostsharing/QuotaLimit.java | ●●●●● patch | view | raw | blame | history | |
hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java | ●●●●● patch | view | raw | blame | history | |
hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java | ●●●●● patch | view | raw | blame | history |
hsarback/src/de/hsadmin/hostsharing/QuotaLimit.java
New 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; } hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
@@ -16,6 +16,7 @@ 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 @@ 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 + " " hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java
@@ -7,6 +7,7 @@ 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 @@ -15,7 +16,7 @@ * @author mi */ public class UnixUserProcessorFactory implements EntityProcessorFactory { /** * @return a Processor which creates a new UNIX user account */ @@ -73,25 +74,29 @@ 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`")); }