Skip to content
This repository was archived by the owner on Jun 17, 2025. It is now read-only.

Commit 1dfe677

Browse files
author
manavmahan
committed
updated pod info to match names
1 parent 1ddb120 commit 1dfe677

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

pod-info.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
API_KEY = os.getenv("RUNPOD_API_KEY")
88

99
URL = f"https://api.runpod.io/graphql?api_key={API_KEY}"
10-
print(URL)
1110
HEADERS = {
1211
'Content-Type': 'application/json',
1312
}
@@ -23,12 +22,10 @@ def get_all_running_pods():
2322
json={'query': query},
2423
headers=HEADERS
2524
)
26-
print(response.json())
25+
# print(response.json())
2726
if response.status_code == 200:
2827
pods = response.json()['data']['myself']['pods']
2928
for pod in pods:
30-
if 'manav' not in pod['name']:
31-
continue
3229
ip = None
3330
port = None
3431
try:
@@ -38,7 +35,7 @@ def get_all_running_pods():
3835
ip = p['ip']
3936
port = p['publicPort']
4037
break
41-
yield (pod['id'], (ip, port))
38+
yield (pod['name'], (ip, port, pod["id"]))
4239
except TypeError:
4340
pass
4441
else:
@@ -47,22 +44,23 @@ def get_all_running_pods():
4744

4845
# Fetch and print all running pods with their IP address and port
4946
pods = dict(get_all_running_pods())
47+
pods = dict(sorted(pods.items(), key=lambda x: x[0]))
5048

5149
config = """Host %s
5250
HostName %s
5351
Port %s
5452
User root
5553
IdentitiesOnly yes
56-
IdentityFile /Users/manav/.ssh/run_pod
54+
IdentityFile /Users/manav/.ssh/runpod
5755
ForwardX11 yes
5856
"""
5957

6058
configs = []
6159
i = 1
62-
for pod, (ip, port) in pods.items():
60+
for pod, (ip, port, id) in pods.items():
6361
if ip is not None:
64-
print(f"{pod} - pod{i} - {ip}:{port}")
65-
configs.append(config % (f"pod{i}", ip, port))
62+
print(f"{pod} - pod{i} - {id} - {ip}:{port}")
63+
configs.append(config % (f"{pod}", ip, port))
6664
i += 1
6765

6866
with open('/Users/manav/.ssh/config', 'w') as f:

0 commit comments

Comments
 (0)