Commit 53ba5651 authored by Steven Gueguen's avatar Steven Gueguen

Address Merge Request demands (promises, comment)

parent f06d6f2e
[instance.cfg] [instance.cfg]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = 331e87b5c619c78e93c33b44df2a1eb3 md5sum = 55d7b4ffdb4374210165c3a30e42a8fe
[install-warp10.sh] [install-warp10.sh]
filename = install-warp10.sh.in filename = install-warp10.sh.in
md5sum = 6a43da88ed75d9d4418c6dd713ca4d5e md5sum = 0cee0cca541c0f7aa2654907258a43d8
#!/bin/sh #!/bin/sh
set -eu
WARP10_HOME={{ warp10_home }} WARP10_HOME={{ warp10_home }}
WARP10_CONFIG_DIR=${WARP10_HOME}/etc/conf.d WARP10_CONFIG_DIR=${WARP10_HOME}/etc/conf.d
JAVA_HOME={{ java_home }} JAVA_HOME={{ java_home }}
...@@ -23,7 +25,7 @@ sed -i -e "s@^#JAVA_HOME=.*@JAVA_HOME=${JAVA_HOME}@" "${WARP10_HOME}/etc/warp10- ...@@ -23,7 +25,7 @@ sed -i -e "s@^#JAVA_HOME=.*@JAVA_HOME=${JAVA_HOME}@" "${WARP10_HOME}/etc/warp10-
sed -i -e 's/\&$//g' "${WARP10_HOME}/bin/warp10.sh" sed -i -e 's/\&$//g' "${WARP10_HOME}/bin/warp10.sh"
## ##
## Listen to all interface, enable SensisionWarpScriptExtension and TokenWarpScriptExtension ## Configure host and port, enable TokenWarpScriptExtension
## ##
sed -i -e 's|^#warpscript.extension.sensision|warpscript.extension.sensision|g' "${WARP10_CONFIG_DIR}/99-init.conf" sed -i -e 's|^#warpscript.extension.sensision|warpscript.extension.sensision|g' "${WARP10_CONFIG_DIR}/99-init.conf"
{ {
......
...@@ -3,12 +3,18 @@ parts = ...@@ -3,12 +3,18 @@ parts =
publish-connection-parameter publish-connection-parameter
warp10-wrapper warp10-wrapper
extends = ${monitor2-template:output}
# Define egg directories to be the one from Software Release # Define egg directories to be the one from Software Release
# (/opt/slapgrid/...) # (/opt/slapgrid/...)
eggs-directory = ${buildout:eggs-directory} eggs-directory = ${buildout:eggs-directory}
develop-eggs-directory = ${buildout:develop-eggs-directory} develop-eggs-directory = ${buildout:develop-eggs-directory}
offline = true offline = true
##
## Configure instance
##
[directory] [directory]
recipe = slapos.cookbook:mkdirectory recipe = slapos.cookbook:mkdirectory
home = $${buildout:directory} home = $${buildout:directory}
...@@ -26,42 +32,44 @@ url = $${slap-connection:server-url} ...@@ -26,42 +32,44 @@ url = $${slap-connection:server-url}
key = $${slap-connection:key-file} key = $${slap-connection:key-file}
cert = $${slap-connection:cert-file} cert = $${slap-connection:cert-file}
[warp10-ip] [warp10-instance]
ipv4 = $${instance-parameter:ipv4-random}
ipv6 = $${instance-parameter:ipv6-random}
[warp10-port]
recipe = slapos.cookbook:free_port recipe = slapos.cookbook:free_port
minimum = 8000 minimum = 8000
maximum = 9000 maximum = 9000
ip = $${instance-parameter:ipv4-random} ip = $${instance-parameter:ipv4-random}
ipv4 =$${:ip}
ipv6 = $${instance-parameter:ipv6-random}
##
## Instal Warp 10
##
# Extract the Warp 10 archive in the instance
[warp10-extract] [warp10-extract]
recipe = slapos.recipe.build:download-unpacked recipe = slapos.recipe.build:download-unpacked
url = ${warp10-download:destination} url = ${warp10-download:destination}
md5sum = 5e16392e5718b88002251cebf13c8cc4 md5sum = 5e16392e5718b88002251cebf13c8cc4
destination = $${directory:opt}/warp10 destination = $${directory:opt}/warp10
# Configure Warp 10 installation script
[install-warp10.sh] [install-warp10.sh]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
url = ${install-warp10.sh:destination} url = ${install-warp10.sh:destination}
output = $${directory:opt}/$${:_buildout_section_name_} output = $${directory:opt}/$${:_buildout_section_name_}
context = context =
key warp10_home warp10-extract:destination key warp10_home warp10-extract:destination
key warp10_host warp10-ip:ipv4 key warp10_host warp10-instance:ipv4
key warp10_port warp10-port:port key warp10_port warp10-instance:port
raw java_home ${java:location} raw java_home ${java:location}
# Bootstrap Warp 10 and apply some configurations
[warp10-install] [warp10-install]
recipe = slapos.recipe.build recipe = plone.recipe.command
warp10_home = $${warp10-extract:destination} warp10_home = $${warp10-extract:destination}
init = command = $${install-warp10.sh:output}
options['location'] = '' stop-on-error = true
install =
import subprocess
subprocess.run("$${install-warp10.sh:output}", capture_output=True)
update=
# Read tokens that are generated during the installation step
[warp10-read-tokengen] [warp10-read-tokengen]
recipe = slapos.recipe.build recipe = slapos.recipe.build
init = init =
...@@ -73,16 +81,19 @@ init = ...@@ -73,16 +81,19 @@ init =
import os import os
if os.path.isfile("$${warp10-install:warp10_home}/tokens/tokens.txt"): if os.path.isfile("$${warp10-install:warp10_home}/tokens/tokens.txt"):
f = open("$${warp10-install:warp10_home}/tokens/tokens.txt", "r") f = open("$${warp10-install:warp10_home}/tokens/tokens.txt", "r")
options['read-token'] = f.readline() options['read-token'] = f.readline().rstrip()
options['write-token'] = f.readline() options['write-token'] = f.readline().rstrip()
options['sensision-read-token'] = f.readline() options['sensision-read-token'] = f.readline().rstrip()
options['sensision-write-token'] = f.readline() options['sensision-write-token'] = f.readline().rstrip()
[warp10-wrapper] [warp10-wrapper]
recipe = slapos.cookbook:wrapper recipe = slapos.cookbook:wrapper
command-line = $${warp10-install:warp10_home}/bin/warp10.sh start command-line = $${warp10-install:warp10_home}/bin/warp10.sh start
wrapper-path = $${directory:services}/warp10 wrapper-path = $${directory:services}/warp10
##
## Configure HAProxy
##
[warp10-frontend-certificate] [warp10-frontend-certificate]
recipe = plone.recipe.command recipe = plone.recipe.command
...@@ -110,12 +121,13 @@ context = ...@@ -110,12 +121,13 @@ context =
content = content =
listen app listen app
log global log global
bind $${:ip}:$${:port} ssl crt $${warp10-frontend-certificate:cert-file} alpn h2,http/1.1 # bind $${:ip}:$${:port} ssl crt $${warp10-frontend-certificate:cert-file} alpn h2,http/1.1
server app $${warp10-ip:ipv4}:$${warp10-port:port} bind $${:ip}:$${:port} alpn h2,http/1.1
server app $${warp10-instance:ipv4}:$${warp10-instance:port}
pidfile = $${directory:run}/$${:_buildout_section_name_}.pid pidfile = $${directory:run}/$${:_buildout_section_name_}.pid
ip = $${instance-parameter:ipv6-random} ip = $${warp10-instance:ipv6}
port = 8443 port = 9001
[warp10-frontend] [warp10-frontend]
recipe = slapos.cookbook:wrapper recipe = slapos.cookbook:wrapper
...@@ -123,14 +135,46 @@ wrapper-path = $${directory:services}/$${:_buildout_section_name_} ...@@ -123,14 +135,46 @@ wrapper-path = $${directory:services}/$${:_buildout_section_name_}
command-line = command-line =
${haproxy:location}/sbin/haproxy -f $${warp10-frontend-config:output} ${haproxy:location}/sbin/haproxy -f $${warp10-frontend-config:output}
url = https://[$${warp10-frontend-config:ip}]:$${warp10-frontend-config:port} # url = https://[$${warp10-frontend-config:ip}]:$${warp10-frontend-config:port}
url = http://[$${warp10-frontend-config:ip}]:$${warp10-frontend-config:port}
##
## Promises
##
# Check if Warp 10 is listening
[promise-warp10-listening]
<= monitor-promise-base
promise = check_socket_listening
name = $${:_buildout_section_name_}.py
config-host = $${warp10-instance:ipv4}
config-port = $${warp10-instance:port}
# Check if HAProxy is listening
[promise-haproxy-listening]
<= monitor-promise-base
promise = check_url_available
name = $${:_buildout_section_name_}.py
config-verify = 0
config-url =$${warp10-frontend:url}
# Check if token is correctly published
[promise-token-published]
<= monitor-promise-base
promise = check_command_execute
name = $${:_buildout_section_name_}.py
config-command = [[ "None" == "$${publish-connection-parameter:read-token}" ]]
# config-command = test -n ""
##
## Publish parameters
##
[publish-connection-parameter] [publish-connection-parameter]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
backend-url = $${warp10-frontend:url} backend-url = $${warp10-frontend:url}
ipv4 = $${warp10-ip:ipv4} ipv4 = $${warp10-instance:ipv4}
ipv6 = $${warp10-ip:ipv6} ipv6 = $${warp10-instance:ipv6}
read-token = $${warp10-read-tokengen:read-token} read-token = $${warp10-read-tokengen:read-token}
write-token = $${warp10-read-tokengen:write-token} write-token = $${warp10-read-tokengen:write-token}
sensision-read-token = $${warp10-read-tokengen:sensision-read-token} sensision-read-token = $${warp10-read-tokengen:sensision-read-token}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment