Skip to content

Commit 7ef19b4

Browse files
author
Catherine Hong
committed
Pony that displays the fedora pool or ip
1 parent 18f1344 commit 7ef19b4

File tree

3 files changed

+24
-4
lines changed

3 files changed

+24
-4
lines changed

scriptspony/controllers/root.py

+2
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ def index(self, locker=None, sudo=False, **kwargs):
8181
try:
8282
hosts = vhosts.list_vhosts(locker)
8383
hosts.sort(key=lambda k: k[0])
84+
pools = vhosts.list_pools()
85+
hosts = [(host,aliases,path,pools.get(ip,ip)) for host,aliases,path,ip in hosts]
8486
except auth.AuthError as e:
8587
flash(e.message)
8688
# User has been deauthorized from this locker

scriptspony/templates/index.mak

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ from scripts import auth
99

1010
<p>
1111
<table border="1">
12-
<tr><th>Hostname</th><th>Path</th><th>Edit</th></tr>
13-
%for host,aliases,path in hosts:
12+
<tr><th>Hostname</th><th>Path</th><th>Fedora Pool</th><th>Edit</th></tr>
13+
%for host,aliases,path,ipv4 in hosts:
1414
<tr>
1515
<td>
1616
<a href="http://${host}">${host}</a>
@@ -21,6 +21,9 @@ from scripts import auth
2121
<td>
2222
<small>/mit/${locker}/web_scripts/</small>${path}
2323
</td>
24+
<td>
25+
<big>${ipv4}</big>
26+
</td>
2427
%if host not in (locker+'.scripts.mit.edu',):
2528
<td class="nbr">
2629
<a href="${tg.url('/edit/'+locker+'/'+host)}" class="btn sm-btn" aria-label="Edit"><span class="fa fa-pencil" aria-hidden="true"></span></a>

scriptspony/vhosts.py

+17-2
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,32 @@ def list_vhosts(locker):
6565
"(&(objectClass=scriptsVhost)(scriptsVhostAccount=uid=%s,ou=People,dc=scripts,dc=mit,dc=edu))",
6666
[locker],
6767
),
68-
["scriptsVhostName", "scriptsVhostDirectory", "scriptsVhostAlias"],
68+
["scriptsVhostName", "scriptsVhostDirectory", "scriptsVhostAlias", "scriptsVhostPoolIPv4"],
6969
)
7070
return [
7171
(
7272
m["scriptsVhostName"][0],
7373
m.get("scriptsVhostAlias", []),
7474
m["scriptsVhostDirectory"][0],
75+
m["scriptsVhostPoolIPv4"][0],
7576
)
76-
for i, m in res
77+
for _, m in res
7778
]
7879

80+
@log.exceptions
81+
@reconnecting
82+
def list_pools():
83+
"""Returns the IP and description for each VhostPool"""
84+
res = conn.search_s(
85+
"ou=Pools,dc=scripts,dc=mit,dc=edu",
86+
ldap.SCOPE_ONELEVEL,
87+
"objectClass=scriptsVhostPool",
88+
["scriptsVhostPoolIPv4", "description"],
89+
)
90+
return {
91+
m["scriptsVhostPoolIPv4"][0]: m["description"][0]
92+
for _, m in res
93+
}
7994

8095
@team_sensitive
8196
@log.exceptions

0 commit comments

Comments
 (0)