Commit 86893227 authored by Tomáš Peterka's avatar Tomáš Peterka

[format] Introduce create_tun config option (default false)

parent 8338ec42
...@@ -468,7 +468,7 @@ class Computer(object): ...@@ -468,7 +468,7 @@ class Computer(object):
user=user, user=user,
address_list=address_list, address_list=address_list,
tap=tap, tap=tap,
tun=tun, tun=tun if conf.create_tun else None,
external_storage_list=external_storage_list, external_storage_list=external_storage_list,
) )
...@@ -1278,6 +1278,7 @@ def parse_computer_definition(conf, definition_path): ...@@ -1278,6 +1278,7 @@ def parse_computer_definition(conf, definition_path):
ipv6_interface=conf.ipv6_interface, ipv6_interface=conf.ipv6_interface,
software_user=computer_definition.get('computer', 'software_user'), software_user=computer_definition.get('computer', 'software_user'),
tap_gateway_interface=conf.tap_gateway_interface, tap_gateway_interface=conf.tap_gateway_interface,
conf=conf
) )
partition_list = [] partition_list = []
for partition_number in range(int(conf.partition_amount)): for partition_number in range(int(conf.partition_amount)):
...@@ -1290,7 +1291,7 @@ def parse_computer_definition(conf, definition_path): ...@@ -1290,7 +1291,7 @@ def parse_computer_definition(conf, definition_path):
tap = Tap(computer_definition.get(section, 'network_interface')) tap = Tap(computer_definition.get(section, 'network_interface'))
tun = Tun("slaptun" + str(partition_number), tun = Tun("slaptun" + str(partition_number),
partition_number, partition_number,
int(conf.partition_amount)) if conf.create_tap else None int(conf.partition_amount)) if conf.create_tun else None
partition = Partition(reference=computer_definition.get(section, 'pathname'), partition = Partition(reference=computer_definition.get(section, 'pathname'),
path=os.path.join(conf.instance_root, path=os.path.join(conf.instance_root,
computer_definition.get(section, 'pathname')), computer_definition.get(section, 'pathname')),
...@@ -1356,7 +1357,7 @@ def parse_computer_xml(conf, xml_path): ...@@ -1356,7 +1357,7 @@ def parse_computer_xml(conf, xml_path):
user=User('%s%s' % (conf.user_base_name, i)), user=User('%s%s' % (conf.user_base_name, i)),
address_list=None, address_list=None,
tap=Tap('%s%s' % (conf.tap_base_name, i)), tap=Tap('%s%s' % (conf.tap_base_name, i)),
tun=Tun('slaptun' + str(i), i, partition_amount) tun=Tun('slaptun' + str(i), i, partition_amount) if conf.create_tun else None
) )
computer.partition_list.append(partition) computer.partition_list.append(partition)
...@@ -1437,6 +1438,7 @@ class FormatConfig(object): ...@@ -1437,6 +1438,7 @@ class FormatConfig(object):
alter_network = None alter_network = None
alter_user = None alter_user = None
create_tap = None create_tap = None
create_tun = None
computer_xml = None computer_xml = None
computer_json = None computer_json = None
input_definition_file = None input_definition_file = None
...@@ -1520,7 +1522,7 @@ class FormatConfig(object): ...@@ -1520,7 +1522,7 @@ class FormatConfig(object):
self.use_unique_local_address_block = False self.use_unique_local_address_block = False
# Convert strings to booleans # Convert strings to booleans
for option in ['alter_network', 'alter_user', 'create_tap', 'use_unique_local_address_block']: for option in ['alter_network', 'alter_user', 'create_tap', 'create_tun', 'use_unique_local_address_block']:
attr = getattr(self, option) attr = getattr(self, option)
if isinstance(attr, str): if isinstance(attr, str):
if attr.lower() == 'true': if attr.lower() == '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