-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgodview
executable file
·60 lines (47 loc) · 1.49 KB
/
godview
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/usr/bin/python
# Usage
# run godview and hit localhost:8000 in the browser
import os
import threading
import time
import SimpleHTTPServer
import SocketServer
from util import *
PORT = 8000
TODOs = [
"kubectl get nodes --show-all -o wide",
"kubectl get svc --all-namespaces --show-all -o wide",
"kubectl get endpoints --all-namespaces --show-all -o wide",
"kubectl get rc --all-namespaces --show-all -o wide",
"kubectl get deployment --all-namespaces --show-all -o wide",
"gcloud compute firewall-rules list | grep e2e",
"gcloud compute routes list",
"gcloud compute forwarding-rules list",
"kubectl get pod --all-namespaces --show-all -o wide",
]
if 'RUN' in os.environ:
TODOs = os.environ['RUN'] + TODOs
template_path = os.path.join(os.path.dirname(os.path.realpath(__file__)), "index.template")
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
SocketServer.TCPServer.allow_reuse_address = True
httpd = SocketServer.TCPServer(("", PORT), Handler)
def update_page():
now = time.ctime()
template = open(template_path, "r")
page = template.read()
template.close()
content = ""
for cmd in TODOs:
content += convert_table_into_html(cmd, get_cmd_result_as_table(cmd))
f = open("index.html", "w+")
f.write(page.format(now, content))
f.close()
threading.Timer(5, update_page).start()
try:
update_page()
print
"Serving at port", PORT
httpd.serve_forever()
except KeyboardInterrupt:
print
'\nGoodbye!'