feat: add homelab deployment configs, documentation, and automation scripts
This commit is contained in:
30
scripts/test_rancher_token.py
Normal file
30
scripts/test_rancher_token.py
Normal file
@@ -0,0 +1,30 @@
|
||||
import paramiko
|
||||
import requests
|
||||
import json
|
||||
import urllib3
|
||||
urllib3.disable_warnings()
|
||||
|
||||
c = paramiko.SSHClient()
|
||||
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
||||
c.connect('140.44.4.11', username='root', key_filename=r'C:\Users\Snarf\.ssh\id_ed25519_snarfnet', timeout=10)
|
||||
|
||||
name = 'kubeconfig-u-aqzkufonck4hmbd'
|
||||
_, o, _ = c.exec_command(f'kubectl get tokens.management.cattle.io {name} -o json')
|
||||
data = json.loads(o.read().decode())
|
||||
token = data.get('token')
|
||||
|
||||
full_key = f"{name}:{token}"
|
||||
headers = {"Authorization": f"Bearer {full_key}"}
|
||||
r = requests.get("https://aerodrome.snarfnet.net/v3/clusters", headers=headers, verify=False, timeout=10)
|
||||
|
||||
for cl in r.json().get('data', []):
|
||||
name = cl.get('name')
|
||||
cid = cl.get('id')
|
||||
state = cl.get('state')
|
||||
cap = cl.get('capacity', {})
|
||||
alloc = cl.get('allocatable', {})
|
||||
print(f"=== Cluster: {name} (ID: {cid}, State: {state}) ===")
|
||||
print(" Capacity:", cap)
|
||||
print(" Allocatable:", alloc)
|
||||
|
||||
c.close()
|
||||
Reference in New Issue
Block a user