refs #2727 unify log messages
parent
32174016be
commit
7a878edf1d
267
api/repo_api.py
267
api/repo_api.py
|
@ -437,7 +437,7 @@ def check_remote_backup(image_name, remote_ip, remote_user, remote_path, job_id)
|
|||
def check_aux_files(image_file_path, job_id):
|
||||
""" Cada 10 segundos comprueba si se han creado todos los archivos auxiliares de la imagen que recibe como parámetro,
|
||||
en cuyo caso lo comunicará a ogCore, llamando a un endpoint, y dejará de realizar la comprobación.
|
||||
También obtiene el valor del archivo ".full.sum" (que corresonde al ID), y se lo comunica a ogCore.
|
||||
También obtiene el valor del archivo ".full.sum" (que corresponde al ID), y se lo comunica a ogCore.
|
||||
"""
|
||||
journal.send("Running function 'check_aux_files'...", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
|
||||
|
@ -719,21 +719,21 @@ def get_repo_status():
|
|||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script getRepoStatus.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": json.loads(result.stdout)
|
||||
"details": json.loads(result.stdout)
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'getRepoStatus.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script getRepoStatus.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'getRepoStatus.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script getRepoStatus.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -759,21 +759,21 @@ def get_repo_info():
|
|||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script getRepoInfo.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": json.loads(result.stdout)
|
||||
"details": json.loads(result.stdout)
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'getRepoInfo.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script getRepoInfo.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'getRepoInfo.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script getRepoInfo.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -796,10 +796,10 @@ def get_repo_image_info(imageId):
|
|||
cmd = ['python3', f"{script_path}/getRepoInfo.py", f"{param_dict['name']}.{param_dict['extension']}"]
|
||||
else:
|
||||
journal.send("Image not found", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint get_repo_image_info', 'desc': 'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint get_repo_image_info', 'desc': 'Warning: Image not found, id: {imageId} , name: {param_dict['name']}'}}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image not found"
|
||||
"details": f"Image not found: id: {imageId} , name: {param_dict['name']}"
|
||||
}), 400
|
||||
|
||||
try:
|
||||
|
@ -813,21 +813,21 @@ def get_repo_image_info(imageId):
|
|||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script getRepoInfo.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": json.loads(result.stdout)
|
||||
"details": json.loads(result.stdout)
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'getRepoInfo.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script getRepoInfo.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'getRepoInfo.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script getRepoInfo.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -853,14 +853,14 @@ def update_repo_info():
|
|||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script updateRepoInfo.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Repository info updated successfully"
|
||||
"details": "Repository info updated successfully"
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'updateRepoInfo.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script updateRepoInfo.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'updateRepoInfo.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
|
@ -868,7 +868,7 @@ def update_repo_info():
|
|||
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -895,7 +895,7 @@ def check_image(imageId):
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint check_image', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image not found (inexistent or deleted)"
|
||||
"details": f"Image {param_dict['name']} not found (inexistent or deleted)"
|
||||
}), 400
|
||||
|
||||
try:
|
||||
|
@ -910,26 +910,26 @@ def check_image(imageId):
|
|||
if "Error" in result.stdout:
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Image file didn't pass the Integrity Check"
|
||||
"details": f"Image {param_dict['name']} file didn't pass the Integrity Check"
|
||||
}), 200
|
||||
else:
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Image file passed the Integrity Check correctly"
|
||||
"details": f"Image {param_dict['name']} file passed the Integrity Check correctly"
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'checkImage.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script checkImage.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'checkImage.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script checkImage.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -961,14 +961,14 @@ def delete_image(imageId):
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint delete_image', 'desc':'Warning: Incorrect method (must be permanent or trash)'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Incorrect method (must be 'permanent' or 'trash')"
|
||||
"details": "Incorrect method (must be 'permanent' or 'trash')"
|
||||
}), 400
|
||||
else:
|
||||
journal.send("Image not found (inexistent or deleted)", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint delete_image', 'desc':'Warning: Image not found (inexistent or deleted)'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image not found (inexistent or deleted)"
|
||||
"details": f"Image {param_dict['name']} not found (inexistent or deleted)"
|
||||
}), 400
|
||||
|
||||
try:
|
||||
|
@ -982,21 +982,21 @@ def delete_image(imageId):
|
|||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script deleteImage.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Image deleted successfully"
|
||||
"details": f"Image {param_dict['name']} deleted successfully"
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'deleteImage.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script deleteImage.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'deleteImage.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script deleteImage.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1027,7 +1027,7 @@ def recover_image():
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint recover_image', 'desc':'Warning: Image not found (inexistent or recovered previously)'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image not found (inexistent or recovered previously)"
|
||||
"details": f"Image {param_dict['name']} not found (inexistent or recovered previously)"
|
||||
}), 400
|
||||
|
||||
try:
|
||||
|
@ -1041,21 +1041,21 @@ def recover_image():
|
|||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script recoverImage.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Image recovered successfully"
|
||||
"details": f"Image {param_dict['name']} recovered successfully"
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'recoverImage.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script recoverImage.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'recoverImage.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script recoverImage.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1081,7 +1081,7 @@ def delete_trash_image(imageId):
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint delete_trash_image', 'desc':'Warning: Image not found at trash'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image not found at trash"
|
||||
"details": f"Image {param_dict['name']} not found at trash"
|
||||
}), 400
|
||||
|
||||
try:
|
||||
|
@ -1095,21 +1095,21 @@ def delete_trash_image(imageId):
|
|||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script deleteTrashImage.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Image deleted successfully"
|
||||
"details": f"Image {param_dict['name']} deleted successfully"
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'deleteTrashImage.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script deleteTrashImage.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'deleteTrashImage.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script deleteTrashImage.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1138,7 +1138,7 @@ def import_image():
|
|||
journal.send("{'component':'ogRepo', 'severity':'ERROR', 'http_code':'400', 'operation':'Run endpoint import_image', 'desc':'Unable to connect to remote server'}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "Can't connect to remote server"
|
||||
"details": "Can't connect to remote server"
|
||||
}), 400
|
||||
|
||||
# Construimos la ruta de la imagen:
|
||||
|
@ -1151,14 +1151,14 @@ def import_image():
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint import_image', 'desc':'Warning: Remote image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "Remote image not found"
|
||||
"details": f"Remote image {image_name} not found"
|
||||
}), 400
|
||||
elif check_image == "Remote image is locked":
|
||||
journal.send("Remote image is locked", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint import_image', 'desc':'Warning: Remote image is locked'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "Remote image is locked"
|
||||
"details": f"Remote image {image_name} is locked"
|
||||
}), 400
|
||||
|
||||
# Construimos la llamada al script:
|
||||
|
@ -1186,7 +1186,7 @@ def import_image():
|
|||
# Informamos que la imagen se está importando, y salimos del endpoint:
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Importing image...",
|
||||
"details": f"Importing image {image_name}...",
|
||||
"job_id": job_id
|
||||
}), 200
|
||||
else:
|
||||
|
@ -1194,21 +1194,21 @@ def import_image():
|
|||
journal.send("{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script importImage.py', 'desc':'Result KO (Error: Image import failed)'}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image import failed"
|
||||
"details": f"Image {image_name} import failed"
|
||||
}), 500
|
||||
except subprocess.CalledProcessError as error:
|
||||
journal.send(f"Script 'importImage.py' result KO (Process Exception: {str(error)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script importImage.py', 'desc':'Result KO (Process Exception: {str(error)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"process exception": str(error)
|
||||
"details": str(error)
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'importImage.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script importImage.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1248,17 +1248,17 @@ def backup_image():
|
|||
# Si la imagen existe pero está bloqueada, devolvemos un error:
|
||||
if image_lock_exists == True:
|
||||
journal.send("Image is locked", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint backup_image', 'desc':'Warning: Image is locked'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint backup_image', 'desc':'Warning: Image {image_name} is locked'}}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "Image is locked"
|
||||
"details": f"Image {image_name} is locked"
|
||||
}), 400
|
||||
else:
|
||||
journal.send("Image not found", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint backup_image', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint backup_image', 'desc':'Warning: Image {image_name} not found'}}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image not found"
|
||||
"details": f"Image {image_name} not found"
|
||||
}), 400
|
||||
|
||||
# Comprobamos la conexión con el equipo remoto, y si falla salimos del endpoint, retornando un error:
|
||||
|
@ -1266,10 +1266,10 @@ def backup_image():
|
|||
|
||||
if connection_OK == False:
|
||||
journal.send("Can't connect to remote server", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'ERROR', 'http_code':'400', 'operation':'Run endpoint backup_image', 'desc':'Unable to connect to remote host'}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'400', 'operation':'Run endpoint backup_image', 'desc':'Unable to connect to remote host {remote_ip}'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "Can't connect to remote host"
|
||||
"details": f"Can't connect to remote host {remote_ip}"
|
||||
}), 400
|
||||
|
||||
# Construimos la llamada al script:
|
||||
|
@ -1296,29 +1296,29 @@ def backup_image():
|
|||
# Informamos que la imagen se está exportando, y salimos del endpoint:
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Making image backup...",
|
||||
"details": f"Making image backup {image_name} in repo {remote_ip}...",
|
||||
"job_id": job_id
|
||||
}), 200
|
||||
else:
|
||||
journal.send("Script 'backupImage.py' result KO (Backup image failed)", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script backupImage.py', 'desc':'Result KO (Backup image failed)'}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send(f"Script 'backupImage.py' result KO (Backup image failed)", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script backupImage.py', 'desc':'Result KO (Backup image {image_name} failed)'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Backup image failed"
|
||||
"details": f"Backup image {image_name} failed"
|
||||
}), 500
|
||||
except subprocess.CalledProcessError as error:
|
||||
journal.send(f"Script 'backupImage.py' result KO (Process Exception: {str(error)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script backupImage.py', 'desc':'Result KO (Process Exception: {str(error_)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script backupImage.py', 'desc':'Result KO (Process Exception: {str(error)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"process exception": str(error)
|
||||
"details": str(error)
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'backupImage.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script backupImage.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1346,7 +1346,7 @@ def create_torrent_sum():
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint create_torrent_sum', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": f"{repo_path}{image_name} Image not found"
|
||||
"details": f"{repo_path}{image_name} Image not found"
|
||||
}), 400
|
||||
|
||||
# Chequeamos que el archivo checked.info existe y si no existe devolvemos error y salimos del endpoint:
|
||||
|
@ -1355,7 +1355,7 @@ def create_torrent_sum():
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint create_torrent_sum', 'desc':'Warning: Checked info file not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": f"{repo_path}{image_name}.info.checked file not found"
|
||||
"details": f"{repo_path}{image_name}.info.checked file not found"
|
||||
}), 400
|
||||
|
||||
# Construimos la ruta de la imagen (relativa a "repo_path"):
|
||||
|
@ -1376,7 +1376,7 @@ def create_torrent_sum():
|
|||
# Evaluamos el resultado de la ejecución, y devolvemos una respuesta:
|
||||
if result.returncode is None:
|
||||
journal.send("Script 'createTorrentSum.py' result OK (ReturnCode: None)", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script createTorrentSum.py', 'desc':'Result OK (ReturnCode: None)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script createTorrentSum.py --> {cmd}', 'desc':'Result OK (ReturnCode: None)'}}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
# Si el resultado es correcto, llamamos a la función "check_aux_files" en un hilo paralelo
|
||||
# (para que compruebe si se han creado todos los archivos auxiliares exitosamente):
|
||||
journal.send("Calling function 'check_aux_files'...", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
|
@ -1385,7 +1385,7 @@ def create_torrent_sum():
|
|||
# Informamos que los archivos auxiliares se están creando, y salimos del endpoint:
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Creating auxiliar files...",
|
||||
"details": f"Creating auxiliar files for {image_name}...",
|
||||
"job_id": job_id
|
||||
}), 200
|
||||
else:
|
||||
|
@ -1393,14 +1393,14 @@ def create_torrent_sum():
|
|||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script createTorrentSum.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'createTorrentSum.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script createTorrentSum.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1428,24 +1428,24 @@ def send_wakeonlan():
|
|||
# Evaluamos el resultado de la ejecución, y devolvemos una respuesta:
|
||||
if result.returncode == 0:
|
||||
journal.send("Script 'sendWakeOnLan.py' result OK (ReturnCode: 0)", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script sendWakeOnLan.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'operation':'Run script sendWakeOnLan.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Wake On Lan packet sended successfully"
|
||||
"details": "Wake On Lan packet sended successfully"
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'sendWakeOnLan.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script sendWakeOnLan.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'sendWakeOnLan.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script sendWakeOnLan.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1481,7 +1481,7 @@ def send_udpcast():
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint send_udpcast', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image not found"
|
||||
"details": f"Image {param_dict['name']}.{param_dict['extension']} not found"
|
||||
}), 400
|
||||
|
||||
try:
|
||||
|
@ -1496,31 +1496,31 @@ def send_udpcast():
|
|||
# Evaluamos el resultado de la ejecución, y devolvemos una respuesta:
|
||||
if result.returncode is None and process_running == True:
|
||||
journal.send("Script 'sendFileMcast.py' result OK (ReturnCode: None), and process running", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script sendFileMcast.py', 'desc':'Result OK (ReturnCode: None), and process running'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'operation':'Run script sendFileMcast.py', 'desc':'Result OK (ReturnCode: None), and process running'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Sending image..."
|
||||
"details": f"Sending image {param_dict['name']}.{param_dict['extension']}..."
|
||||
}), 200
|
||||
else:
|
||||
journal.send("Script 'sendFileMcast.py' result KO (Image send failed)", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script sendFileMcast.py', 'desc':'Result KO (Image send failed)'}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image send failed"
|
||||
"details": f"Image {param_dict['name']}.{param_dict['extension']} send failed"
|
||||
}), 500
|
||||
except subprocess.CalledProcessError as error:
|
||||
journal.send(f"Script 'sendFileMcast.py' result KO (Process Exception: {str(error)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script sendFileMcast.py', 'desc':'Result KO (Process Exception: {str(error)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"process exeption": str(error)
|
||||
"details": str(error)
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'sendFileMcast.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script sendFileMcast.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1554,7 +1554,7 @@ def send_uftp():
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint send_uftp', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image not found"
|
||||
"details": f"Image {param_dict['name']}.{param_dict['extension']} not found"
|
||||
}), 400
|
||||
|
||||
try:
|
||||
|
@ -1569,31 +1569,31 @@ def send_uftp():
|
|||
# Evaluamos el resultado de la ejecución, y devolvemos una respuesta:
|
||||
if result.returncode is None and process_running == True:
|
||||
journal.send("Script 'sendFileUFTP.py' result OK (ReturnCode: None), and process running", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script sendFileUFTP.py', 'desc':'Result OK (ReturnCode: None), and process running'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'operation':'Run script sendFileUFTP.py', 'desc':'Result OK (ReturnCode: None), and process running'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Sending image..."
|
||||
"details": f"Sending image {param_dict['name']}.{param_dict['extension']}..."
|
||||
}), 200
|
||||
else:
|
||||
journal.send("Script 'sendFileUFTP.py' result KO (Image send failed)", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script sendFileUFTP.py', 'desc':'Result KO (Image send failed)'}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image send failed"
|
||||
"details": f"Image {param_dict['name']}.{param_dict['extension']} send failed"
|
||||
}), 500
|
||||
except subprocess.CalledProcessError as error:
|
||||
journal.send(f"Script 'sendFileUFTP.py' result KO (Process Exception: {str(error)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script sendFileUFTP.py', 'desc':'Result KO (Process Exception: {str(error)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"process exeption": str(error)
|
||||
"details": str(error)
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'sendFileUFTP.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script sendFileUFTP.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1624,7 +1624,7 @@ def send_p2p():
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint send_p2p', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image not found"
|
||||
"details": f"Image {param_dict['name']}.{param_dict['extension']} not found"
|
||||
}), 400
|
||||
|
||||
# Comprobamos si el tracker esta ejecutandose, si no lo esta devolevemos un error y salimos del endpoint:
|
||||
|
@ -1635,7 +1635,7 @@ def send_p2p():
|
|||
error_message = "Tracker not running. Check if the tracker is installed and configured correctly."
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": error_message
|
||||
"details": error_message
|
||||
}), 500
|
||||
|
||||
# Ejecutamos los scripts "runTorrentSeeder.py", que no reciben parámetros.
|
||||
|
@ -1655,7 +1655,7 @@ def send_p2p():
|
|||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script runTorrentSeeder.py', 'desc':'Results OK (ReturnCodes: None), and processes running'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Tracker and Seeder serving image correctly"
|
||||
"details": "Tracker and Seeder serving image correctly"
|
||||
}), 200
|
||||
else:
|
||||
journal.send("Script 'runTorrentSeeder.py' results KO (Seeder not runnig)", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
|
@ -1664,7 +1664,7 @@ def send_p2p():
|
|||
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": error_message
|
||||
"details": error_message
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1689,17 +1689,17 @@ def get_udpcast_info():
|
|||
# Evaluamos el resultado de la ejecución, y devolvemos la respuesta:
|
||||
if result.returncode == 0:
|
||||
journal.send("Script 'getUDPcastInfo.py' result OK (ReturnCode: 0)", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script getUDPcastInfo.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'operation':'Run script getUDPcastInfo.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": json.loads(result.stdout)
|
||||
"details": json.loads(result.stdout)
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'getUDPcastInfo.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script getUDPcastInfo.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
if "exit status 1" in str(error_description):
|
||||
|
@ -1707,14 +1707,14 @@ def get_udpcast_info():
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run script getUDPcastInfo.py', 'desc':'Warning: No UDPcast active transmissions'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "No UDPCast active transmissions"
|
||||
"details": "No UDPCast active transmissions"
|
||||
}), 400
|
||||
else:
|
||||
journal.send(f"Script 'getUDPcastInfo.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script getUDPcastInfo.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1738,17 +1738,17 @@ def get_uftp_info():
|
|||
# Evaluamos el resultado de la ejecución, y devolvemos la respuesta:
|
||||
if result.returncode == 0:
|
||||
journal.send("Script 'getUFTPInfo.py' result OK (ReturnCode: 0)", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script getUFTPInfo.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'operation':'Run script getUFTPInfo.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": json.loads(result.stdout)
|
||||
"details": json.loads(result.stdout)
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'getUFTPInfo.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script getUFTPInfo.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
if "exit status 1" in str(error_description):
|
||||
|
@ -1756,14 +1756,14 @@ def get_uftp_info():
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run script getUFTPInfo.py', 'desc':'Warning: No UFTP active transmissions'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "No UFTP active transmissions"
|
||||
"details": "No UFTP active transmissions"
|
||||
}), 400
|
||||
else:
|
||||
journal.send(f"Script 'getUFTPInfo.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script getUFTPInfo.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1789,7 +1789,7 @@ def stop_udpcast(imageId):
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint stop_udpcast', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image not found"
|
||||
"details": "Image not found"
|
||||
}), 400
|
||||
|
||||
try:
|
||||
|
@ -1800,17 +1800,17 @@ def stop_udpcast(imageId):
|
|||
# Evaluamos el resultado de la ejecución, y devolvemos una respuesta:
|
||||
if result.returncode == 0:
|
||||
journal.send("Script 'stopUDPcast.py' result OK (ReturnCode: 0)", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script stopUDPcast.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'operation':'Run script stopUDPcast.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Image transmission canceled successfully"
|
||||
"details": "Image transmission canceled successfully"
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'stopUDPcast.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script stopUDPcast.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
if "exit status 3" in str(error_description):
|
||||
|
@ -1818,28 +1818,28 @@ def stop_udpcast(imageId):
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run script stopUDPcast.py', 'desc':'Warning: No UDPCast active transmissions for specified image'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "No UDPCast active transmissions for specified image"
|
||||
"details": "No UDPCast active transmissions for specified image"
|
||||
}), 400
|
||||
elif "exit status 4" in str(error_description):
|
||||
journal.send("Script 'stopUDPcast.py' result KO (Unexpected error checking UDPcast transmissions)", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script stopUDPcast.py', 'desc':'Result KO (Unexpected error checking UDPcast transmissions)'}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "Unexpected error checking UDPcast transmissions"
|
||||
"details": "Unexpected error checking UDPcast transmissions"
|
||||
}), 500
|
||||
elif "exit status 5" in str(error_description):
|
||||
journal.send("Script 'stopUDPcast.py' result KO (Unexpected error finalizing UDPcast transmission)", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script stopUDPcast.py', 'desc':'Result KO (Unexpected error finalizing UDPcast transmission)'}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "Unexpected error finalizing UDPcast transmission"
|
||||
"details": "Unexpected error finalizing UDPcast transmission"
|
||||
}), 500
|
||||
else:
|
||||
journal.send(f"Script 'stopUDPcast.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script stopUDPcast.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1865,7 +1865,7 @@ def stop_uftp(imageId):
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint stop_uftp', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image not found"
|
||||
"details": "Image not found"
|
||||
}), 400
|
||||
|
||||
try:
|
||||
|
@ -1876,17 +1876,17 @@ def stop_uftp(imageId):
|
|||
# Evaluamos el resultado de la ejecución, y devolvemos una respuesta:
|
||||
if result.returncode == 0:
|
||||
journal.send("Script 'stopUFTP.py' result OK (ReturnCode: 0)", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script stopUFTP.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'operation':'Run script stopUFTP.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Image transmission canceled successfully"
|
||||
"details": "Image transmission canceled successfully"
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'stopUFTP.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script stopUFTP.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
if "exit status 3" in str(error_description):
|
||||
|
@ -1894,28 +1894,28 @@ def stop_uftp(imageId):
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run script stopUFTP.py', 'desc':'Warning: No UFTP active transmissions for specified image'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "No UFTP active transmissions for specified image"
|
||||
"details": "No UFTP active transmissions for specified image"
|
||||
}), 400
|
||||
elif "exit status 4" in str(error_description):
|
||||
journal.send("Script 'stopUFTP.py' result KO (Unexpected error checking UFTP transmissions)", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script stopUFTP.py', 'desc':'Result KO (Unexpected error checking UFTP transmissions)'}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "Unexpected error checking UFTP transmissions"
|
||||
"details": "Unexpected error checking UFTP transmissions"
|
||||
}), 500
|
||||
elif "exit status 5" in str(error_description):
|
||||
journal.send("Script 'stopUFTP.py' result KO (Unexpected error finalizing UFTP transmission)", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script stopUFTP.py', 'desc':'Result KO (Unexpected error finalizing UFTP transmission)'}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "Unexpected error finalizing UFTP transmission"
|
||||
"details": "Unexpected error finalizing UFTP transmission"
|
||||
}), 500
|
||||
else:
|
||||
journal.send(f"Script 'stopUFTP.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script stopUFTP.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1938,24 +1938,24 @@ def stop_p2p():
|
|||
# Evaluamos el resultado de la ejecución, y devolvemos la respuesta:
|
||||
if result.returncode == 0:
|
||||
journal.send("Script 'stopP2P.py' result OK (ReturnCode: 0)", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script stopP2P.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'operation':'Run script stopP2P.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "P2P transmissions canceled successfully"
|
||||
"details": "P2P transmissions canceled successfully"
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'stopP2P.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script stopP2P.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'stopP2P.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script stopP2P.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -1985,10 +1985,10 @@ def convert_virtual_image():
|
|||
# Si la imagen virtual no existe, devolvemos un error:
|
||||
if vm_image_exists == False:
|
||||
journal.send("Virtual image not found", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint convert_virtual_image', 'desc':'Warning: Virtual image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint convert_virtual_image', 'desc':'Warning: Virtual image {vm_image_name_full} not found'}}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "Virtual image not found"
|
||||
"details": f"Virtual image {vm_image_name_full} not found"
|
||||
}), 400
|
||||
|
||||
# Comprobamos si ya existe una imagen "img" con el mismo nombre que la imagen virtual, llamando a la función "check_file_exists":
|
||||
|
@ -1997,10 +1997,10 @@ def convert_virtual_image():
|
|||
# Si existe una imagen con el mismo nombre que la imagen virtual (salvo por la extensión), devolvemos un error:
|
||||
if img_image_exists == True:
|
||||
journal.send("There is an image with the same name as the virtual image", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint convert_virtual_image', 'desc':'Warning: There is an image with the same name as the virtual image'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint convert_virtual_image', 'desc':'Warning: There is an image with the same name as the virtual image --> {vm_image_name_full}'}}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "There is an image with the same name as the virtual image"
|
||||
"details": f"There is an image with the same name as the virtual image: {vm_image_name_full}"
|
||||
}), 400
|
||||
|
||||
# Comprobamos si hay espacio suficiente en disco para convertir la imagen virtual (4 veces su tamaño):
|
||||
|
@ -2012,7 +2012,7 @@ def convert_virtual_image():
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint convert_virtual_image', 'desc':'Warning: There is not enough free disk space'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "There is not enough free disk space"
|
||||
"details": "There is not enough free disk space"
|
||||
}), 400
|
||||
|
||||
# Construimos la llamada al script:
|
||||
|
@ -2040,7 +2040,7 @@ def convert_virtual_image():
|
|||
# Informamos que la imagen se está convirtiendo, y salimos del endpoint:
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Converting virtual image...",
|
||||
"details": "Converting virtual image...",
|
||||
"job_id": job_id
|
||||
}), 200
|
||||
else:
|
||||
|
@ -2048,21 +2048,21 @@ def convert_virtual_image():
|
|||
journal.send("{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script convertVMtoIMG.py', 'desc':'Result KO (Error: Virtual image conversion failed)'}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Virtual image conversion failed"
|
||||
"details": f"Virtual image conversion failed"
|
||||
}), 500
|
||||
except subprocess.CalledProcessError as error:
|
||||
journal.send(f"Script 'convertVMtoIMG.py' result KO (Process Exception: {str(error)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script convertVMtoIMG.py', 'desc':'Result KO (Process Exception: {str(error)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"process exception": str(error)
|
||||
"details": str(error)
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'convertVMtoIMG.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script convertVMtoIMG.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -2093,10 +2093,10 @@ def convert_image_to_virtual():
|
|||
cmd = ['python3', f"{script_path}/convertIMGtoVM.py", image_name_full, vm_extension]
|
||||
else:
|
||||
journal.send("Image not found", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint convert_image_to_virtual', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint convert_image_to_virtual', 'desc':'Warning: Image {image_name_full} not found'}}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image not found"
|
||||
"details": f"Image {image_name_full} not found"
|
||||
}), 400
|
||||
|
||||
# Comprobamos si ya existe una imagen virtual exportada con el mismo nombre que la imagen "img" y la extensión especificada, llamando a la función "check_file_exists":
|
||||
|
@ -2105,10 +2105,10 @@ def convert_image_to_virtual():
|
|||
# Si existe una imagen con el mismo nombre que la imagen virtual (salvo por la extensión), devolvemos un error:
|
||||
if vm_image_exists == True:
|
||||
journal.send("There is an exported virtual image with the same name as the image", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint convert_image_to_virtual', 'desc':'Warning: There is an exported virtual image with the same name as the image'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint convert_image_to_virtual', 'desc':'Warning: There is an exported virtual image with the same name as the image: {image_name_full}'}}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "There is an exported virtual image with the same name as the image"
|
||||
"details": f"There is an exported virtual image with the same name as the image: {image_name_full}"
|
||||
}), 400
|
||||
|
||||
# Comprobamos si hay espacio suficiente en disco para convertir la imagen "img" a virtual (4 veces su tamaño):
|
||||
|
@ -2120,7 +2120,7 @@ def convert_image_to_virtual():
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint convert_image_to_virtual', 'desc':'Warning: There is not enough free disk space'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "There is not enough free disk space"
|
||||
"details": "There is not enough free disk space"
|
||||
}), 400
|
||||
|
||||
try:
|
||||
|
@ -2145,7 +2145,7 @@ def convert_image_to_virtual():
|
|||
# Informamos que la imagen se está convirtiendo, y salimos del endpoint:
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Converting image to virtual...",
|
||||
"details": "Converting image to virtual...",
|
||||
"job_id": job_id
|
||||
}), 200
|
||||
else:
|
||||
|
@ -2153,21 +2153,21 @@ def convert_image_to_virtual():
|
|||
journal.send("{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script convertIMGtoVM.py', 'desc':'Result KO (Error: Image conversion to virtual failed)'}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image conversion to virtual failed"
|
||||
"details": f"Image conversion to virtual failed"
|
||||
}), 500
|
||||
except subprocess.CalledProcessError as error:
|
||||
journal.send(f"Script 'convertIMGtoVM.py' result KO (Process Exception: {str(error)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script convertIMGtoVM.py', 'desc':'Result KO (Process Exception: {str(error)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"process exception": str(error)
|
||||
"details": str(error)
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'convertIMGtoVM.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script convertIMGtoVM.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -2199,7 +2199,7 @@ def rename_image():
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint rename_image', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": "Image not found"
|
||||
"details": f"Image {image_original_name} not found"
|
||||
}), 400
|
||||
|
||||
# Comprobamos si ya existe una imagen con el mismo nombre que se quiere asignar, llamando a la función "check_file_exists":
|
||||
|
@ -2211,7 +2211,7 @@ def rename_image():
|
|||
journal.send("{'component':'ogRepo', 'severity':'WARNING', 'http_code':'400', 'operation':'Run endpoint convert_image_to_virtual', 'desc':'Warning: There is an image with the name to assign'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": "There is an image with the name to assign"
|
||||
"details": f"There is an image with the name {image_new_name} to assign"
|
||||
}), 400
|
||||
|
||||
try:
|
||||
|
@ -2225,21 +2225,21 @@ def rename_image():
|
|||
journal.send("{'component':'ogRepo', 'severity':'INFO', 'http_code':'200', 'operation':'Run script renameImage.py', 'desc':'Result OK (ReturnCode: 0)'}", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": True,
|
||||
"output": "Image renamed successfully"
|
||||
"details": f"Image {image_original_name} renamed successfully"
|
||||
}), 200
|
||||
else:
|
||||
journal.send(f"Script 'renameImage.py' result KO (Error: {result.stderr})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script renameImage.py', 'desc':'Result KO (Error: {result.stderr})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"error": result.stderr
|
||||
"details": result.stderr
|
||||
}), 500
|
||||
except Exception as error_description:
|
||||
journal.send(f"Script 'renameImage.py' result KO (Exception: {str(error_description)})", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"{{'component':'ogRepo', 'severity':'ERROR', 'http_code':'500', 'operation':'Run script renameImage.py', 'desc':'Result KO (Exception: {str(error_description)})'}}", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api")
|
||||
return jsonify({
|
||||
"success": False,
|
||||
"exception": str(error_description)
|
||||
"details": str(error_description)
|
||||
}), 500
|
||||
|
||||
|
||||
|
@ -2557,13 +2557,12 @@ def git_get_branches(repo):
|
|||
"""
|
||||
repo_path = os.path.join(REPOSITORIES_BASE_PATH, OGGIT_USER, repo + ".git")
|
||||
if not os.path.isdir(repo_path):
|
||||
journal.send(f"Can't list repositories. Repository storage at {REPOSITORIES_BASE_PATH} not found", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
journal.send(f"Can't create branch. Repository storage at {REPOSITORIES_BASE_PATH} not found", PRIORITY=journal.LOG_ERR, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
||||
return jsonify({"error": "Repository not found"}), 404
|
||||
|
||||
git_repo = git.Repo(repo_path)
|
||||
git_repo.git.config('--global', '--add', 'safe.directory', repo_path)
|
||||
|
||||
|
||||
branches = []
|
||||
for branch in git_repo.branches:
|
||||
branches = branches + [branch.name]
|
||||
|
|
Loading…
Reference in New Issue