Commit fa82cc5c authored by Alain Takoudjou's avatar Alain Takoudjou

kvm: set additional route to reach global ipv4 network

parent 2d79471e
...@@ -115,9 +115,13 @@ class Recipe: ...@@ -115,9 +115,13 @@ class Recipe:
cert_file = slap_connection.get('cert_file') cert_file = slap_connection.get('cert_file')
instance_root = self.buildout['buildout']['directory'] instance_root = self.buildout['buildout']['directory']
storage_configuration_dict = self.buildout.get('storage-configuration') storage_configuration_dict = self.buildout.get('storage-configuration')
network_dict = self.buildout.get('network-information')
storage_home = '' storage_home = ''
global_ipv4_network = ''
if storage_configuration_dict: if storage_configuration_dict:
storage_home = storage_configuration_dict.get('storage-home') storage_home = storage_configuration_dict.get('storage-home')
if network_dict:
global_ipv4_network = network_dict.get('global-ipv4-network')
slap.initializeConnection(server_url, key_file, cert_file) slap.initializeConnection(server_url, key_file, cert_file)
self.computer_partition = slap.registerComputerPartition( self.computer_partition = slap.registerComputerPartition(
computer_id, computer_id,
...@@ -173,6 +177,8 @@ class Recipe: ...@@ -173,6 +177,8 @@ class Recipe:
buildout.set('slap-network-information', 'tap-gateway', tap_gateway) buildout.set('slap-network-information', 'tap-gateway', tap_gateway)
buildout.set('slap-network-information', 'tap-netmask', tap_netmask) buildout.set('slap-network-information', 'tap-netmask', tap_netmask)
buildout.set('slap-network-information', 'tap-network', tap_network) buildout.set('slap-network-information', 'tap-network', tap_network)
buildout.set('slap-network-information', 'global-ipv4-network',
global_ipv4_network)
# Copy/paste slap_connection # Copy/paste slap_connection
buildout.add_section('slap-connection') buildout.add_section('slap-connection')
......
...@@ -85,7 +85,7 @@ command = ...@@ -85,7 +85,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 = d2413a9d4978092e939418748585bbb3 md5sum = 8debca5cccf4c365f8709523aa57e2fb
output = ${buildout:directory}/template.cfg output = ${buildout:directory}/template.cfg
mode = 0644 mode = 0644
...@@ -93,7 +93,7 @@ mode = 0644 ...@@ -93,7 +93,7 @@ mode = 0644
recipe = hexagonit.recipe.download recipe = hexagonit.recipe.download
url = ${:_profile_base_location_}/instance-kvm.cfg.jinja2 url = ${:_profile_base_location_}/instance-kvm.cfg.jinja2
mode = 644 mode = 644
md5sum = c8f69039aff15e20447c6e522267c152 md5sum = 8c736cf6b5768423224a1b0ea2a90349
download-only = true download-only = true
on-update = true on-update = true
......
...@@ -257,8 +257,13 @@ nat-rule-url-{{port}} = [${slap-network-information:global-ipv6}]:{{external_por ...@@ -257,8 +257,13 @@ nat-rule-url-{{port}} = [${slap-network-information:global-ipv6}]:{{external_por
{% if slapparameter_dict.get('use-tap', 'False') == 'True' and tap_network_dict.has_key('ipv4') -%} {% if slapparameter_dict.get('use-tap', 'False') == 'True' and tap_network_dict.has_key('ipv4') -%}
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 = ifconfig {{ iface }} ${slap-network-information:tap-ipv4} netmask ${slap-network-information:tap-netmask} 2_info = ifconfig {{ iface }} ${slap-network-information:tap-ipv4} netmask ${slap-network-information:tap-netmask}
3_info = route add -host ${slap-network-information:tap-gateway} dev {{ iface }} 3_info = route add ${slap-network-information:tap-gateway} dev {{ iface }}
4_info = route add -net ${slap-network-information:tap-network} netmask ${slap-network-information:tap-netmask} gw ${slap-network-information:tap-gateway} 4_info = route add -net ${slap-network-information:tap-network} netmask ${slap-network-information:tap-netmask} gw ${slap-network-information:tap-gateway}
{% if iface == 'eth0' -%}
5_info = route add default gw ${slap-network-information:tap-gateway}
{% elif global_ipv4_prefix -%}
5_info = ip route add {{ global_ipv4_prefix }} via ${slap-network-information:tap-gateway} dev {{ iface }} src ${slap-network-information:tap-ipv4}
{% endif -%}
{% endif -%} {% endif -%}
......
...@@ -27,6 +27,9 @@ pull-backup = ${template-pull-backup:output} ...@@ -27,6 +27,9 @@ pull-backup = ${template-pull-backup:output}
[storage-configuration] [storage-configuration]
storage-home = storage-home =
[network-information]
global-ipv4-network =
[slap-configuration] [slap-configuration]
recipe = slapos.cookbook:slapconfiguration.serialised recipe = slapos.cookbook:slapconfiguration.serialised
computer = $${slap-connection:computer-id} computer = $${slap-connection:computer-id}
...@@ -47,6 +50,7 @@ context = ...@@ -47,6 +50,7 @@ context =
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 tap_network_dict slap-configuration:tap-network-information-dict 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
...@@ -70,6 +74,7 @@ extensions = jinja2.ext.do ...@@ -70,6 +74,7 @@ extensions = jinja2.ext.do
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 global_ipv4_prefix network-information:global-ipv4-network
key slapparameter_dict slap-configuration:configuration key slapparameter_dict slap-configuration:configuration
key storage_dict slap-configuration:storage-dict key storage_dict slap-configuration:storage-dict
key tap_network_dict slap-configuration:tap-network-information-dict key tap_network_dict slap-configuration:tap-network-information-dict
......
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