Commit c1f24e68 authored by Alain Takoudjou's avatar Alain Takoudjou

kvm: fix bug when nat-rules parameter is empty, set nat-rules empty by default for kvm-cluster

parent 58a4f0db
......@@ -98,7 +98,7 @@ mode = 0644
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/instance-kvm.cfg.jinja2
mode = 644
md5sum = 4056df213786fd87b60efd3d6f1f2bec
md5sum = 0df2380dc0151a0669804891fdfe07d1
download-only = true
on-update = true
......@@ -106,7 +106,7 @@ on-update = true
recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/instance-kvm-cluster.cfg.jinja2.in
mode = 644
md5sum = 8e84c7a4e7be009021243c14707e0a1e
md5sum = 23235b16e2f4deb00a1bd5bf0846daaf
download-only = true
on-update = true
......@@ -184,7 +184,7 @@ recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/template/template-kvm-run.in
mode = 644
filename = template-kvm-run.in
md5sum = 38265d52fdc03589081cc7dd13999020
md5sum = 42e5c653780fdb86b50aa89d73814934
download-only = true
on-update = true
......
......@@ -51,7 +51,7 @@ config-cpu-count = {{ dumps(kvm_parameter_dict.get('cpu-count', 1)) }}
config-cpu-options = {{ dumps(kvm_parameter_dict.get('cpu-options', '')) }}
config-numa = {{ dumps(kvm_parameter_dict.get('numa', '')) }}
{% set nat_rules_list = kvm_parameter_dict.get('nat-rules', [22, 80, 443]) -%}
{% set nat_rules_list = kvm_parameter_dict.get('nat-rules', []) -%}
config-nat-rules = {{ nat_rules_list | join(' ') }}
config-publish-nat-url = True
config-use-nat = {{ use_nat }}
......@@ -76,6 +76,7 @@ config-document-host = ${apache-conf:ip}
config-document-port = ${apache-conf:port}
config-document-path = ${hash-code:passwd}
config-keyboard-layout-language = {{ dumps(kvm_parameter_dict.get('keyboard-layout-language', '')) }}
config-type = cluster
{% set authorized_source_list = slapparameter_dict.get('fw-authorized-sources', []) -%}
{% set rejected_source_list = slapparameter_dict.get('fw-reject-sources', []) -%}
......
......@@ -4,10 +4,19 @@
{% set name = slapparameter_dict.get('name', 'localhost') -%}
{% set monitor = slapparameter_dict.get('enable-monitor', 'True').lower() -%}
{% set disable_ansible_promise = slapparameter_dict.get('disable-ansible-promise', 'False').lower() -%}
{% set instance_type = slapparameter_dict.get('type', 'standalone') -%}
{% set nat_rule_list = slapparameter_dict.get('nat-rules', '22 80 443') -%}
{% set frontend_software_type = 'default' -%}
{% set extends_list = [] -%}
{% set part_list = [] -%}
{% if instance_type == 'cluster' -%}
{% set nat_rule_list = slapparameter_dict.get('nat-rules', '') %}
{% endif -%}
{% if not nat_rule_list or not nat_rule_list.strip() -%}
{% set nat_rule_list = '' %}
{% endif -%}
{% if monitor -%}
{% do extends_list.append(template_monitor) -%}
{% endif -%}
......@@ -81,7 +90,7 @@ tap-mac-address = ${create-tap-mac:mac-address}
use-tap = ${slap-parameter:use-tap}
use-nat = ${slap-parameter:use-nat}
nat-rules = ${slap-parameter:nat-rules}
nat-rules = {{ nat_rule_list }}
enable-vhost = ${slap-parameter:enable-vhost}
virtual-hard-drive-url = ${slap-parameter:virtual-hard-drive-url}
......@@ -142,8 +151,7 @@ ipv6 = ${slap-network-information:global-ipv6}
wrapper-path = ${directory:services}/6tunnel-${:ipv6-port}
command-line = {{ sixtunnel_executable_location }} -6 -4 -d -l ${:ipv6} ${:ipv6-port} ${:ipv4} ${:ipv4-port}
{% if use_nat == 'true' -%}
{% set nat_rule_list = slapparameter_dict.get('nat-rules', '22 80 443') %}
{% if use_nat == 'true' and nat_rule_list -%}
{% for port in nat_rule_list.split(' ') -%}
{% set external_port = 10000 + port|int() -%}
{% set section_name = '6tunnel-' ~ external_port -%}
......@@ -313,7 +321,7 @@ source = ${directory:public}
[monitor-parameters]
port = 8026
{% if slapparameter_dict.get('document-host', '') and slapparameter_dict.get('document-port', '') -%}
{% if instance_type == 'cluster' -%}
# XXX - Set frontend software type to 'custom-personal' by default for cluster instance
{% set frontend_software_type = 'custom-personal' -%}
{% endif -%}
......@@ -350,7 +358,6 @@ maximum-extra-disk-amount = {{ disk_number }}
{% set iface = 'eth1' -%}
# Publish NAT port mapping status
# XXX: hardcoded value from [slap-parameter]
{% set nat_rule_list = slapparameter_dict.get('nat-rules', '22 80 443') %}
{% for port in nat_rule_list.split(' ') -%}
{% set external_port = 10000 + port|int() -%}
nat-rule-port-{{port}} = ${slap-network-information:global-ipv6} : ${6tunnel-{{external_port}}:ipv6-port}
......
......@@ -217,8 +217,11 @@ numa_parameter = []
number = -1
if use_nat == 'true':
number += 1
rules = 'user,id=lan%s,' % number + ','.join('hostfwd=tcp:%s:%s-:%s' % (listen_ip,
rules = 'user,id=lan%s' % number
if nat_rules:
rules += ',' + ','.join('hostfwd=tcp:%s:%s-:%s' % (listen_ip,
int(port) + 10000, port) for port in nat_rules.split())
if httpd_port > 0:
rules += ',guestfwd=tcp:10.0.2.100:80-cmd:%s %s %s' % (netcat_bin,
listen_ip, httpd_port)
......
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