From 7559a94a3592c9461316d9f8335ff7f7beb95c1c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?J=C3=A9rome=20Perrin?= <jerome@nexedi.com>
Date: Fri, 5 Jun 2015 03:19:42 +0000
Subject: [PATCH] palo: etl working version

---
 component/palo_olap/buildout.cfg |  1 +
 software/palo/instance.cfg.in    | 28 +++++++----
 software/palo/palo.ini.in        |  1 -
 software/palo/server.xml.in      | 79 ++++++++++++++++++++++++++++++++
 software/palo/software.cfg       | 14 +++++-
 5 files changed, 110 insertions(+), 13 deletions(-)
 create mode 100644 software/palo/server.xml.in

diff --git a/component/palo_olap/buildout.cfg b/component/palo_olap/buildout.cfg
index 54ef0f5fc..3f2a520a6 100644
--- a/component/palo_olap/buildout.cfg
+++ b/component/palo_olap/buildout.cfg
@@ -25,6 +25,7 @@ recipe = slapos.recipe.build:gitclone
 repository = https://lab.nexedi.cn/jerome/palo_olap.git
 branch = 5.1
 git-executable = ${git:location}/bin/git
+develop = true
 
 [palo_olap]
 recipe = slapos.recipe.cmmi
diff --git a/software/palo/instance.cfg.in b/software/palo/instance.cfg.in
index 071057ddb..2dc539594 100644
--- a/software/palo/instance.cfg.in
+++ b/software/palo/instance.cfg.in
@@ -4,7 +4,6 @@ parts =
   directory
   palo_olap
   publish-connection-parameter
-todo=
   palo_etl
 
 eggs-directory = ${buildout:eggs-directory}
@@ -20,7 +19,6 @@ url = $${slap_connection:server_url}
 key = $${slap_connection:key_file}
 cert = $${slap_connection:cert_file}
 
-configuration.name = John Doe
 configuration.erp5_url = 
 
 [palo_olap_parameter]
@@ -39,9 +37,13 @@ service = $${:etc}/service
 promise = $${:etc}/promise/
 log = $${:var}/log
 
+[directory_palo_etl]
+<= directory
+data_directory = $${:var}/palo_olap/
+
 [directory_tomcat]
 <= directory
-catalina_base = $${:home}/var/palo_etl
+catalina_base = $${:var}/palo_etl
 catalina_logs = $${:catalina_base}/logs
 catalina_temp = $${:catalina_base}/temp
 catalina_webapps = $${:catalina_base}/webapps
@@ -52,7 +54,6 @@ catalina_conf = $${:catalina_base}/conf
 [TODO]
 todo =
   tunnel
-  patch ipv6
   etl
   log_rotation
 
@@ -72,36 +73,43 @@ context = import json_module json
 
 [palo_olap]
 recipe = slapos.cookbook:wrapper
-command-line = ${palo_olap:location}/usr/bin/palo --data-direct $${directory:var}  --init-file $${palo_ini:rendered}
+command-line = ${palo_olap:location}/usr/bin/palo --data-directory $${directory_palo_etl:data_directory}  --init-file $${palo_ini:rendered}
 wrapper-path = $${directory:service}/palo_olap
 
+[tomcat_palo_etl]
+recipe = plone.recipe.command
+command = echo "needed ?"
+
 [palo_etl]
 recipe = slapos.cookbook:wrapper
 command-line = ${tomcat:location}/bin/catalina.sh run
 wrapper-path = $${directory:service}/palo_etl
 environment = JAVA_HOME = ${java:location}
   CATALINA_BASE = $${directory_tomcat:catalina_base}
-dependencies = $${palo_etl_server_xml:rendered}
+dependencies = $${palo_etl_server_xml:rendered} $${tomcat_palo_etl:recipe}
 
 [palo_etl_server_xml]
 recipe = slapos.recipe.template:jinja2
-template = ${:_profile_base_location_}/server.xml.in
+# XXX  template = ${template_server_xml:location}/${template_server_xml:filename}
+template = ${template_server_xml:url}
 rendered = $${directory_tomcat:catalina_conf}/server.xml
 extensions = jinja2.ext.do
 context = import json_module json
   section palo_etl_parameter palo_etl_parameter
   raw palo_etl_server_war ${palo_etl_download:location}
-
+  
 [palo_etl_parameter]
 tomcat_port = 8888
-tomcat_host = $${:ipv4}
-tomcat_server_port = 8005
+tomcat_host = $${:ipv6}
+tomcat_server_port = 8006
 ipv4 = $${instance-parameter:ipv4-random}
 ipv6 = $${instance-parameter:ipv6-random}
