Files
SnarfCode/scripts/check_blockdevices.py

23 lines
988 B
Python

import paramiko
SSH_KEY = r"C:\Users\Snarf\.ssh\id_ed25519_snarfnet"
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect("140.44.4.90", username="rancher", key_filename=SSH_KEY, timeout=10)
def k8s(cmd):
full_cmd = f"echo Katzir476! | sudo -S sh -c 'export KUBECONFIG=/etc/rancher/rke2/rke2.yaml; PATH=$PATH:/var/lib/rancher/rke2/bin; {cmd}'"
_, o, e = c.exec_command(full_cmd)
return o.read().decode().strip(), e.read().decode().strip()
print("Harvester Block Devices:")
out, _ = k8s("kubectl get blockdevices.harvesterhci.io -A -o custom-columns=NAMESPACE:.metadata.namespace,NAME:.metadata.name,NODE:.spec.nodeName,DEV:.status.devicePath,FS:.status.fileSystem.type,MOUNT:.status.fileSystem.mountPoint,PROVISIONED:.status.provisioned")
print(out)
print("\nHarvester Node Disk status:")
out, _ = k8s("kubectl get nodes.harvesterhci.io -A -o yaml | grep -E 'nodeName|diskStatus|mountPath|provisioned'")
print(out[:1000])
c.close()