ogclone-engine/client/shared/scripts/listSoftwareInfo.py

38 lines
1.0 KiB
Python

import sys
import os
sys.path.append('/opt/opengnsys/lib/engine/bin')
from NetLib import ogGetIpAddress
from SystemLib import ogRaiseError
from InventoryLib import ogListSoftware
REDUCED = False
if len(sys.argv) > 1 and sys.argv[1] == "-r":
REDUCED = True
sys.argv.pop(1)
if len(sys.argv) != 3:
og_raise_error("OG_ERR_FORMAT", "Usage: listSoftwareInfo [-r] disk partition")
sys.exit(1)
disk = sys.argv[1]
partition = sys.argv[2]
# Directorio del servidor donde se exportan los ficheros de registro
server_log_dir = "/mnt/oglog" # Assuming OGLOG is mounted at /mnt/oglog
# Fichero de listado: soft-IP-disk-partition
soft_file = f"soft-{ogGetIpAddress()}-{disk}-{partition}"
log_path = os.path.join(server_log_dir, soft_file)
# Redirigir salida al fichero de listado
with open(log_path, "w") as log_file:
if not REDUCED:
ogListSoftware(disk, partition, log_file)
else:
for line in og_list_software(disk, partition):
if "(KB" not in line:
log_file.write(line + "\n")
print(log_path)