+palo_etl_war = ${palo_etl_download:location}
 
 [publish-connection-parameter]
 recipe = slapos.cookbook:publish
 palo_olap_url = $${palo_olap_parameter:ipv4}:$${palo_olap_parameter:palo_olap_port}
 palo_olap_ipv6_url = [$${palo_olap_parameter:ipv6}]:$${palo_olap_parameter:palo_olap_port}
 palo_olap_admin_url = $${palo_olap_parameter:ipv4}:$${palo_olap_parameter:palo_olap_admin_port}
+palo_etl_url = http://[$${palo_etl_parameter:tomcat_host}]:$${palo_etl_parameter:tomcat_port}/etlserver/services/ETL-Server?wsdl
 
diff --git a/software/palo/palo.ini.in b/software/palo/palo.ini.in
index 4fe206e0e..bc4f26a91 100644
--- a/software/palo/palo.ini.in
+++ b/software/palo/palo.ini.in
@@ -5,7 +5,6 @@ log {{ directory_log }}/palo_olap.log
 verbose debug
 
 {% if erp5_url %}
-user-login
 workerlogin authorization
 worker {{ erp5_login_worker_path }} {{ directory_log }}/erp5_login_worker.log {{ erp5_url }}
 admin {{ palo_olap_parameter.ipv4 }} {{ palo_olap_parameter.palo_olap_admin_port }}
diff --git a/software/palo/server.xml.in b/software/palo/server.xml.in
new file mode 100644
index 000000000..8d5fae3b8
--- /dev/null
+++ b/software/palo/server.xml.in
@@ -0,0 +1,79 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<!-- Note:  A "Server" is not itself a "Container", so you may not
+     define subcomponents such as "Valves" at this level.
+     Documentation at /docs/config/server.html
+     
+     Debug: {{ repr(palo_etl_parameter) }}
+ -->
+<Server port="-1" shutdown="SHUTDOWN">
+
+  <!--APR library loader. Documentation at /docs/apr.html -->
+  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
+  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
+  <Listener className="org.apache.catalina.core.JasperListener" />
+  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
+  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
+  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
+<!--
+  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
+  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />
+-->
+
+<!--
+  <GlobalNamingResources>
+    <Resource name="UserDatabase" auth="Container"
+              type="org.apache.catalina.UserDatabase"
+              description="User database that can be updated and saved"
+              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
+              pathname="conf/tomcat-users.xml" />
+  </GlobalNamingResources>
+-->  
+
+  <Service name="Catalina">
+    <Connector address="{{ palo_etl_parameter['tomcat_host'] }}" port="{{ palo_etl_parameter['tomcat_port'] }}"
+      maxThreads="10"
+      minSpareThreads="3"
+      maxSpareThreads="7"
+      connectionTimeout="20000"
+      enableLookups="false"
+      maxHttpHeaderSize="8192"
+      protocol="HTTP/1.1"
+      useBodyEncodingForURI="true"
+      redirectPort="8443"
+      acceptCount="100"
+      disableUploadTimeout="true" />
+                  
+    <Context path="/" docBase="{{ palo_etl_parameter['palo_etl_war'] }}/etlserver.war" 
+         debug="1" privileged="true">
+      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"                
+         resourceName="UserDatabase"/> 
+    </Context>
+
+    <Engine name="Catalina" defaultHost="localhost">
+      <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
+             resourceName="UserDatabase"/>
+
+      <Host name="localhost"  appBase="webapps" debug="1"
+            unpackWARs="true" autoDeploy="true"
+            xmlValidation="false" xmlNamespaceAware="false">
+
+      </Host>
+    </Engine>
+  </Service>
+</Server>
diff --git a/software/palo/software.cfg b/software/palo/software.cfg
index d64e5e18d..c7bd045a3 100644
--- a/software/palo/software.cfg
+++ b/software/palo/software.cfg
@@ -7,6 +7,7 @@ extends =
 parts =
   palo_olap
   palo_etl
+  template_server_xml
   slapos-cookbook
   instance-profile
 
@@ -22,11 +23,20 @@ mode = 0644
 recipe = hexagonit.recipe.download
 url = http://downloads.sourceforge.net/project/palo-etl-server/etlserver/Palo%20ETL%20Server%203.2/etlserver.war
 download-only = true
-;destination = ${buildout:directory}/var/tomcat/webapps/
+
+[download-base]
+recipe = slapos.recipe.build:download
+url = ${:_profile_base_location_}/${:filename}
+mode = 644
+
+[template_server_xml]
+< = download-base
+filename = server.xml.in
+# md5sum = 
 
 [palo_etl]
 recipe = plone.recipe.command
-command = echo "TODO"
+command = echo "etl downlaoded in ${palo_etl_download:location}"
 needs = ${palo_etl_download:url}
 
 [versions]
-- 
2.30.9