Commit dd9b9623 authored by Guillaume Hervier's avatar Guillaume Hervier

software/kvm: Small fix on UDP NAT rules

This way when setting `udp:<port>` in `nat-rules` instance parameter, it won't mess up with buildout's syntax.

PS: It seems the UDP won't work at all since `6tunnel` doesn't support TCP tunneling, so this is more of a cosmetic fix.

/reviewed-on nexedi/slapos!464
parent f45c62c8
...@@ -184,8 +184,13 @@ hash-files = ${buildout:directory}/software_release/buildout.cfg ...@@ -184,8 +184,13 @@ hash-files = ${buildout:directory}/software_release/buildout.cfg
{% if use_nat == 'true' and nat_rule_list -%} {% if use_nat == 'true' and nat_rule_list -%}
{% for port in nat_rule_list.split(' ') -%} {% for port in nat_rule_list.split(' ') -%}
{% if ':' in port -%}
{% set proto, port = port.split(':') -%}
{% else -%}
{% set proto, port = 'tcp', port -%}
{% endif -%}
{% set external_port = 10000 + port|int() -%} {% set external_port = 10000 + port|int() -%}
{% set section_name = '6tunnel-' ~ external_port -%} {% set section_name = '6tunnel-' ~ proto ~ '-' ~ external_port -%}
[{{ section_name }}] [{{ section_name }}]
<= tunnel-6to4-base <= tunnel-6to4-base
ipv4-port = {{ external_port }} ipv4-port = {{ external_port }}
...@@ -419,8 +424,13 @@ maximum-extra-disk-amount = {{ disk_number }} ...@@ -419,8 +424,13 @@ maximum-extra-disk-amount = {{ disk_number }}
{% if nat_rule_list -%} {% if nat_rule_list -%}
# Publish NAT port mapping status # Publish NAT port mapping status
{% for port in nat_rule_list.split(' ') -%} {% for port in nat_rule_list.split(' ') -%}
{% if ':' in port -%}
{% set proto, port = port.split(':') -%}
{% else -%}
{% set proto, port = 'tcp', port -%}
{% endif -%}
{% set external_port = 10000 + port|int() -%} {% set external_port = 10000 + port|int() -%}
nat-rule-port-{{port}} = ${slap-network-information:global-ipv6} : ${6tunnel-{{external_port}}:ipv6-port} nat-rule-port-{{proto}}-{{port}} = ${slap-network-information:global-ipv6} : ${6tunnel-{{proto}}-{{external_port}}:ipv6-port}
{% if slapparameter_dict.get('publish-nat-url', False) -%} {% if slapparameter_dict.get('publish-nat-url', False) -%}
nat-rule-url-{{port}} = [${slap-network-information:global-ipv6}]:${6tunnel-{{external_port}}:ipv6-port} nat-rule-url-{{port}} = [${slap-network-information:global-ipv6}]:${6tunnel-{{external_port}}:ipv6-port}
{% endif -%} {% endif -%}
......
...@@ -99,7 +99,7 @@ recipe = hexagonit.recipe.download ...@@ -99,7 +99,7 @@ recipe = hexagonit.recipe.download
ignore-existing = true ignore-existing = true
url = ${:_profile_base_location_}/instance-kvm.cfg.jinja2 url = ${:_profile_base_location_}/instance-kvm.cfg.jinja2
mode = 644 mode = 644
md5sum = 149df1bc788ce68c86a5fda4872e008e md5sum = 0668791e78430bafdec5300b4ea8d90a
download-only = true download-only = true
on-update = true on-update = true
......
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