From c1e6c98a04a6e00d3f7da58e370e9207a2eee03c Mon Sep 17 00:00:00 2001
From: Guillaume Hervier <guillaume.hervier@nexedi.com>
Date: Fri, 29 Jun 2018 15:17:39 +0200
Subject: [PATCH] re6stnet: Add port-redirection config file generation

---
 software/re6stnet/instance-re6stnet.cfg.in | 13 ++++++++++++-
 software/re6stnet/software.cfg             |  2 +-
 2 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/software/re6stnet/instance-re6stnet.cfg.in b/software/re6stnet/instance-re6stnet.cfg.in
index 528e8b34e..23ef9895e 100644
--- a/software/re6stnet/instance-re6stnet.cfg.in
+++ b/software/re6stnet/instance-re6stnet.cfg.in
@@ -184,6 +184,16 @@ name = re6stnet
 log = ${re6st-registry-conf-dict:logfile}
 post = test ! -s ${re6st-registry-wrapper:pid-file} || {{ parameter_dict['bin-directory'] }}/slapos-kill --pidfile ${re6st-registry-wrapper:pid-file} -s USR1
 
+[port-redirection]
+recipe = slapos.recipe.template:jinja2
+template = inline:
+{%- raw %}
+  [{"srcPort": 9201, "destPort": 9201, "destAddress": "{{ parameter_dict['ipv4'] }}"}]
+{% endraw -%}
+rendered = ${buildout:directory}/.slapos-port-redirect
+context =
+  section parameter_dict re6st-registry-conf-dict
+
 [re6st-registry-promise]
 recipe = slapos.cookbook:check_port_listening
 path = ${directory:promises}/re6st-registry
@@ -221,7 +231,8 @@ parts =
   apache-httpd
   apache-httpd-graceful
   publish
-  
+  port-redirection
+
   re6st-registry-promise
   apache-registry-promise
   monitor-base
diff --git a/software/re6stnet/software.cfg b/software/re6stnet/software.cfg
index 498b93961..07795a4e4 100644
--- a/software/re6stnet/software.cfg
+++ b/software/re6stnet/software.cfg
@@ -87,7 +87,7 @@ extra-context =
 [template-re6stnet]
 < = download-base
 filename = instance-re6stnet.cfg.in
-md5sum = 7d65efffeae3f9ae4e64699303a083b4
+md5sum = 6f28b611a0e2415768238f5e8d29d36e
 
 [template-apache-conf]
 < = download-base
-- 
2.30.9