Files
SnarfCode/scripts/test_rancher_customapi.py

19 lines
622 B
Python

import requests
import json
import urllib3
urllib3.disable_warnings()
full_key = "kubeconfig-u-aqzkufonck4hmbd:bw22b96nv8844k8w5r8lzpz8gnk22tjwj95j6nkzr7hd5dhm4bs6z7"
headers = {
"Authorization": f"Bearer {full_key}",
"Accept": "application/json"
}
for cid in ["local", "c-cclnt"]:
r = requests.get(f"https://aerodrome.snarfnet.net/v3/clusters/{cid}", headers=headers, verify=False, timeout=10)
print(f"Cluster {cid} status: {r.status_code}")
if r.status_code == 200:
d = r.json()
print(f"Name: {d.get('name')}, State: {d.get('state')}")
print("Capacity:", d.get('capacity'))