From 494dfc305ab8ba627118a8f2b53383c0ff27156a Mon Sep 17 00:00:00 2001
From: Tristan Cavelier <tristan.cavelier@tiolive.com>
Date: Wed, 23 Sep 2015 15:20:00 +0000
Subject: [PATCH] erp5: make mariadb monitor friendly

---
 stack/erp5/buildout.cfg            | 14 ++++++++++++--
 stack/erp5/dummy.cfg               |  0
 stack/erp5/instance-mariadb.cfg.in | 13 ++++++++++---
 stack/erp5/instance.cfg.in         |  1 +
 4 files changed, 23 insertions(+), 5 deletions(-)
 create mode 100644 stack/erp5/dummy.cfg

diff --git a/stack/erp5/buildout.cfg b/stack/erp5/buildout.cfg
index c2533f4db..97d8eded0 100644
--- a/stack/erp5/buildout.cfg
+++ b/stack/erp5/buildout.cfg
@@ -147,7 +147,7 @@ mode = 755
 [template-mariadb]
 <= download-base
 filename = instance-mariadb.cfg.in
-md5sum = 4d46ab5aa651a39c4021de6f647e8be9
+md5sum = 843e59e4151ab37a2c7bfd1ea9dafd98
 link-binary =
   ${coreutils:location}/bin/basename
   ${coreutils:location}/bin/cat
@@ -225,7 +225,7 @@ recipe = slapos.recipe.template:jinja2
 # XXX: "template.cfg" is hardcoded in instanciation recipe
 rendered = ${buildout:directory}/template.cfg
 template = ${:_profile_base_location_}/instance.cfg.in
-md5sum = 4d043c96d70b35d1fbbd8120d8edee7c
+md5sum = 708a721558f9bbe8856482e60891b4c7
 mode = 640
 context =
     key mariadb_link_binary template-mariadb:link-binary
@@ -291,6 +291,7 @@ context =
     key template_kumofs template-kumofs:target
     key template_mariadb template-mariadb:target
     key template_mariadb_initial_setup template-mariadb-initial-setup:target
+    key template_monitor monitor-template:rendered
     key template_my_cnf template-my-cnf:target
     key template_postfix template-postfix:target
     key template_postfix_aliases template-postfix-aliases:target
@@ -306,6 +307,15 @@ context =
     key xfixes_location xfixes:location
     key zlib_location zlib:location
 
+[monitor-template-dummy]
+<= download-base
+# This is a placeholder, to be overriden by extending monitor SR
+filename = dummy.cfg
+md5sum = d41d8cd98f00b204e9800998ecf8427e
+
+[monitor-template]
+rendered = ${monitor-template-dummy:target}
+
 [template-erp5]
 <= download-base
 filename = instance-erp5.cfg.in
diff --git a/stack/erp5/dummy.cfg b/stack/erp5/dummy.cfg
new file mode 100644
index 000000000..e69de29bb
diff --git a/stack/erp5/instance-mariadb.cfg.in b/stack/erp5/instance-mariadb.cfg.in
index 4b46a03fb..447176e20 100644
--- a/stack/erp5/instance-mariadb.cfg.in
+++ b/stack/erp5/instance-mariadb.cfg.in
@@ -17,7 +17,7 @@
 {%   set ip = (ipv4_set | list)[0] -%}
 {% endif -%}
 
-[publish-mariadb-url]
+[publish]
 recipe = slapos.cookbook:publish.serialised
 {% macro render_database_list(database_list) -%}
 {% set publish_database_list = [] -%}
@@ -232,10 +232,17 @@ command-line = "{{ parameter_dict['bin-directory'] }}/is-local-tcp-port-opened"
 wrapper-path = ${directory:promise}/mariadb
 parameters-extra = true
 
+[monitor-instance-parameter]
+monitor-httpd-ipv6 = {{ (ipv6_set | list)[0] }}
+monitor-httpd-port = {{ port + 1 }}
+monitor-title = Mariadb monitor
+
 [buildout]
-extends = {{ logrotate_cfg }}
+extends =
+  {{ logrotate_cfg }}
+  {{ paremeter_dict['template-monitor'] }}
 parts +=
-  publish-mariadb-url
+  publish
   logrotate-entry-mariadb
   binary-link
   update-mysql
diff --git a/stack/erp5/instance.cfg.in b/stack/erp5/instance.cfg.in
index 908662864..548bf29fa 100644
--- a/stack/erp5/instance.cfg.in
+++ b/stack/erp5/instance.cfg.in
@@ -150,6 +150,7 @@ template-mariadb-initial-setup = {{ template_mariadb_initial_setup }}
 link-binary = {{ dumps(mariadb_link_binary) }}
 bin-directory = {{ bin_directory }}
 mariadb-resiliency-after-import-script = {{ mariadb_resiliency_after_import_script }}
+template-monitor = {{ template_monitor }}
 
 [dynamic-template-mariadb]
 <= jinja2-template-base
-- 
2.30.9