Commit b89c4377 authored by Thomas Gambier's avatar Thomas Gambier 🚴🏼

CLEANUP: clean tap information and correctly use base template

Use tap information from partition resource (coming from slapconfiguration recipe) instead of old (and deprecated softwaretype recipe).
parent 1c56e822
...@@ -89,18 +89,8 @@ class Recipe(object): ...@@ -89,18 +89,8 @@ class Recipe(object):
One of the IPv4 addresses. One of the IPv4 addresses.
ipv6-random ipv6-random
One of the IPv6 addresses. One of the IPv6 addresses.
tap global_ipv4_network
Set of TAP interfaces. The global IPv4 network
tap-network-information-dict
Dict of set of all TAP network information
tap-ipv4
ipv4 allowed for this TAP
tap-gateway
ipv4 of gateway interface of this TAP
tap-netmask
ipv4 netmask address of this TAP
tap-network
ipv4 network address of this TAP
configuration configuration
Dict of all parameters. Dict of all parameters.
storage-dict storage-dict
...@@ -112,6 +102,8 @@ class Recipe(object): ...@@ -112,6 +102,8 @@ class Recipe(object):
anyway, and are available through "configuration" output key. anyway, and are available through "configuration" output key.
instance-state instance-state
The instance state. The instance state.
Also note that all information from resource file will be appended
""" """
# XXX: used to detect if a configuration key is a valid section key. This # XXX: used to detect if a configuration key is a valid section key. This
...@@ -215,20 +207,6 @@ class Recipe(object): ...@@ -215,20 +207,6 @@ class Recipe(object):
options['ipv4-random'] = list(ipv4_set)[0].encode('UTF-8') options['ipv4-random'] = list(ipv4_set)[0].encode('UTF-8')
if ipv6_set: if ipv6_set:
options['ipv6-random'] = list(ipv6_set)[0].encode('UTF-8') options['ipv6-random'] = list(ipv6_set)[0].encode('UTF-8')
if route_ipv4_set:
options['tap-ipv4'] = list(route_ipv4_set)[0].encode('UTF-8')
options['tap-network-information-dict'] = dict(ipv4=route_ipv4_set,
netmask=route_mask_set,
gateway=route_gw_set,
network=route_network_set)
else:
options['tap-network-information-dict'] = {}
if route_gw_set:
options['tap-gateway'] = list(route_gw_set)[0].encode('UTF-8')
if route_mask_set:
options['tap-netmask'] = list(route_mask_set)[0].encode('UTF-8')
if route_network_set:
options['tap-network'] = list(route_network_set)[0].encode('UTF-8')
storage_home = options.get('storage-home') storage_home = options.get('storage-home')
storage_dict = {} storage_dict = {}
...@@ -245,8 +223,6 @@ class Recipe(object): ...@@ -245,8 +223,6 @@ class Recipe(object):
storage_dict[filename] = storage_link storage_dict[filename] = storage_link
options['storage-dict'] = storage_dict options['storage-dict'] = storage_dict
options['tap'] = tap_set
# The external information transfered from Slap Master has been processed # The external information transfered from Slap Master has been processed
# so we extend with information gathered from partition resource file # so we extend with information gathered from partition resource file
if hasattr(slapformat.Partition, "resource_file"): if hasattr(slapformat.Partition, "resource_file"):
......
...@@ -87,7 +87,7 @@ nbd-port = ${slap-parameter:nbd-port} ...@@ -87,7 +87,7 @@ nbd-port = ${slap-parameter:nbd-port}
nbd2-host = ${slap-parameter:nbd2-host} nbd2-host = ${slap-parameter:nbd2-host}
nbd2-port = ${slap-parameter:nbd2-port} nbd2-port = ${slap-parameter:nbd2-port}
tap-interface = ${slap-network-information:network-interface} tap-interface = {{ tap_name }}
disk-size = ${slap-parameter:disk-size} disk-size = ${slap-parameter:disk-size}
disk-type = ${slap-parameter:disk-type} disk-type = ${slap-parameter:disk-type}
...@@ -132,7 +132,7 @@ external-disk-number = ${slap-parameter:external-disk-number} ...@@ -132,7 +132,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 tap_network_dict.has_key('ipv4') ) -%} {% if enable_http == 'true' or ( use_tap == 'true' and tap_ipv4_addr != "") -%}
httpd-port = ${slap-parameter:httpd-port} httpd-port = ${slap-parameter:httpd-port}
{% else -%} {% else -%}
httpd-port = 0 httpd-port = 0
...@@ -438,7 +438,7 @@ nat-rule-url-{{port}} = [${slap-network-information:global-ipv6}]:${6tunnel-{{ex ...@@ -438,7 +438,7 @@ nat-rule-url-{{port}} = [${slap-network-information:global-ipv6}]:${6tunnel-{{ex
{% endif -%} {% endif -%}
{% endif -%} {% endif -%}
{% if use_tap == 'true' -%} {% if use_tap == 'true' -%}
tap-ipv4 = ${slap-network-information:tap-ipv4} tap-ipv4 = {{tap_ipv4_addr}}
{% endif -%} {% endif -%}
{% set kvm_http = 'http://${slap-network-information:local-ipv4}:' ~ slapparameter_dict.get('httpd-port', 8081) -%} {% set kvm_http = 'http://${slap-network-information:local-ipv4}:' ~ slapparameter_dict.get('httpd-port', 8081) -%}
...@@ -451,7 +451,7 @@ tap-ipv4 = ${slap-network-information:tap-ipv4} ...@@ -451,7 +451,7 @@ tap-ipv4 = ${slap-network-information:tap-ipv4}
{% endif %} {% endif %}
{% endif %} {% endif %}
{% if use_tap == 'true' and tap_network_dict.has_key('ipv4') -%} {% if use_tap == 'true' and tap_ipv4_addr != "" -%}
1_info = Use these configurations below to configure interface {{ iface }} in your VM. 1_info = Use these configurations below to configure interface {{ iface }} in your VM.
2_info = ${network-config:ifconfig} 2_info = ${network-config:ifconfig}
3_info = ${network-config:route-iface} 3_info = ${network-config:route-iface}
...@@ -464,15 +464,15 @@ tap-ipv4 = ${slap-network-information:tap-ipv4} ...@@ -464,15 +464,15 @@ tap-ipv4 = ${slap-network-information:tap-ipv4}
[network-config] [network-config]
recipe = plone.recipe.command recipe = plone.recipe.command
path = ${directory:public}/netconfig.sh path = ${directory:public}/netconfig.sh
ifconfig = ifconfig {{ iface }} ${slap-network-information:tap-ipv4} netmask ${slap-network-information:tap-netmask} ifconfig = ifconfig {{ iface }} {{tap_ipv4_addr}} netmask {{tap_ipv4_netmask}}
route-iface = route add ${slap-network-information:tap-gateway} dev {{ iface }} route-iface = route add {{tap_ipv4_gateway}} dev {{ iface }}
route-network = route add -net ${slap-network-information:tap-network} netmask ${slap-network-information:tap-netmask} gw ${slap-network-information:tap-gateway} route-network = route add -net {{tap_ipv4_network}} netmask {{tap_ipv4_netmask}} gw {{tap_ipv4_gateway}}
{% if iface == 'eth0' -%} {% if iface == 'eth0' -%}
route-default = route add default gw ${slap-network-information:tap-gateway} route-default = route add default gw {{tap_ipv4_gateway}}
{% elif nat_restrict == 'true' -%} {% elif nat_restrict == 'true' -%}
route-default = route add default gw ${slap-network-information:tap-gateway} dev {{ iface }} route-default = route add default gw {{tap_ipv4_gateway}} dev {{ iface }}
{% elif global_ipv4_prefix -%} {% elif global_ipv4_prefix -%}
route-default = ip route add {{ global_ipv4_prefix }} via ${slap-network-information:tap-gateway} dev {{ iface }} src ${slap-network-information:tap-ipv4} route-default = ip route add {{ global_ipv4_prefix }} via {tap_ipv4_gateway}} dev {{ iface }} src {{tap_ipv4_addr}}
{% else -%} {% else -%}
route-default = route-default =
{% endif -%} {% endif -%}
...@@ -513,11 +513,11 @@ mode = {{ mode }} ...@@ -513,11 +513,11 @@ 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 tap_network_dict.has_key('ipv4') -%} {% if use_tap == 'true' and tap_ipv4_addr != "" -%}
local-ipv4 = ${slap-network-information:tap-ipv4} local-ipv4 = {{tap_ipv4_addr}}
gateway = ${slap-network-information:tap-gateway} gateway = {{tap_ipv4_gateway}}
netmask = ${slap-network-information:tap-network} netmask = {{tap_ipv4_network}}
network = ${slap-network-information:tap-netmask} network = {{tap_ipv4_netmask}}
{% else -%} {% else -%}
local-ipv4 = 127.0.0.1 local-ipv4 = 127.0.0.1
gateway = gateway =
...@@ -576,7 +576,7 @@ template = {{ ansible_promise_tpl }} ...@@ -576,7 +576,7 @@ template = {{ ansible_promise_tpl }}
rendered = ${directory:promises}/ansible_{{ name }} rendered = ${directory:promises}/ansible_{{ name }}
extensions = jinja2.ext.do extensions = jinja2.ext.do
context = context =
key host slap-network-information:tap-ipv4 key host {{ tap_ipv4_addr }}
raw logs ${directory:public}/ansible raw logs ${directory:public}/ansible
raw name {{ name }} raw name {{ name }}
......
...@@ -45,17 +45,16 @@ extensions = jinja2.ext.do ...@@ -45,17 +45,16 @@ extensions = jinja2.ext.do
mode = 0644 mode = 0644
extra-context = extra-context =
context = context =
key develop_eggs_directory buildout:develop-eggs-directory key develop_eggs_directory buildout:develop-eggs-directory
key eggs_directory buildout:eggs-directory key eggs_directory buildout:eggs-directory
key ipv4 slap-configuration:ipv4 key ipv4 slap-configuration:ipv4
key ipv6 slap-configuration:ipv6 key ipv6 slap-configuration:ipv6
key global_ipv4_prefix network-information:global-ipv4-network key global_ipv4_prefix network-information:global-ipv4-network
key tap_network_dict slap-configuration:tap-network-information-dict key storage_dict slap-configuration:storage-dict
key storage_dict slap-configuration:storage-dict key slapparameter_dict slap-configuration:configuration
key slapparameter_dict slap-configuration:configuration key computer_id slap-configuration:computer
key computer_id slap-configuration:computer raw openssl_executable_location ${openssl:location}/bin/openssl
raw openssl_executable_location ${openssl:location}/bin/openssl $${:extra-context}
$${:extra-context}
[dynamic-template-kvm-cluster-parameters] [dynamic-template-kvm-cluster-parameters]
...@@ -71,45 +70,45 @@ extra-context = ...@@ -71,45 +70,45 @@ extra-context =
raw template_monitor ${monitor2-template:rendered} raw template_monitor ${monitor2-template:rendered}
[dynamic-template-kvm] [dynamic-template-kvm]
recipe = slapos.recipe.template:jinja2 <= jinja2-template-base
template = ${template-kvm:location}/instance-kvm.cfg.jinja2 template = ${template-kvm:location}/instance-kvm.cfg.jinja2
rendered = $${buildout:directory}/template-kvm.cfg filename = template-kvm.cfg
extensions = jinja2.ext.do extra-context =
context = key tap_ipv4_addr slap-configuration:tap-ipv4-addr
key develop_eggs_directory buildout:develop-eggs-directory key tap_ipv4_gateway slap-configuration:tap-ipv4-gateway
key eggs_directory buildout:eggs-directory key tap_ipv4_netmask slap-configuration:tap-ipv4-netmask
key global_ipv4_prefix network-information:global-ipv4-network key tap_ipv4_network slap-configuration:tap-ipv4-network
key slapparameter_dict slap-configuration:configuration key tap_ipv6_addr slap-configuration:tap-ipv6-addr
key storage_dict slap-configuration:storage-dict key tap_ipv6_gateway slap-configuration:tap-ipv6-gateway
key tap_network_dict slap-configuration:tap-network-information-dict key tap_ipv6_netmask slap-configuration:tap-ipv6-netmask
raw ansible_promise_tpl ${template-ansible-promise:location}/${template-ansible-promise:filename} key tap_ipv6_network slap-configuration:tap-ipv6-network
raw curl_executable_location ${curl:location}/bin/curl key tap_name slap-configuration:tap-name
raw dash_executable_location ${dash:location}/bin/dash raw ansible_promise_tpl ${template-ansible-promise:location}/${template-ansible-promise:filename}
raw dcron_executable_location ${dcron:location}/sbin/crond raw curl_executable_location ${curl:location}/bin/curl
raw debian_amd64_netinst_location ${debian-amd64-netinst.iso:location}/${debian-amd64-netinst.iso:filename} raw dash_executable_location ${dash:location}/bin/dash
raw file_download_script ${file-download-script:location}/${file-download-script:filename} raw dcron_executable_location ${dcron:location}/sbin/crond
raw logrotate_cfg ${template-logrotate-base:rendered} raw debian_amd64_netinst_location ${debian-amd64-netinst.iso:location}/${debian-amd64-netinst.iso:filename}
raw novnc_location ${noVNC:location} raw file_download_script ${file-download-script:location}/${file-download-script:filename}
raw netcat_bin ${netcat:location}/bin/netcat raw logrotate_cfg ${template-logrotate-base:rendered}
raw openssl_executable_location ${openssl:location}/bin/openssl raw novnc_location ${noVNC:location}
raw python_executable ${buildout:executable} raw netcat_bin ${netcat:location}/bin/netcat
raw python_eggs_executable ${buildout:bin-directory}/${eggs:interpreter} raw python_executable ${buildout:executable}
raw qemu_executable_location ${kvm:location}/bin/qemu-system-x86_64 raw python_eggs_executable ${buildout:bin-directory}/${eggs:interpreter}
raw qemu_img_executable_location ${kvm:location}/bin/qemu-img raw qemu_executable_location ${kvm:location}/bin/qemu-system-x86_64
raw qemu_start_promise_tpl ${template-qemu-ready:location}/${template-qemu-ready:filename} raw qemu_img_executable_location ${kvm:location}/bin/qemu-img
raw sixtunnel_executable_location ${6tunnel:location}/bin/6tunnel raw qemu_start_promise_tpl ${template-qemu-ready:location}/${template-qemu-ready:filename}
raw template_httpd_cfg ${template-httpd:rendered} raw sixtunnel_executable_location ${6tunnel:location}/bin/6tunnel
raw template_content ${template-content:location}/${template-content:filename} raw template_httpd_cfg ${template-httpd:rendered}
raw template_kvm_controller_run ${template-kvm-controller:location}/${template-kvm-controller:filename} raw template_content ${template-content:location}/${template-content:filename}
raw template_kvm_run ${template-kvm-run:location}/${template-kvm-run:filename} raw template_kvm_controller_run ${template-kvm-controller:location}/${template-kvm-controller:filename}
raw template_monitor ${monitor2-template:rendered} raw template_kvm_run ${template-kvm-run:location}/${template-kvm-run:filename}
raw websockify_executable_location ${buildout:directory}/bin/websockify raw template_monitor ${monitor2-template:rendered}
raw wipe_disk_wrapper ${buildout:directory}/bin/securedelete raw websockify_executable_location ${buildout:directory}/bin/websockify
raw wipe_disk_wrapper ${buildout:directory}/bin/securedelete
template-parts-destination = ${template-parts:target} template-parts-destination = ${template-parts:target}
template-replicated-destination = ${template-replicated:target} template-replicated-destination = ${template-replicated:target}
import-list = file parts :template-parts-destination import-list = file parts :template-parts-destination
file replicated :template-replicated-destination file replicated :template-replicated-destination
mode = 0644
[dynamic-template-kvm-resilient] [dynamic-template-kvm-resilient]
recipe = slapos.recipe.template:jinja2 recipe = slapos.recipe.template:jinja2
......
...@@ -90,7 +90,7 @@ command = ...@@ -90,7 +90,7 @@ command =
[template] [template]
recipe = slapos.recipe.template recipe = slapos.recipe.template
url = ${:_profile_base_location_}/instance.cfg.in url = ${:_profile_base_location_}/instance.cfg.in
md5sum = 5a17fc127190bbc19361c5ffb10711b3 md5sum = 2e3fba2f0f6483e62f19a8d2616554bc
output = ${buildout:directory}/template.cfg output = ${buildout:directory}/template.cfg
mode = 0644 mode = 0644
...@@ -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 = 0668791e78430bafdec5300b4ea8d90a md5sum = 602cdd2ed6d26d494f2dce697e8168d9
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