feat: add DNS setup blueprint and infrastructure automation scripts
This commit is contained in:
75
scripts/audit_harvester_hardware.py
Normal file
75
scripts/audit_harvester_hardware.py
Normal file
@@ -0,0 +1,75 @@
|
||||
import paramiko
|
||||
import time
|
||||
import re
|
||||
|
||||
nodes = {
|
||||
"Node 1 (snaihvs0lnx01)": "140.44.44.121",
|
||||
"Node 2 (snaihvs0lnx02)": "140.44.44.122",
|
||||
"Node 3 (snaihvs0lnx03)": "140.44.44.123",
|
||||
"Node 4 (idrac-spacedock4)": "140.44.44.124",
|
||||
}
|
||||
|
||||
results = {}
|
||||
|
||||
for name, ip in nodes.items():
|
||||
print(f"Connecting to {name} ({ip})...")
|
||||
node_data = {}
|
||||
try:
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect(ip, username="root", password="Katzir476!", timeout=10)
|
||||
chan = c.invoke_shell()
|
||||
time.sleep(2)
|
||||
if chan.recv_ready():
|
||||
chan.recv(4096)
|
||||
|
||||
def send_and_recv(cmd, wait_time=2.5):
|
||||
chan.send(cmd + "\r\n")
|
||||
time.sleep(wait_time)
|
||||
out = ""
|
||||
while chan.recv_ready():
|
||||
out += chan.recv(8192).decode('utf-8', errors='ignore')
|
||||
time.sleep(0.5)
|
||||
return out
|
||||
|
||||
# 1. BIOS Settings
|
||||
raw_bios = send_and_recv("racadm get bios.SysProfileSettings", 2)
|
||||
for key in ["SysProfile", "ProcCStates", "ProcC1E", "ProcTurboMode", "ProcPwrPerf"]:
|
||||
m = re.search(rf"{key}\s*=\s*(\w+)", raw_bios)
|
||||
node_data[key] = m.group(1) if m else "Unknown"
|
||||
|
||||
raw_proc = send_and_recv("racadm get bios.ProcSettings", 2)
|
||||
for key in ["ProcVirtualization", "ProcExecuteDisable", "LogicalProc"]:
|
||||
m = re.search(rf"{key}\s*=\s*(\w+)", raw_proc)
|
||||
node_data[key] = m.group(1) if m else "Unknown"
|
||||
|
||||
raw_dev = send_and_recv("racadm get bios.IntegratedDevices", 2)
|
||||
for key in ["SriovGlobalEnable"]:
|
||||
m = re.search(rf"{key}\s*=\s*(\w+)", raw_dev)
|
||||
node_data[key] = m.group(1) if m else "Unknown"
|
||||
|
||||
# 2. Storage / RAID
|
||||
raw_ctrl = send_and_recv("racadm raid get controllers", 2)
|
||||
controllers = [line.strip() for line in raw_ctrl.splitlines() if "RAID." in line or "PERC" in line or "AHCI." in line]
|
||||
node_data["Controllers"] = ", ".join(controllers) if controllers else "None"
|
||||
|
||||
raw_vdisks = send_and_recv("racadm raid get vdisks", 3)
|
||||
vdisks = [line.strip() for line in raw_vdisks.splitlines() if line.startswith("Disk.Virtual")]
|
||||
node_data["VirtualDisks"] = len(vdisks)
|
||||
node_data["VirtualDisksList"] = vdisks
|
||||
|
||||
raw_pdisks = send_and_recv("racadm raid get pdisks", 4)
|
||||
pdisk_lines = [line.strip() for line in raw_pdisks.splitlines() if line.startswith("Disk.Bay")]
|
||||
node_data["PhysicalDisks"] = len(pdisk_lines)
|
||||
node_data["PDisksSummary"] = raw_pdisks
|
||||
|
||||
c.close()
|
||||
except Exception as e:
|
||||
node_data["Error"] = str(e)
|
||||
|
||||
results[name] = node_data
|
||||
|
||||
print("\n\n========================= SUMMARY MATRIX =========================")
|
||||
import json
|
||||
print(json.dumps(results, indent=2))
|
||||
|
||||
Reference in New Issue
Block a user