Update 2025-12-19 20:23:59

This commit is contained in:
unknown
2025-12-19 20:23:59 +09:00
parent b37c43ab86
commit 9d5d2b8d99
22 changed files with 1302 additions and 472 deletions

View File

@@ -3,6 +3,14 @@ import subprocess
from dotenv import load_dotenv
import sys
from multiprocessing import Pool
import logging
# Configure logging
logging.basicConfig(
level=logging.INFO,
format='%(asctime)s [INFO] root: %(message)s',
datefmt='%Y-%m-%d %H:%M:%S'
)
# 환경 변수 로드
load_dotenv() # .env 파일에서 환경 변수 로드
@@ -16,13 +24,14 @@ OME_PASS = os.getenv("OME_PASS")
# IP 주소 파일 로드 및 유효성 검사
def load_ip_file(ip_file_path):
if not os.path.isfile(ip_file_path):
sys.exit(f"IP file {ip_file_path} does not exist.")
logging.error(f"IP file {ip_file_path} does not exist.")
sys.exit(1)
with open(ip_file_path, "r") as file:
return [line.strip() for line in file if line.strip()]
# iDRAC 정보를 가져오는 함수
def fetch_idrac_info(idrac_ip):
print(f"Collecting TSR report for iDRAC IP: {idrac_ip}")
logging.info(f"Collecting TSR report for iDRAC IP: {idrac_ip}")
try:
result = subprocess.run(
[
@@ -32,13 +41,13 @@ def fetch_idrac_info(idrac_ip):
capture_output=True,
text=True
)
print(
f"Successfully collected TSR report for {idrac_ip}"
if result.returncode == 0
else f"Failed to collect TSR report for {idrac_ip}: {result.stderr.strip()}"
)
if result.returncode == 0:
logging.info(f"Successfully collected TSR report for {idrac_ip}")
else:
logging.error(f"Failed to collect TSR report for {idrac_ip}: {result.stderr.strip()}")
except Exception as e:
print(f"Exception occurred for {idrac_ip}: {e}")
logging.error(f"Exception occurred for {idrac_ip}: {e}")
# 메인 함수
if __name__ == "__main__":
@@ -51,4 +60,4 @@ if __name__ == "__main__":
with Pool() as pool:
pool.map(fetch_idrac_info, ip_list)
print("설정 완료.")
logging.info("설정 완료.")