Commit 7076f75c authored by Antoine Catton's avatar Antoine Catton

Switch to veth with slapos' bridge for lxc networking

parent 63166871
...@@ -21,5 +21,6 @@ def main(): ...@@ -21,5 +21,6 @@ def main():
partition_base_path = os.path.join(instance_root, partition_base_name) partition_base_path = os.path.join(instance_root, partition_base_name)
partition_list = ['%s%d' % (partition_base_path, i) partition_list = ['%s%d' % (partition_base_path, i)
for i in range(partition_amount)] for i in range(partition_amount)]
bridge_name = slapos_conf.get('slapformat', 'interface_name')
prepare.main(sr_directory, partition_list) prepare.main(sr_directory, partition_list, bridge_name)
...@@ -16,7 +16,7 @@ class SlapContainerError(Exception): ...@@ -16,7 +16,7 @@ class SlapContainerError(Exception):
def main(sr_directory, partition_list): def main(sr_directory, partition_list, bridge_name):
for partition_path in partition_list: for partition_path in partition_list:
slapcontainer_filename = os.path.join(partition_path, slapcontainer_filename = os.path.join(partition_path,
...@@ -34,7 +34,7 @@ def main(sr_directory, partition_list): ...@@ -34,7 +34,7 @@ def main(sr_directory, partition_list):
if requested_status == 'started': if requested_status == 'started':
if not created(partition_path, slapcontainer_conf): if not created(partition_path, slapcontainer_conf):
create(sr_directory, partition_path, create(sr_directory, partition_path,
slapcontainer_conf) slapcontainer_conf, bridge_name)
if status(sr_directory, partition_path) == 'stopped': if status(sr_directory, partition_path) == 'stopped':
start(sr_directory, partition_path) start(sr_directory, partition_path)
else: else:
...@@ -96,7 +96,7 @@ def extract_rootfs(partition_path, conf): ...@@ -96,7 +96,7 @@ def extract_rootfs(partition_path, conf):
def create(sr_directory, partition_path, conf): def create(sr_directory, partition_path, conf, bridge_name):
tmp_dir = conf.get('rootfs', 'tmp') tmp_dir = conf.get('rootfs', 'tmp')
rootfs_dir = conf.get('rootfs', 'directory') rootfs_dir = conf.get('rootfs', 'directory')
if os.path.exists(tmp_dir): if os.path.exists(tmp_dir):
...@@ -108,12 +108,10 @@ def create(sr_directory, partition_path, conf): ...@@ -108,12 +108,10 @@ def create(sr_directory, partition_path, conf):
lxc_filename = os.path.join(partition_path, 'config') lxc_filename = os.path.join(partition_path, 'config')
lxc = LXCConfig() lxc = LXCConfig()
lxc.utsname = os.path.basename(partition_path) lxc.utsname = os.path.basename(partition_path)
lxc.network.type = 'vlan' lxc.network.type = 'veth'
lxc.network.link = conf.get('network', 'interface') lxc.network.link = bridge_name
lxc.network.veth.pair = 'lxc%s' % conf.get('network', 'interface')
lxc.network.name = 'eth0' lxc.network.name = 'eth0'
# XXX: Hardcoded netmasks
lxc.network.ipv4 = '%s/32' % conf.get('network', 'ipv4')
lxc.network.ipv6 = '%s/128' % conf.get('network', 'ipv6')
lxc.network.flags = 'up' lxc.network.flags = 'up'
# XXX: Hardcoded stuff # XXX: Hardcoded stuff
lxc.tty = '4' lxc.tty = '4'
......
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