From 1ea0bc8966a632a11f89fe9a20a9b7f10c334cb4 Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Fri, 21 Mar 2014 15:48:46 +0100
Subject: [PATCH] erzeuge pac-addr-ipv4

---
 hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm         |   12 ++++++
 hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java |   58 +++++++++++++++--------------
 hsarback/test/de/hsadmin/remote/InitDataTest.java         |   12 ++++--
 3 files changed, 50 insertions(+), 32 deletions(-)

diff --git a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
index a517e2c..9bc0f60 100644
--- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
+++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
@@ -49,33 +49,6 @@
 		}
 	}
 
-	private Processor createAccountingRulesProc() {
-		return new ShellProcessor("mk-iptables-rules Accounting");
-	}
-
-	private Processor createHttpdVirtualProc(Hive hive) throws ProcessorException {
-		Processor domSetupProcessor = new CompoundProcessor(
-				new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.vm", hive,
-						"/etc/apache2/virtual.conf.tmp", "root", "root", "644", true),
-				new ShellProcessor("for PEM in $( cat /etc/apache2/virtual.conf.tmp | grep SSLCertificateFile | cut -c24- ); do " +
-						"ls $PEM >/dev/null 2>&1 || ( " +
-						" sed -i \"/SSLCertificateFile.*${PEM:18}/c \\\n" +
-						"\\ \\ \\ \\ SSLCertificateFile \\/etc\\/apache2\\/pems\\/default.pem\" /etc/apache2/virtual.conf.tmp && " +
-						" sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/c \\\n" +
-						"\\ \\ \\ \\ SSLCertificateChainFile \\/etc\\/apache2\\/pems\\/default.chain.pem\" /etc/apache2/virtual.conf.tmp " +
-						"); " +
-						"done"),
-				new ShellProcessor("for PEM in $( cat /etc/apache2/virtual.conf.tmp | grep SSLCertificateChainFile | cut -c29- ); do " +
-						"ls $PEM >/dev/null 2>&1 || " +
-						" sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/d \" /etc/apache2/virtual.conf.tmp ; " +
-						"done"),
-				new ShellProcessor("(diff -q /etc/apache2/virtual.conf.tmp /etc/apache2/virtual.conf"
-								+ " && rm /etc/apache2/virtual.conf.tmp )"
-								+ " || ( mv /etc/apache2/virtual.conf.tmp /etc/apache2/virtual.conf "
-								+ " && invoke-rc.d apache2 reload >/dev/null 2>&1 ) "));
-		return domSetupProcessor;
-	}
-
 	@Override
 	public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity)
 			throws ProcessorException {
@@ -109,12 +82,41 @@
 		}
 	}
 
+	private Processor createAccountingRulesProc() {
+		return new ShellProcessor("mk-iptables-rules Accounting");
+	}
+
+	private Processor createHttpdVirtualProc(Hive hive) throws ProcessorException {
+		Processor domSetupProcessor = new CompoundProcessor(
+				new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.vm", hive,
+						"/etc/apache2/virtual.conf.tmp", "root", "root", "644", true),
+				new ShellProcessor("for PEM in $( cat /etc/apache2/virtual.conf.tmp | grep SSLCertificateFile | cut -c24- ); do " +
+						"ls $PEM >/dev/null 2>&1 || ( " +
+						" sed -i \"/SSLCertificateFile.*${PEM:18}/c \\\n" +
+						"\\ \\ \\ \\ SSLCertificateFile \\/etc\\/apache2\\/pems\\/default.pem\" /etc/apache2/virtual.conf.tmp && " +
+						" sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/c \\\n" +
+						"\\ \\ \\ \\ SSLCertificateChainFile \\/etc\\/apache2\\/pems\\/default.chain.pem\" /etc/apache2/virtual.conf.tmp " +
+						"); " +
+						"done"),
+				new ShellProcessor("for PEM in $( cat /etc/apache2/virtual.conf.tmp | grep SSLCertificateChainFile | cut -c29- ); do " +
+						"ls $PEM >/dev/null 2>&1 || " +
+						" sed -i \"/SSLCertificateChainFile.*${PEM:18:5}.chain.pem/d \" /etc/apache2/virtual.conf.tmp ; " +
+						"done"),
+				new ShellProcessor("(diff -q /etc/apache2/virtual.conf.tmp /etc/apache2/virtual.conf"
+								+ " && rm /etc/apache2/virtual.conf.tmp )"
+								+ " || ( mv /etc/apache2/virtual.conf.tmp /etc/apache2/virtual.conf "
+								+ " && invoke-rc.d apache2 reload >/dev/null 2>&1 ) "));
+		return domSetupProcessor;
+	}
+
 	private Processor createEtcHostsProc(Hive hive) throws ProcessorException {
 		return new VelocityProcessor("/de/hsadmin/mods/pac/hosts.vm", hive, "/etc/hosts", true);
 	}
 
 	private Processor createNetworkInterfacesProc(Hive hive) throws ProcessorException {
-		return new VelocityProcessor("/de/hsadmin/mods/pac/interfaces.vm", hive, "/etc/network/interfaces", true);
+		VelocityProcessor interfacesProc = new VelocityProcessor("/de/hsadmin/mods/pac/interfaces.vm", hive, "/etc/network/interfaces", true);
+		VelocityProcessor pacIPv4Proc = new VelocityProcessor("/de/hsadmin/mods/pac/pac-addr-ipv4.vm", hive, "/etc/network/pac-addr-ipv4", true);
+		return new CompoundProcessor(interfacesProc, pacIPv4Proc);
 	}
 
 	private Processor createIPTablesProc() {
diff --git a/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm b/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm
new file mode 100644
index 0000000..a2fb8cf
--- /dev/null
+++ b/hsarback/src/de/hsadmin/mods/pac/pac-addr-ipv4.vm
@@ -0,0 +1,12 @@
+# 
+# This file is managed by HSAdmin.
+# Do not edit manually. Changes will be overwritten.
+#
+
+#foreach( $pac in ${hive.pacs} )
+#if( !${pac.managedServer} )
+eth0:${pac.name}:${pac.curINetAddr.inetAddr}/32
+#end
+#end
+
+        
diff --git a/hsarback/test/de/hsadmin/remote/InitDataTest.java b/hsarback/test/de/hsadmin/remote/InitDataTest.java
index a03e1fd..05571f6 100644
--- a/hsarback/test/de/hsadmin/remote/InitDataTest.java
+++ b/hsarback/test/de/hsadmin/remote/InitDataTest.java
@@ -36,8 +36,15 @@
 		client = null;
 		cas = null;
 	}
-
+	
 	@Test
+	public void initData() {
+		testAdd1Member();
+		testAdd2Pac();
+		testAdd3User();
+		testAdd4Domain();
+	}
+
 	public void testAdd1Member() {
 		String user = "ad";
 		int membersCount = -9999;
@@ -70,7 +77,6 @@
 		}
 	}
 
-	@Test
 	public void testAdd2Pac() {
 		int count = getPacsCount();
 		String user = "ad";
@@ -98,7 +104,6 @@
 		assertEquals(count + 1, getPacsCount());
 	}
 
-	@Test
 	public void testAdd3User() {
 		int count = getUsersCount();
 		try {
@@ -127,7 +132,6 @@
 		assertEquals(count + 1, getUsersCount());
 	}
 
-	@Test
 	public void testAdd4Domain() {
 		int count = getUsersCount();
 		try {

--
Gitblit v1.9.0-SNAPSHOT