|
|
|
@ -435,7 +435,7 @@ def get_repo_status():
|
|
|
|
|
try:
|
|
|
|
|
journal.send("Running script 'getRepoStatus.py'...", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
|
|
|
|
# Ejecutamos el script "getRepoStatus.py", y almacenamos el resultado:
|
|
|
|
|
result = subprocess.run(['sudo', 'python3', f"{script_path}/getRepoStatus.py"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF8')
|
|
|
|
|
result = subprocess.run(['python3', f"{script_path}/getRepoStatus.py"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF8')
|
|
|
|
|
|
|
|
|
|
# Evaluamos el resultado de la ejecución, y devolvemos la respuesta:
|
|
|
|
|
if result.returncode == 0:
|
|
|
|
@ -475,7 +475,7 @@ def get_repo_info():
|
|
|
|
|
try:
|
|
|
|
|
journal.send("Running script 'getRepoInfo.py'...", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
|
|
|
|
# Ejecutamos el script "getRepoInfo.py" (con el parámetro "all"), y almacenamos el resultado:
|
|
|
|
|
result = subprocess.run(['sudo', 'python3', f"{script_path}/getRepoInfo.py", 'all'], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF8')
|
|
|
|
|
result = subprocess.run(['python3', f"{script_path}/getRepoInfo.py", 'all'], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF8')
|
|
|
|
|
|
|
|
|
|
# Evaluamos el resultado de la ejecución, y devolvemos la respuesta:
|
|
|
|
|
if result.returncode == 0:
|
|
|
|
@ -517,7 +517,7 @@ def get_repo_image_info(imageId):
|
|
|
|
|
|
|
|
|
|
# Evaluamos los parámetros obtenidos, para construir la llamada al script, o para devover un error si no se ha encontrado la imagen:
|
|
|
|
|
if param_dict:
|
|
|
|
|
cmd = ['sudo', 'python3', f"{script_path}/getRepoInfo.py", f"{param_dict['name']}.{param_dict['extension']}"]
|
|
|
|
|
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")
|
|
|
|
@ -569,7 +569,7 @@ def update_repo_info():
|
|
|
|
|
try:
|
|
|
|
|
journal.send("Running script 'updateRepoInfo.py'...", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
|
|
|
|
# Ejecutamos el script "updateRepoInfo.py" (sin parámetros), y almacenamos el resultado:
|
|
|
|
|
result = subprocess.run(['sudo', 'python3', f"{script_path}/updateRepoInfo.py"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF8')
|
|
|
|
|
result = subprocess.run(['python3', f"{script_path}/updateRepoInfo.py"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF8')
|
|
|
|
|
|
|
|
|
|
# Evaluamos el resultado de la ejecución, y devolvemos una respuesta:
|
|
|
|
|
if result.returncode == 0:
|
|
|
|
@ -613,7 +613,7 @@ def check_image(imageId):
|
|
|
|
|
|
|
|
|
|
# Evaluamos los parámetros obtenidos, para construir la llamada al script, o para devover un error si no se ha encontrado la imagen:
|
|
|
|
|
if param_dict:
|
|
|
|
|
cmd = ['sudo', 'python3', f"{script_path}/checkImage.py", f"{param_dict['name']}.{param_dict['extension']}"]
|
|
|
|
|
cmd = ['python3', f"{script_path}/checkImage.py", f"{param_dict['name']}.{param_dict['extension']}"]
|
|
|
|
|
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 check_image', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
|
|
|
@ -677,9 +677,9 @@ def delete_image(imageId):
|
|
|
|
|
# Evaluamos los parámetros obtenidos, para construir la llamada al script, o para devover un error si no se ha encontrado la imagen:
|
|
|
|
|
if param_dict:
|
|
|
|
|
if method == "permanent":
|
|
|
|
|
cmd = ['sudo', 'python3', f"{script_path}/deleteImage.py", f"{param_dict['name']}.{param_dict['extension']}", '-p']
|
|
|
|
|
cmd = ['python3', f"{script_path}/deleteImage.py", f"{param_dict['name']}.{param_dict['extension']}", '-p']
|
|
|
|
|
elif method == "trash":
|
|
|
|
|
cmd = ['sudo', 'python3', f"{script_path}/deleteImage.py", f"{param_dict['name']}.{param_dict['extension']}"]
|
|
|
|
|
cmd = ['python3', f"{script_path}/deleteImage.py", f"{param_dict['name']}.{param_dict['extension']}"]
|
|
|
|
|
else:
|
|
|
|
|
journal.send("Incorrect method (must be 'permanent' or 'trash')", 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: Incorrect method (must be permanent or trash)'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
|
|
|
@ -745,7 +745,7 @@ def recover_image():
|
|
|
|
|
|
|
|
|
|
# Evaluamos los parámetros obtenidos, para construir la llamada al script, o para devover un error si no se ha encontrado la imagen:
|
|
|
|
|
if param_dict:
|
|
|
|
|
cmd = ['sudo', 'python3', f"{script_path}/recoverImage.py", f"{param_dict['name']}.{param_dict['extension']}"]
|
|
|
|
|
cmd = ['python3', f"{script_path}/recoverImage.py", f"{param_dict['name']}.{param_dict['extension']}"]
|
|
|
|
|
else:
|
|
|
|
|
journal.send("Image not found (inexistent or recovered previously)", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
|
|
|
|
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")
|
|
|
|
@ -799,7 +799,7 @@ def delete_trash_image(imageId):
|
|
|
|
|
|
|
|
|
|
# Evaluamos los parámetros obtenidos, para construir la llamada al script, o para devover un error si no se ha encontrado la imagen:
|
|
|
|
|
if param_dict:
|
|
|
|
|
cmd = ['sudo', 'python3', f"{script_path}/deleteTrashImage.py", f"{param_dict['name']}.{param_dict['extension']}"]
|
|
|
|
|
cmd = ['python3', f"{script_path}/deleteTrashImage.py", f"{param_dict['name']}.{param_dict['extension']}"]
|
|
|
|
|
else:
|
|
|
|
|
journal.send("Image not found at trash", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
|
|
|
|
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")
|
|
|
|
@ -1080,7 +1080,7 @@ def create_torrent_sum():
|
|
|
|
|
image_file_path = image_name
|
|
|
|
|
|
|
|
|
|
# Construimos la llamada al script:
|
|
|
|
|
cmd = ['sudo', 'python3', f"{script_path}/createTorrentSum.py", image_file_path]
|
|
|
|
|
cmd = ['python3', f"{script_path}/createTorrentSum.py", image_file_path]
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
journal.send("Running script 'createTorrentSum.py'...", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
|
|
|
@ -1156,7 +1156,7 @@ def send_wakeonlan():
|
|
|
|
|
try:
|
|
|
|
|
journal.send("Running script 'sendWakeOnLan.py'...", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
|
|
|
|
# Ejecutamos el script "sendWakeOnLan.py" (con los parámetros almacenados), y almacenamos el resultado:
|
|
|
|
|
result = subprocess.run(['sudo', 'python3', f"{script_path}/sendWakeOnLan.py", broadcast_ip, mac], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF8')
|
|
|
|
|
result = subprocess.run(['python3', f"{script_path}/sendWakeOnLan.py", broadcast_ip, mac], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF8')
|
|
|
|
|
|
|
|
|
|
# Evaluamos el resultado de la ejecución, y devolvemos una respuesta:
|
|
|
|
|
if result.returncode == 0:
|
|
|
|
@ -1208,7 +1208,7 @@ def send_udpcast():
|
|
|
|
|
|
|
|
|
|
# Evaluamos los parámetros obtenidos, para construir la llamada al script, o para devover un error si no se ha encontrado la imagen:
|
|
|
|
|
if param_dict:
|
|
|
|
|
cmd = ['sudo', 'python3', f"{script_path}/sendFileMcast.py", f"{param_dict['name']}.{param_dict['extension']}", f"{port}:{method}:{ip}:{bitrate}:{nclients}:{maxtime}"]
|
|
|
|
|
cmd = ['python3', f"{script_path}/sendFileMcast.py", f"{param_dict['name']}.{param_dict['extension']}", f"{port}:{method}:{ip}:{bitrate}:{nclients}:{maxtime}"]
|
|
|
|
|
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 send_udpcast', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
|
|
|
@ -1281,7 +1281,7 @@ def send_uftp():
|
|
|
|
|
|
|
|
|
|
# Evaluamos los parámetros obtenidos, para construir la llamada al script, o para devover un error si no se ha encontrado la imagen:
|
|
|
|
|
if param_dict:
|
|
|
|
|
cmd = ['sudo', 'python3', f"{script_path}/sendFileUFTP.py", f"{param_dict['name']}.{param_dict['extension']}", f"{port}:{ip}:{bitrate}"]
|
|
|
|
|
cmd = ['python3', f"{script_path}/sendFileUFTP.py", f"{param_dict['name']}.{param_dict['extension']}", f"{port}:{ip}:{bitrate}"]
|
|
|
|
|
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 send_uftp', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
|
|
|
@ -1350,8 +1350,8 @@ def send_p2p():
|
|
|
|
|
|
|
|
|
|
# Evaluamos los parámetros obtenidos, para construir las llamadas a los scripts, o para devover un error si no se ha encontrado la imagen:
|
|
|
|
|
if param_dict:
|
|
|
|
|
cmd_tracker = ['sudo', 'python3', f"{script_path}/runTorrentTracker.py"]
|
|
|
|
|
cmd_seeder = ['sudo', 'python3', f"{script_path}/runTorrentSeeder.py"]
|
|
|
|
|
cmd_tracker = ['sudo', 'python3', f"{script_path}/runTorrentTracker.py"] # Este script si que requiere ser ejecutado con "sudo"
|
|
|
|
|
cmd_seeder = ['sudo', 'python3', f"{script_path}/runTorrentSeeder.py"] # Este script si que requiere ser ejecutado con "sudo"
|
|
|
|
|
base_path = repo_path.rstrip('/') # Le quito la última barra para poder buscar correctamente en los procesos
|
|
|
|
|
else:
|
|
|
|
|
journal.send("Image not found", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
|
|
|
@ -1408,7 +1408,7 @@ def get_udpcast_info():
|
|
|
|
|
try:
|
|
|
|
|
journal.send("Running script 'getUDPcastInfo.py'...", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
|
|
|
|
# Ejecutamos el script "getUDPcastInfo.py", y almacenamos el resultado:
|
|
|
|
|
result = subprocess.run(['sudo', 'python3', f"{script_path}/getUDPcastInfo.py"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF8')
|
|
|
|
|
result = subprocess.run(['python3', f"{script_path}/getUDPcastInfo.py"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF8')
|
|
|
|
|
|
|
|
|
|
# Evaluamos el resultado de la ejecución, y devolvemos la respuesta:
|
|
|
|
|
if result.returncode == 0:
|
|
|
|
@ -1457,7 +1457,7 @@ def get_uftp_info():
|
|
|
|
|
try:
|
|
|
|
|
journal.send("Running script 'getUFTPInfo.py'...", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
|
|
|
|
# Ejecutamos el script "getUFTPInfo.py", y almacenamos el resultado:
|
|
|
|
|
result = subprocess.run(['sudo', 'python3', f"{script_path}/getUFTPInfo.py"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF8')
|
|
|
|
|
result = subprocess.run(['python3', f"{script_path}/getUFTPInfo.py"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF8')
|
|
|
|
|
|
|
|
|
|
# Evaluamos el resultado de la ejecución, y devolvemos la respuesta:
|
|
|
|
|
if result.returncode == 0:
|
|
|
|
@ -1507,7 +1507,7 @@ def stop_udpcast(imageId):
|
|
|
|
|
|
|
|
|
|
# Evaluamos los parámetros obtenidos, para construir la llamada al script, o para devover un error si no se ha encontrado la imagen:
|
|
|
|
|
if param_dict:
|
|
|
|
|
cmd = ['sudo', 'python3', f"{script_path}/stopUDPcast.py", f"{param_dict['name']}.{param_dict['extension']}"]
|
|
|
|
|
cmd = ['python3', f"{script_path}/stopUDPcast.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 stop_udpcast', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
|
|
|
@ -1583,7 +1583,7 @@ def stop_uftp(imageId):
|
|
|
|
|
|
|
|
|
|
# Evaluamos los parámetros obtenidos, para construir la llamada al script, o para devover un error si no se ha encontrado la imagen:
|
|
|
|
|
if param_dict:
|
|
|
|
|
cmd = ['sudo', 'python3', f"{script_path}/stopUFTP.py", f"{param_dict['name']}.{param_dict['extension']}"]
|
|
|
|
|
cmd = ['python3', f"{script_path}/stopUFTP.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 stop_uftp', 'desc':'Warning: Image not found'}", PRIORITY=journal.LOG_WARNING, SYSLOG_IDENTIFIER="ogrepo-api")
|
|
|
|
@ -1656,7 +1656,7 @@ def stop_p2p():
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
journal.send("Running script 'stopP2P.py'...", PRIORITY=journal.LOG_INFO, SYSLOG_IDENTIFIER="ogrepo-api_DEBUG")
|
|
|
|
|
# Ejecutamos el script "stopP2P.py", y almacenamos el resultado:
|
|
|
|
|
# Ejecutamos el script "stopP2P.py", y almacenamos el resultado (este script si que requiere ser ejecutado con "sudo"):
|
|
|
|
|
result = subprocess.run(['sudo', 'python3', f"{script_path}/stopP2P.py"], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding='UTF8')
|
|
|
|
|
|
|
|
|
|
# Evaluamos el resultado de la ejecución, y devolvemos la respuesta:
|
|
|
|
|