Update 2026-01-20 20:47:44
This commit is contained in:
@@ -44,8 +44,9 @@ def fetch_idrac_info(idrac_ip, output_dir):
|
||||
# 서비스 태그 저장
|
||||
f.write(f"{svc_tag}\n")
|
||||
|
||||
# 모든 PortGUID를 저장할 리스트
|
||||
hex_guid_list = []
|
||||
# 슬롯별 GUID를 딕셔너리로 수집
|
||||
slot_to_guid = {}
|
||||
slots_found = []
|
||||
|
||||
# 각 InfiniBand.VndrConfigPage.<숫자> 처리
|
||||
for number, slot in matches:
|
||||
@@ -56,6 +57,25 @@ def fetch_idrac_info(idrac_ip, output_dir):
|
||||
match_guid = re.search(r"PortGUID=(\S+)", output_detail)
|
||||
port_guid = match_guid.group(1) if match_guid else "Not Found"
|
||||
|
||||
slot_to_guid[slot] = port_guid
|
||||
slots_found.append(slot)
|
||||
|
||||
# 환경변수에서 슬롯 우선순위 읽기
|
||||
slot_priority_str = os.getenv("GUID_SLOT_PRIORITY", "")
|
||||
|
||||
if slot_priority_str:
|
||||
# 사용자 지정 슬롯 우선순위 사용
|
||||
desired_order = [s.strip() for s in slot_priority_str.split(",") if s.strip()]
|
||||
logging.info(f"사용자 지정 슬롯 우선순위 사용: {desired_order}")
|
||||
else:
|
||||
# 기본: 발견된 순서대로
|
||||
desired_order = slots_found
|
||||
logging.info(f"기본 순서 사용 (발견된 순서): {desired_order}")
|
||||
|
||||
# 지정된 순서대로 파일에 기록 + GUID 합치기
|
||||
hex_guid_list = []
|
||||
for slot in desired_order:
|
||||
port_guid = slot_to_guid.get(slot, "Not Found")
|
||||
# Slot.<숫자>: <PortGUID> 형식으로 저장
|
||||
f.write(f"Slot.{slot}: {port_guid}\n")
|
||||
|
||||
@@ -66,9 +86,11 @@ def fetch_idrac_info(idrac_ip, output_dir):
|
||||
# 모든 PortGUID를 "GUID: 0x<GUID1>;0x<GUID2>" 형식으로 저장
|
||||
if hex_guid_list:
|
||||
f.write(f"GUID: {';'.join(hex_guid_list)}\n")
|
||||
logging.info(f"GUID 합치기 완료: {len(hex_guid_list)}개 슬롯")
|
||||
|
||||
logging.info(f"✅ Completed: {idrac_ip}")
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"Error processing IP {idrac_ip}: {e}")
|
||||
|
||||
@@ -77,8 +99,19 @@ def main(ip_file):
|
||||
logging.error(f"IP file {ip_file} does not exist.")
|
||||
return
|
||||
|
||||
output_dir = "/app/idrac_info/idrac_info"
|
||||
# Output directory resolution
|
||||
# Try to find 'data/idrac_info' relative to this script
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
# Assuming script is in data/scripts, parent is data
|
||||
data_dir = os.path.dirname(script_dir)
|
||||
output_dir = os.path.join(data_dir, "idrac_info")
|
||||
|
||||
# Fallback to current directory if structure is different
|
||||
if not os.path.basename(data_dir) == "data":
|
||||
output_dir = os.path.join(os.getcwd(), "idrac_info")
|
||||
|
||||
os.makedirs(output_dir, exist_ok=True)
|
||||
logging.info(f"Output directory set to: {output_dir}")
|
||||
|
||||
with open(ip_file, "r") as file:
|
||||
ip_addresses = [line.strip() for line in file.readlines()]
|
||||
|
||||
Reference in New Issue
Block a user