Skip to content
Snippets Groups Projects
Commit 43a72c52 authored by Idriss Larbi's avatar Idriss Larbi
Browse files

Merge branch 'fix/atresys/logical-library-queues' into 'master'

Fix/atresys/logical library queues

See merge request cta/cta-operations-utilities!56
parents 7451f800 b5ee7ef2
No related branches found
No related tags found
No related merge requests found
......@@ -141,6 +141,7 @@ def get_max_drives_per_ll(per:int=20):
def get_current_repacks_per_ll(repacks:list[repack_utils.Repack],db_connection):
c = {}
for repack in repacks:
# Get tape logical library
cmd = f"{tapeadmin.cta_admin_json_tape_ls_vid} {repack.vid}"
cta_adm_call = cmd_utils.run_cmd(
cmd, number_of_attempts=2, timeout=10, logger=logger
......@@ -157,9 +158,29 @@ def get_current_repacks_per_ll(repacks:list[repack_utils.Repack],db_connection):
"Not found in CTA catalogue"
)
continue
ll = json.loads(cta_adm_call.stdout)[0]['logicalLibrary']
c[ll] = c[ll]+1 if ll in c else 1
# Get number of retrieved files for this repack
cmd = f"{tapeadmin.cta_admin_json_repack_ls_vid} {repack.vid}"
cta_adm_call = cmd_utils.run_cmd(
cmd, number_of_attempts=2, timeout=10, logger=logger
)
if cta_adm_call.returncode == 1:
log_utils.log_and_exit(
logger=logger, msg=f"Error during command execution: {cmd}"
)
elif cta_adm_call.returncode > 1 or not json.loads(cta_adm_call.stdout):
repack.declare_problematic(
db_connection,
config,
logger,
"Not found in CTA object store"
)
continue
cta_repack = json.loads(cta_adm_call.stdout)[0]
if int(cta_repack["totalFilesToRetrieve"]) == int(cta_repack["retrievedFiles"]):
c[ll] = c[ll]+1 if ll in c else 1
return c
......
......@@ -172,7 +172,19 @@ def add_repack_manager_log_entry(args):
out_dict['timestamp'] = timestamp
out_dict['command'] = cmd
out_dict['host'] = os.uname()[1]
ls_logger.info(out_dict)
# Get tape logical library
cmd = f"{tapeadmin.cta_admin_json_tape_ls_vid} {repack['tape']}"
cta_adm_call = cmd_utils.run_cmd(
cmd, number_of_attempts=2, timeout=10, logger=logger
)
if cta_adm_call.returncode != 0 or not json.loads(cta_adm_call.stdout):
logger.error(f"Not able to find tape {repack['tape']} in CTA catalogue")
out_dict["logicalLibrary"] = None
else:
out_dict["logicalLibrary"] = json.loads(cta_adm_call.stdout)[0]["logicalLibrary"]
ls_logger.info(json.dumps(out_dict))
def main():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment