diff --git a/hsarback/src/de/hsadmin/hostsharing/QuotaLimit.java b/hsarback/src/de/hsadmin/hostsharing/QuotaLimit.java new file mode 100644 index 0000000..f11b1ad --- /dev/null +++ b/hsarback/src/de/hsadmin/hostsharing/QuotaLimit.java @@ -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; + +} diff --git a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java index 9839a30..223fc5a 100644 --- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java @@ -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 + " " diff --git a/hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java b/hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java index 3cd5d91..6621287 100644 --- a/hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/user/UnixUserProcessorFactory.java @@ -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 @@ -15,7 +16,7 @@ import de.hsadmin.core.qserv.ShellProcessor; * @author mi */ public class UnixUserProcessorFactory implements EntityProcessorFactory { - + /** * @return a Processor which creates a new UNIX user account */ @@ -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`")); }