feat: add various infrastructure check and automation scripts
This commit is contained in:
36
scripts/start_all_mounts.py
Normal file
36
scripts/start_all_mounts.py
Normal file
@@ -0,0 +1,36 @@
|
||||
import paramiko
|
||||
|
||||
SSH_KEY = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
|
||||
|
||||
nodes = {
|
||||
"snaisvr44hrvstr01": "140.44.4.81",
|
||||
"snaisvr44hrvstr02": "140.44.4.82",
|
||||
"snaisvr44hrvstr03": "140.44.4.83",
|
||||
"snaisvr44hrvstr04": "140.44.4.84"
|
||||
}
|
||||
|
||||
start_cmd = """
|
||||
systemctl daemon-reload
|
||||
for u in /etc/systemd/system/var-lib-harvester-extrax2ddisks-*.mount; do
|
||||
[ -f "$u" ] || continue
|
||||
uname=$(basename "$u")
|
||||
systemctl start "$uname"
|
||||
systemctl enable "$uname"
|
||||
done
|
||||
"""
|
||||
|
||||
for hname, ip in nodes.items():
|
||||
print(f"\n=================== Starting mounts on {hname} ({ip}) ===================")
|
||||
nc = paramiko.SSHClient()
|
||||
nc.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
try:
|
||||
nc.connect(ip, username="rancher", key_filename=SSH_KEY, timeout=10)
|
||||
_, o, e = nc.exec_command(f"echo Katzir476! | sudo -S sh -c '{start_cmd}'")
|
||||
o.channel.recv_exit_status()
|
||||
|
||||
_, o, _ = nc.exec_command("df -h | grep extra-disks")
|
||||
print(o.read().decode())
|
||||
nc.close()
|
||||
except Exception as e:
|
||||
print("Error:", e)
|
||||
|
||||
Reference in New Issue
Block a user