Commit 2a20eae9 authored by Philip ABBET's avatar Philip ABBET
Browse files

Update 'db index' to the latest version of beat.core

parent 8d56fb28
......@@ -245,8 +245,7 @@ def index_output(configuration, names, ls, delete, checksum, uid, db_root):
protocols = [protocol_filter]
if not (ls or delete or checksum): #we're indexing
host = dock.Host()
host.setup(raise_on_errors=False)
host = dock.Host(raise_on_errors=False)
for protocol_name in protocols:
......@@ -279,7 +278,7 @@ def index_output(configuration, names, ls, delete, checksum, uid, db_root):
input_list.add(input_group)
db_configuration = {
'inputs': {},
'inputs': {},
'channel': set_name,
}
......@@ -294,7 +293,7 @@ def index_output(configuration, names, ls, delete, checksum, uid, db_root):
input_group.add(input)
db_configuration['inputs'][output_name] = dict(
database=db_name,
database=db_name,
protocol=protocol_name,
set=set_name,
output=output_name,
......@@ -332,30 +331,27 @@ def index_output(configuration, names, ls, delete, checksum, uid, db_root):
db_name,
", ".join(host.db_environments.keys())))
tmp_dir = os.path.join('/tmp', os.path.basename(db_tempdir))
db_cmd = ['databases_provider', db_address, tmp_dir]
volumes = {}
if db_root is None:
volumes[database_path] = {
'bind': os.path.join('/databases', db_name),
'mode': 'ro',
}
# Creation of the container
# Note: we only support one databases image loaded at the same time
db_cmd = [
'databases_provider',
db_address,
os.path.join('/tmp', os.path.basename(db_tempdir))
]
databases_container = host.create_container(db_envkey, db_cmd)
databases_container.copy_path(db_tempdir, '/tmp')
# Specify the volumes to mount inside the container
if not db_configuration.has_key('datasets_root_path'):
databases_container.add_volume(database_path, os.path.join('/databases', db_name))
else:
volumes[db_root] = {
'bind': db_root,
'mode': 'ro',
}
databases_container.add_volume(db_configuration['datasets_root_path'],
db_configuration['datasets_root_path'])
# Start the container
host.start(databases_container)
# Note: we only support one databases image loaded at the same time
db_process = dock.Popen(
host,
db_envkey,
command=db_cmd,
tmp_archive=db_tempdir,
volumes=volumes
)
index_filenames = []
previous_data_indices = []
......@@ -409,7 +405,6 @@ def index_output(configuration, names, ls, delete, checksum, uid, db_root):
with open(lock_filename, 'a'): os.utime(lock_filename, None)
if not (ls or delete or checksum): #we're indexing
try:
while input_group.hasMoreData():
......@@ -440,9 +435,8 @@ def index_output(configuration, names, ls, delete, checksum, uid, db_root):
continue
if not (ls or delete or checksum): #we're indexing
db_process.kill()
db_process.wait()
db_process.rm()
host.kill(databases_container)
host.wait(databases_container)
db_socket.setsockopt(zmq.LINGER, 0)
db_socket.close()
......
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