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,25 +26,30 @@ def main(sr_directory, partition_list): ...@@ -26,25 +26,30 @@ def main(sr_directory, partition_list):
lock.acquire(timeout=0) lock.acquire(timeout=0)
slapcontainer_conf = ConfigParser.ConfigParser() slapcontainer_conf = ConfigParser.ConfigParser()
slapcontainer_conf.read(slapcontainer_filename) slapcontainer_conf.read(slapcontainer_filename)
try:
requested_status = slapcontainer_conf.get('requested', 'status')
requested_status = slapcontainer_conf.get('requested',
if not slapcontainer_conf.has_section('current'): 'status')
slapcontainer_conf.add_section('current')
if not slapcontainer_conf.has_option('current', 'created'): if not slapcontainer_conf.has_section('current'):
slapcontainer_conf.set('current', 'created', 'no') slapcontainer_conf.add_section('current')
if not slapcontainer_conf.has_option('current', 'status'): if not slapcontainer_conf.has_option('current', 'created'):
slapcontainer_conf.set('current', 'status', 'stopped') slapcontainer_conf.set('current', 'created', 'no')
if not slapcontainer_conf.has_option('current', 'status'):
if requested_status == 'started': slapcontainer_conf.set('current', 'status', 'stopped')
start(sr_directory, partition_path,
slapcontainer_conf) if requested_status == 'started':
else: if slapcontainer_conf.get('current', 'created') == 'no':
stop(sr_directory, partition_path, create(sr_directory, partition_path, slapcontainer_conf)
slapcontainer_conf) slapcontainer_conf.set('current', 'created', 'yes')
start(sr_directory, partition_path,
with open(slapcontainer_filename, 'w') as slapcontainer_fp: slapcontainer_conf)
slapcontainer_conf.write(slapcontainer_fp) 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: except lockfile.LockTimeout:
# Can't do anything, we'll see on the next run # Can't do anything, we'll see on the next run
pass pass
...@@ -54,11 +59,6 @@ def main(sr_directory, partition_list): ...@@ -54,11 +59,6 @@ def main(sr_directory, partition_list):
def start(sr_directory, partition_path, conf): 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, lxc_start = os.path.join(sr_directory,
'parts/lxc/bin/lxc-start') 'parts/lxc/bin/lxc-start')
config_filename = os.path.join(partition_path, 'config') 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