Release 2.0.1

This commit is contained in:
Peter Hormanns 2011-08-30 13:41:19 +00:00
parent 8b2e746fa9
commit 75b244caea
3 changed files with 38 additions and 17 deletions

View File

@ -42,7 +42,8 @@ public class PacProcessorFactory implements EntityProcessorFactory {
createIPTablesProc(), createIPTablesProc(),
createSudouersProc(hiveValues, pacValuesList), createSudouersProc(hiveValues, pacValuesList),
createProftpdConfProc(hiveValues, pacValuesList), createProftpdConfProc(hiveValues, pacValuesList),
createMakePacDirectoryStructure(unixUser)); createMakePacDirectoryStructure(unixUser),
createIfUp(pacName));
WaitingTasksProcessor secProcessor = new WaitingTasksProcessor(priProcessor); WaitingTasksProcessor secProcessor = new WaitingTasksProcessor(priProcessor);
secProcessor.appendProcessor(pac.getHiveName(), createSendEMailProc(pacName, customerEMail, emailVars), "send email to customer"); secProcessor.appendProcessor(pac.getHiveName(), createSendEMailProc(pacName, customerEMail, emailVars), "send email to customer");
return secProcessor; return secProcessor;
@ -51,7 +52,8 @@ public class PacProcessorFactory implements EntityProcessorFactory {
@Override @Override
public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity) public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity)
throws ProcessorException { throws ProcessorException {
throw new ProcessorException("pac.update not implemented"); Pac pac = (Pac) entity;
return createSetQuotaProc(pac);
} }
@Override @Override
@ -61,6 +63,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
Map<String, String> hiveValues = fillHiveValues(hive); Map<String, String> hiveValues = fillHiveValues(hive);
List<Map<String, String>> pacValuesList = fillPacValuesList(hive, pac); List<Map<String, String>> pacValuesList = fillPacValuesList(hive, pac);
WaitingTasksProcessor waitingProcessor = new WaitingTasksProcessor(new CompoundProcessor( WaitingTasksProcessor waitingProcessor = new WaitingTasksProcessor(new CompoundProcessor(
createIfDown(pac.getName()),
createEtcHostsProc(hiveValues, pacValuesList), createEtcHostsProc(hiveValues, pacValuesList),
createNetworkInterfacesProc(hiveValues, pacValuesList), createNetworkInterfacesProc(hiveValues, pacValuesList),
createSudouersProc(hiveValues, pacValuesList), createSudouersProc(hiveValues, pacValuesList),
@ -130,18 +133,20 @@ public class PacProcessorFactory implements EntityProcessorFactory {
} }
private Processor createMakePacDirectoryStructure(UnixUser unixUser) { private Processor createMakePacDirectoryStructure(UnixUser unixUser) {
return new ShellProcessor("chmod 711 " + unixUser.getHomedir() + " && " + String homedir = unixUser.getHomedir();
"su -l " + unixUser.getName() + " -s \"/bin/bash\" -c \"mkdir -p " + String username = unixUser.getName();
unixUser.getHomedir() + "/doms " + return new ShellProcessor("chmod 711 " + homedir + " && " +
unixUser.getHomedir() + "/etc " + "su -l " + username + " -s \"/bin/bash\" -c \"mkdir -p " +
unixUser.getHomedir() + "/users " + homedir + "/doms " +
unixUser.getHomedir() + "/var " + homedir + "/etc " +
homedir + "/users " +
homedir + "/var " +
"\" && " + "\" && " +
"chown httpd " + unixUser.getHomedir() + "/doms && " + "chown httpd " + homedir + "/doms && " +
"chmod 1550 " + unixUser.getHomedir() + "/doms && " + "chmod 1550 " + homedir + "/doms && " +
"chmod 2700 " + unixUser.getHomedir() + "/etc && " + "chmod 2700 " + homedir + "/etc && " +
"chmod 2750 " + unixUser.getHomedir() + "/var && " + "chmod 2750 " + homedir + "/var && " +
"chmod 2755 " + unixUser.getHomedir() + "/users" "chmod 2755 " + homedir + "/users"
); );
} }
@ -155,6 +160,14 @@ public class PacProcessorFactory implements EntityProcessorFactory {
); );
} }
private Processor createIfUp(String pacName) {
return new ShellProcessor("ifup eth0:" + pacName);
}
private Processor createIfDown(String pacName) {
return new ShellProcessor("ifdown eth0:" + pacName);
}
private UnixUser getPacAdminUser(Pac pac) throws ProcessorException { private UnixUser getPacAdminUser(Pac pac) throws ProcessorException {
UnixUser unixUser = null; UnixUser unixUser = null;
Set<UnixUser> unixUserSet = pac.getUnixUser(); Set<UnixUser> unixUserSet = pac.getUnixUser();

View File

@ -2,9 +2,11 @@ package de.hsadmin.remote;
import java.text.DateFormat; import java.text.DateFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.SortedSet;
import java.util.TreeSet;
import de.hsadmin.core.model.AbstractEntity; import de.hsadmin.core.model.AbstractEntity;
import de.hsadmin.mods.cust.Customer; import de.hsadmin.mods.cust.Customer;
@ -28,10 +30,16 @@ public class PacRemote extends AbstractRemote {
resultMap.put("curinetaddr", pac.getCurINetAddr().getInetAddr()); resultMap.put("curinetaddr", pac.getCurINetAddr().getInetAddr());
resultMap.put("created", df.format(pac.getCreated())); resultMap.put("created", df.format(pac.getCreated()));
resultMap.put("basepac", pac.getBasepac().getName()); resultMap.put("basepac", pac.getBasepac().getName());
Set<PacComponent> pacComponents = pac.getPacComponents(); SortedSet<PacComponent> sortedComponents = new TreeSet<PacComponent>(new Comparator<PacComponent>() {
@Override
public int compare(PacComponent o1, PacComponent o2) {
return o2.getBaseComponent().getSorting() - o1.getBaseComponent().getSorting();
}
});
sortedComponents.addAll(pac.getPacComponents());
StringBuffer bf = new StringBuffer(); StringBuffer bf = new StringBuffer();
boolean empty = true; boolean empty = true;
for (PacComponent comp : pacComponents) { for (PacComponent comp : sortedComponents) {
if (comp.getQuantity() > 0) { if (comp.getQuantity() > 0) {
if (!empty) { if (!empty) {
bf.append("; "); bf.append("; ");

View File

@ -91,7 +91,7 @@ public class RoleTest {
@Test @Test
public void testHostmaster() { public void testHostmaster() {
String user = "pe"; String user = "ad";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> whereParams = new HashMap<String, String>(); Map<String, String> whereParams = new HashMap<String, String>();
Object[] params = new Object[] { user, Object[] params = new Object[] { user,