Commit ecefc35a authored by Marco Mariani's avatar Marco Mariani

rewritten enable_bridge() to set create_tap

parent e66208b9
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
from optparse import OptionParser, Option from optparse import OptionParser, Option
import ConfigParser, os import ConfigParser, os
import pkg_resources import pkg_resources
from shutil import move import re
import socket import socket
from subprocess import call as subprocessCall from subprocess import call as subprocessCall
import sys import sys
...@@ -159,22 +159,16 @@ def get_computer_name(slapos_configuration): ...@@ -159,22 +159,16 @@ def get_computer_name(slapos_configuration):
return socket.gethostname() return socket.gethostname()
def enable_bridge(slapos_configuration): def enable_bridge(slapos_configuration):
#Create temp file # we don't use ConfigParser here, as it would remove comments
slapos_old_path = os.path.join(slapos_configuration,'slapos.cfg') slapos_cfg_path = os.path.join(slapos_configuration, 'slapos.cfg')
slapos_new_path = os.path.join(slapos_configuration,'slapos.cfg.tmp') lines = []
slapos_new = open(slapos_new_path,'w') for line in open(slapos_cfg_path):
slapos_old = open(slapos_old_path) if re.match('^create_tap *=', line):
for line in slapos_old: line = 'create_tap = true\n'
slapos_new.write(line.replace("create_tap = false", "#create_tap = false")) lines.append(line)
#close temp file with open(slapos_cfg_path, 'w') as fout:
slapos_new.close() fout.writelines(lines)
slapos_old.close()
#Remove original file
os.remove(slapos_old_path)
#Move new file
move(slapos_new_path, slapos_old_path)
# Function to get ssh key # Function to get ssh key
......
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