Commit 65ad3322 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

[KVM] better information for IPv6

use address 1 instead of address 0 and display a /etc/network/interfaces syntax.

Also display the info for resilient KVM.

Note that formatting is not perfect due to softwaretype recipe (which doesn't preserve spaces).

/cc @jm @rafael @alain.takoudjou

/reviewed-on nexedi/slapos!521
parent 98b747a1
...@@ -19,7 +19,7 @@ md5sum = 028b6a6456d744c11b1bb2c51ecd51b2 ...@@ -19,7 +19,7 @@ md5sum = 028b6a6456d744c11b1bb2c51ecd51b2
[template-kvm] [template-kvm]
filename = instance-kvm.cfg.jinja2 filename = instance-kvm.cfg.jinja2
md5sum = e30912b1256bb093329ee3c108666f05 md5sum = c51026e815ca43b5de5ddc6cbd8bf1e2
[template-kvm-cluster] [template-kvm-cluster]
filename = instance-kvm-cluster.cfg.jinja2.in filename = instance-kvm-cluster.cfg.jinja2.in
...@@ -27,7 +27,7 @@ md5sum = 63fa784d8946d0b6e3fbd6381e1ea9f4 ...@@ -27,7 +27,7 @@ md5sum = 63fa784d8946d0b6e3fbd6381e1ea9f4
[template-kvm-resilient] [template-kvm-resilient]
filename = instance-kvm-resilient.cfg.jinja2 filename = instance-kvm-resilient.cfg.jinja2
md5sum = c189bce8b196a3b5bcb01526a3f9b2aa md5sum = 6677ac6074f6be671fe8e8b8a6a4afe8
[template-kvm-import] [template-kvm-import]
filename = instance-kvm-import.cfg.jinja2.in filename = instance-kvm-import.cfg.jinja2.in
......
...@@ -68,12 +68,14 @@ return = ...@@ -68,12 +68,14 @@ return =
# KVM related parameters # KVM related parameters
# XXX: return ALL parameters (like nat rules), through jinja # XXX: return ALL parameters (like nat rules), through jinja
backend-url url ip backend-url url ip
{{ ' ' }}ipv6-network-info
[publish-connection-information] [publish-connection-information]
recipe = slapos.cookbook:publish recipe = slapos.cookbook:publish
backend-url = ${request-kvm:connection-backend-url} backend-url = ${request-kvm:connection-backend-url}
url = ${request-kvm:connection-url} url = ${request-kvm:connection-url}
ipv6 = ${request-kvm:connection-ip} ipv6 = ${request-kvm:connection-ip}
ipv6-network-info = ${request-kvm:connection-ipv6-network-info}
monitor-password = ${publish-early:monitor-password} monitor-password = ${publish-early:monitor-password}
monitor-user = ${monitor-publish-parameters:monitor-user} monitor-user = ${monitor-publish-parameters:monitor-user}
{% if monitor_dict -%} {% if monitor_dict -%}
......
...@@ -133,7 +133,7 @@ external-disk-number = ${slap-parameter:external-disk-number} ...@@ -133,7 +133,7 @@ external-disk-number = ${slap-parameter:external-disk-number}
external-disk-size = ${slap-parameter:external-disk-size} external-disk-size = ${slap-parameter:external-disk-size}
external-disk-format = ${slap-parameter:external-disk-format} external-disk-format = ${slap-parameter:external-disk-format}
{% if enable_http == 'true' or ( use_tap == 'true' and slap_configuration.get('tap-ipv4-addr', '') != "") -%} {% if enable_http == 'true' -%}
httpd-port = ${slap-parameter:httpd-port} httpd-port = ${slap-parameter:httpd-port}
{% else -%} {% else -%}
httpd-port = 0 httpd-port = 0
...@@ -464,14 +464,14 @@ key_info = Get the publick key file in your VM with the command: wget {{ kvm_htt ...@@ -464,14 +464,14 @@ key_info = Get the publick key file in your VM with the command: wget {{ kvm_htt
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if use_tap == 'true' and slap_configuration.get('tap-ipv4-addr', '') != "" -%} {% if use_tap == 'true' and slap_configuration.get('tap-ipv4-addr') -%}
ipv4-network-info = ipv4-network-info =
Use these configurations below to configure IPv4 on interface {{ iface }} in your VM. Use this configuration in /etc/network/interfaces to configure IPv4 on interface {{ iface }} in your VM.
IFACE={{ iface }} auto {{ iface }}
${network-config-ipv4:ifconfig} iface {{ iface }} inet static
${network-config-ipv4:route-iface} address {{ slap_configuration.get('tap-ipv4-addr') }}
${network-config-ipv4:route-network} netmask {{ slap_configuration.get('tap-ipv4-netmask') }}
${network-config-ipv4:route-default} gateway {{ slap_configuration.get('tap-ipv4-gateway') }}
{% if enable_http == 'true' %} {% if enable_http == 'true' %}
${helper:blank-line} ${helper:blank-line}
Or run in your VM the command: wget -O- {{ kvm_http }}/netconfig.sh | /bin/sh - Or run in your VM the command: wget -O- {{ kvm_http }}/netconfig.sh | /bin/sh -
...@@ -479,20 +479,21 @@ ipv4-network-info = ...@@ -479,20 +479,21 @@ ipv4-network-info =
{% endif %} {% endif %}
ipv6-network-info = ipv6-network-info =
{% if use_tap == 'true' and slap_configuration.get('tap-ipv6-addr', '') != "" %} {% if use_tap == 'true' and slap_configuration.get('tap-ipv6-addr') %}
Use these configurations below to configure IPv6 on interface {{ iface }} in your VM. Use this configuration in /etc/network/interfaces to configure IPv6 on interface {{ iface }} in your VM.
IFACE={{ iface }} auto {{ iface }}
ip link set dev $IFACE up iface {{ iface }} inet6 static
${network-config-ipv6:ipv6-add-address} address {{ slap_configuration.get('tap-ipv6-gateway') }}
${network-config-ipv6:ipv6-add-default-route} netmask {{ slap_configuration.get('tap-ipv6-network').split('/')[1] }}
gateway {{ slap_configuration.get('tap-ipv6-addr') }}
{% if enable_http == 'true' %} {% if enable_http == 'true' %}
${helper:blank-line} ${helper:blank-line}
Or run in your VM the command: wget -O- {{ kvm_http }}/ipv6_config.sh | /bin/sh - Or run in your VM the command: wget -O- {{ kvm_http }}/${network-config-ipv6:filename} | /bin/sh -
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if use_tap == 'true' and slap_configuration.get('tap-ipv4-addr', '') != "" -%} {% if use_tap == 'true' and slap_configuration.get('tap-ipv4-addr') -%}
[network-config-ipv4] [network-config-ipv4]
recipe = plone.recipe.command recipe = plone.recipe.command
path = ${directory:public}/netconfig.sh path = ${directory:public}/netconfig.sh
...@@ -521,19 +522,22 @@ command = ...@@ -521,19 +522,22 @@ command =
update-command = ${:command} update-command = ${:command}
{% endif -%} {% endif -%}
{% if use_tap == 'true' and slap_configuration.get('tap-ipv6-addr', '') != "" -%} {% if use_tap == 'true' and slap_configuration.get('tap-ipv6-addr') -%}
[network-config-ipv6] [network-config-ipv6]
recipe = plone.recipe.command recipe = plone.recipe.command
path = ${directory:public}/ipv6_config.sh filename = ipv6_config.sh
ipv6-add-address = ip -6 address add {{ slap_configuration.get('tap-ipv6-network') }} dev \$IFACE path = ${directory:public}/${:filename}
ipv6-add-address = ip -6 address add {{ slap_configuration.get('tap-ipv6-gateway') }}/{{ slap_configuration.get('tap-ipv6-network').split('/')[1] }} dev \$IFACE
ipv6-add-default-route = ipv6-add-default-route =
ip -6 route del default ; ip -6 route add default dev \$IFACE via {{ slap_configuration.get('tap-ipv6-gateway') }} ip -6 route del default ; ip -6 route add default dev \$IFACE via {{ slap_configuration.get('tap-ipv6-addr') }}
ipv6-set-link-up = ip link set dev \$IFACE up
command = command =
cat > ${:path} << EOF cat > ${:path} << EOF
#!/bin/sh #!/bin/sh
IFACE={{ iface }} IFACE={{ iface }}
${:ipv6-add-address} ${:ipv6-add-address}
${:ipv6-add-default-route} ${:ipv6-add-default-route}
${:ipv6-set-link-up}
EOF EOF
update-command = ${:command} update-command = ${:command}
{% endif -%} {% endif -%}
...@@ -565,7 +569,7 @@ mode = {{ mode }} ...@@ -565,7 +569,7 @@ mode = {{ mode }}
[publish-host-config] [publish-host-config]
recipe = plone.recipe.command recipe = plone.recipe.command
name = {{ slapparameter_dict.get('name', 'localhost') }} name = {{ slapparameter_dict.get('name', 'localhost') }}
{% if use_tap == 'true' and slap_configuration.get('tap-ipv4-addr', '') != "" -%} {% if use_tap == 'true' and slap_configuration.get('tap-ipv4-addr') -%}
local-ipv4 = {{ slap_configuration['tap-ipv4-addr'] }} local-ipv4 = {{ slap_configuration['tap-ipv4-addr'] }}
gateway = {{ slap_configuration.get('tap-ipv4-gateway') }} gateway = {{ slap_configuration.get('tap-ipv4-gateway') }}
netmask = {{ slap_configuration.get('tap-ipv4-network') }} netmask = {{ slap_configuration.get('tap-ipv4-network') }}
......
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