Commit 1983cab4 authored by Antoine Catton's avatar Antoine Catton

Merge branch 'lxc'

parents b60d8335 5611378d
...@@ -38,6 +38,10 @@ def main(sr_directory, partition_list, database, bridge_name): ...@@ -38,6 +38,10 @@ def main(sr_directory, partition_list, database, bridge_name):
# XXX: Hardcoded path # XXX: Hardcoded path
lxc_conf_path = os.path.join(partition_path, lxc_conf_path = os.path.join(partition_path,
'etc/lxc.conf') 'etc/lxc.conf')
lxc_state_path = os.path.join(partition_path,
'.slapcontainer.state')
sib_state_path = os.path.join(partition_path,
'.shellinabox.state')
# XXX: Avoid hacking slapos.core # XXX: Avoid hacking slapos.core
########################################################## ##########################################################
magic_string = '!!BRIDGE_NAME!!' magic_string = '!!BRIDGE_NAME!!'
...@@ -61,7 +65,9 @@ def main(sr_directory, partition_list, database, bridge_name): ...@@ -61,7 +65,9 @@ def main(sr_directory, partition_list, database, bridge_name):
name=name, name=name,
database=database, database=database,
logger=partition_logger, logger=partition_logger,
lxc_conf_filename=lxc_conf_path) lxc_conf_filename=lxc_conf_path,
lxc_state_path=lxc_state_path,
sib_state_path=sib_state_path)
if start_requested: if start_requested:
logger.debug('Container which start was requested : %s.', logger.debug('Container which start was requested : %s.',
...@@ -126,7 +132,9 @@ def process_partition(requested_status, ...@@ -126,7 +132,9 @@ def process_partition(requested_status,
name, name,
database, database,
logger, logger,
lxc_conf_filename): lxc_conf_filename,
lxc_state_path,
sib_state_path):
if requested_status == 'started': if requested_status == 'started':
...@@ -143,6 +151,9 @@ def process_partition(requested_status, ...@@ -143,6 +151,9 @@ def process_partition(requested_status,
else: else:
current_status = 'stopped' current_status = 'stopped'
with open(lxc_state_path, 'w') as lxc_state_file:
lxc_state_file.write(current_status)
### If container is not launch, launch it ### If container is not launch, launch it
if requested_status != current_status: if requested_status != current_status:
logger.debug('Start lxc.') logger.debug('Start lxc.')
...@@ -162,6 +173,8 @@ def process_partition(requested_status, ...@@ -162,6 +173,8 @@ def process_partition(requested_status,
pid = int(database[name]) pid = int(database[name])
if is_pid_running(pid): if is_pid_running(pid):
current_status = 'started' current_status = 'started'
with open(sib_state_path, 'w') as sib_state_file:
sib_state_file.write(current_status)
if current_status == 'stopped': if current_status == 'stopped':
logger.debug('Start shellinabox.') logger.debug('Start shellinabox.')
......
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