Commit a8b082be authored by Antoine Catton's avatar Antoine Catton

Replace the bridge name in lxc.conf

parent 0c85687b
......@@ -50,6 +50,7 @@ def run(args):
partition_amount = slapos_conf.getint('slapformat', 'partition_amount')
partition_base_name = slapos_conf.get('slapformat', 'partition_base_name')
bridge_name = slapos_conf.get('slapformat', 'interface_name')
instance_root = slapos_conf.get('slapos', 'instance_root')
partition_base_path = os.path.join(instance_root, partition_base_name)
partition_list = ['%s%d' % (partition_base_path, i)
......@@ -59,7 +60,7 @@ def run(args):
database = gdbm.open(args.database, 'c', 0600)
try:
process.main(sr_directory, partition_list, database)
process.main(sr_directory, partition_list, database, bridge_name)
finally:
database.sync()
database.close()
......@@ -12,7 +12,7 @@ class SlapContainerError(Exception):
def main(sr_directory, partition_list, database):
def main(sr_directory, partition_list, database, bridge_name):
logger = logging.getLogger('process')
......@@ -38,6 +38,17 @@ def main(sr_directory, partition_list, database):
# XXX: Hardcoded path
lxc_conf_path = os.path.join(partition_path,
'etc/lxc.conf')
# XXX: Avoid hacking slapos.core
##########################################################
magic_string = '!!BRIDGE_NAME!!'
with open(lxc_conf_path, 'r') as lxc_conf_file:
lxc_conf_content = lxc_conf_file.read()
if magic_string in lxc_conf_content:
with open(lxc_conf_path, 'w') as lxc_conf_file:
lxc_conf_file.write(
lxc_conf_content.replace(magic_string, bridge_name)
)
##########################################################
with open(lxc_conf_path, 'r') as lxc_conf_file:
requested_status = lxc_conf_file.readline().strip(' \n\r\t#')
......
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