Commit fd20a6d6 authored by Antoine Catton's avatar Antoine Catton

Don't create the container in the starting method

This way, once the container is created, even if slapcontainer
fail to start it ; slapcontainer_conf will be written.
parent 35b9ed2c
......@@ -26,8 +26,10 @@ def main(sr_directory, partition_list):
lock.acquire(timeout=0)
slapcontainer_conf = ConfigParser.ConfigParser()
slapcontainer_conf.read(slapcontainer_filename)
try:
requested_status = slapcontainer_conf.get('requested', 'status')
requested_status = slapcontainer_conf.get('requested',
'status')
if not slapcontainer_conf.has_section('current'):
slapcontainer_conf.add_section('current')
......@@ -37,12 +39,15 @@ def main(sr_directory, partition_list):
slapcontainer_conf.set('current', 'status', 'stopped')
if requested_status == 'started':
if slapcontainer_conf.get('current', 'created') == 'no':
create(sr_directory, partition_path, slapcontainer_conf)
slapcontainer_conf.set('current', 'created', 'yes')
start(sr_directory, partition_path,
slapcontainer_conf)
else:
stop(sr_directory, partition_path,
slapcontainer_conf)
finally:
with open(slapcontainer_filename, 'w') as slapcontainer_fp:
slapcontainer_conf.write(slapcontainer_fp)
except lockfile.LockTimeout:
......@@ -54,11 +59,6 @@ def main(sr_directory, partition_list):
def start(sr_directory, partition_path, conf):
if conf.get('current', 'created') == 'no':
create(sr_directory, partition_path, conf)
conf.set('current', 'created', 'yes')
lxc_start = os.path.join(sr_directory,
'parts/lxc/bin/lxc-start')
config_filename = os.path.join(partition_path, 'config')
......
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