[buildout]
parts =
  instance-parameter
  directory
  palo_olap
  publish-connection-parameter
todo=
  palo_etl

eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true


[instance-parameter]
recipe = slapos.cookbook:slapconfiguration
computer = $${slap_connection:computer_id}
partition = $${slap_connection:partition_id}
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]
ipv4 = $${instance-parameter:ipv4-random}
ipv6 = $${instance-parameter:ipv6-random}
palo_olap_port = 7777
palo_olap_admin_port = 7778

[directory]
recipe = slapos.cookbook:mkdirectory
home = $${buildout:directory}
etc = $${:home}/etc
var = $${:home}/var
script = $${:etc}/run/
service = $${:etc}/service
promise = $${:etc}/promise/
log = $${:var}/log

[directory_tomcat]
<= directory
catalina_base = $${:home}/var/palo_etl
catalina_logs = $${:catalina_base}/logs
catalina_temp = $${:catalina_base}/temp
catalina_webapps = $${:catalina_base}/webapps
catalina_work = $${:catalina_base}/work
catalina_conf = $${:catalina_base}/conf


[TODO]
todo =
  tunnel
  patch ipv6
  etl
  log_rotation


[palo_ini]
recipe = slapos.recipe.template:jinja2
template = ${:_profile_base_location_}/palo.ini.in
rendered = $${directory:etc}/palo.ini
extensions = jinja2.ext.do
context = import json_module json
  key directory_log directory:log
  raw palo_olap_repository_location ${palo_olap-repository.git:location}
  section parameter instance-parameter
  section palo_olap_parameter palo_olap_parameter
  key erp5_url instance-parameter:configuration.erp5_url
  raw erp5_login_worker_path ${erp5_login_worker:output}

[palo_olap]
recipe = slapos.cookbook:wrapper
command-line = ${palo_olap:location}/usr/bin/palo --data-direct $${directory:var}  --init-file $${palo_ini:rendered}
wrapper-path = $${directory:service}/palo_olap

[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}

[palo_etl_server_xml]
recipe = slapos.recipe.template:jinja2
template = ${:_profile_base_location_}/server.xml.in
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
ipv4 = $${instance-parameter:ipv4-random}
ipv6 = $${instance-parameter:ipv6-random}

[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}

