Commit 912a8835 authored by Xavier Thompson's avatar Xavier Thompson

html5as: Match the final state of html5as-tutorial

parent d7721eb4
...@@ -17,11 +17,11 @@ ...@@ -17,11 +17,11 @@
[template-cfg] [template-cfg]
filename = instance.cfg.in filename = instance.cfg.in
md5sum = 9e486efe4ab1aba8cb72b04f6c6da8ad md5sum = 51292164b96db5889010e0962c96ee96
[instance_html5as] [instance_html5as]
_update_hash_filename_ = instance_html5as.cfg.in _update_hash_filename_ = instance_html5as.cfg.in
md5sum = f86b2f37c0acd21ca1f41d90c5477d75 md5sum = 98b880debb61556066c5d720c1cb86e3
[template_nginx_conf] [template_nginx_conf]
_update_hash_filename_ = templates/nginx_conf.in _update_hash_filename_ = templates/nginx_conf.in
...@@ -46,3 +46,7 @@ md5sum = 1c0ee16966e1fcdb3fd11c09f12ee2b2 ...@@ -46,3 +46,7 @@ md5sum = 1c0ee16966e1fcdb3fd11c09f12ee2b2
[template_instance_replicate] [template_instance_replicate]
_update_hash_filename_ = instance_replicate.cfg.in _update_hash_filename_ = instance_replicate.cfg.in
md5sum = 7ff7e11d05145115f53564ec1af205ef md5sum = 7ff7e11d05145115f53564ec1af205ef
[custom-promise]
_update_hash_filename_ = promise/check_index_exists.py
md5sum = a98d598136629e667e7e43e1d3746b53
...@@ -15,6 +15,7 @@ template_launcher = {{ template_launcher_target }} ...@@ -15,6 +15,7 @@ template_launcher = {{ template_launcher_target }}
template_index_html = {{ template_index_html_target }} template_index_html = {{ template_index_html_target }}
template_graceful = {{ template_graceful_target }} template_graceful = {{ template_graceful_target }}
template_monitor = {{ template_monitor }} template_monitor = {{ template_monitor }}
custom_promise = {{ custom_promise }}
[instance-html5as] [instance-html5as]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
......
...@@ -14,6 +14,7 @@ parts = ...@@ -14,6 +14,7 @@ parts =
launcher launcher
nginx-graceful nginx-graceful
port-listening-promise port-listening-promise
index-exists-promise
logrotate-entry-nginx logrotate-entry-nginx
publish-connection-information publish-connection-information
...@@ -239,3 +240,12 @@ promise = check_url_available ...@@ -239,3 +240,12 @@ promise = check_url_available
name = html5as-http-frontend.py name = html5as-http-frontend.py
url = ${html5as-frontend:connection-secure_access} url = ${html5as-frontend:connection-secure_access}
config-url = ${:url} config-url = ${:url}
config-check-secure = 1
# Add the custom promise to check that the index file exists
[index-exists-promise]
recipe = slapos.cookbook:promise.plugin
eggs = slapos.core
file = {{ parameter_list['custom_promise'] }}
output = ${directory:plugins}/check-index-exists.py
config-filepath = ${html5as:default_index}
import os
from zope.interface import implementer
from slapos.grid.promise import interface
from slapos.grid.promise.generic import GenericPromise
@implementer(interface.IPromise)
class RunPromise(GenericPromise):
def __init__(self, config):
"""
Called when initialising the promise before testing.
Sets the configuration and the periodicity.
"""
super(RunPromise, self).__init__(config)
self.setPeriodicity(minute=2)
def sense(self):
"""
Called every time the promise is tested.
Signals a positive or negative result.
In this case, check whether the file exists.
"""
path = self.getConfig('filepath')
if os.path.isfile(path):
self.logger.info("filepath %s exists and is a file", path)
else:
self.logger.error("filepath %s does not exist or is not a file", path)
def test(self):
"""
Called after sense() if the instance is still converging.
Returns success or failure based on sense results.
In this case, fail if the previous sensor result is negative.
"""
return self._test(result_count=1, failure_amount=1)
def anomaly(self):
"""
Called after sense() if the instance has finished converging.
Returns success or failure based on sense results.
Failure signals the instance has diverged.
In this case, fail if two out of the last three results are negative.
"""
return self._anomaly(result_count=3, failure_amount=2)
...@@ -21,6 +21,8 @@ parts = ...@@ -21,6 +21,8 @@ parts =
# Call creation of instance.cfg file that will be called for deployment of # Call creation of instance.cfg file that will be called for deployment of
# instance # instance
template-cfg template-cfg
# Add extra egg
extra-eggs
# Download instance.cfg.in (buildout profile used to deployment of instance), # Download instance.cfg.in (buildout profile used to deployment of instance),
# replace all {{ foo_bar }} parameters by real values # replace all {{ foo_bar }} parameters by real values
...@@ -41,12 +43,9 @@ context = ...@@ -41,12 +43,9 @@ context =
key template_index_html_target template_index_html:target key template_index_html_target template_index_html:target
key template_graceful_target template_graceful:target key template_graceful_target template_graceful:target
key template_instance_replicate template_instance_replicate:target key template_instance_replicate template_instance_replicate:target
# Monitor stack also provides a template for the instance
key template_monitor monitor2-template:rendered key template_monitor monitor2-template:rendered
key custom_promise custom-promise:target
# Have one shared section to define the default behaviour to download
# templates. Sections inheriting from this one won't need to redefine
# shared parameters
[download-base] [download-base]
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/${:_update_hash_filename_} url = ${:_profile_base_location_}/${:_update_hash_filename_}
...@@ -56,7 +55,6 @@ mode = 0644 ...@@ -56,7 +55,6 @@ mode = 0644
[instance_html5as] [instance_html5as]
# This section inherit from download-base # This section inherit from download-base
<= download-base <= download-base
# Filename and md5sum is defined in buildout.hash.cfg
[template_nginx_conf] [template_nginx_conf]
<= download-base <= download-base
...@@ -75,3 +73,12 @@ mode = 0644 ...@@ -75,3 +73,12 @@ mode = 0644
[template_instance_replicate] [template_instance_replicate]
<= download-base <= download-base
[extra-eggs]
recipe = zc.recipe.egg
eggs =
plone.recipe.command
# Download the custom promise
[custom-promise]
<= download-base
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