This repository has been archived by the owner on Apr 29, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #60 from NERSC/19-05
19 05
- Loading branch information
Showing
11 changed files
with
733 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
# Shut down all but the newest jupyterhub server running. | ||
|
||
hostname=$1 | ||
username=$2 | ||
cert=/certs/$username.key | ||
echo $username $cert | ||
if [ ! -f $cert ]; then | ||
echo " ... no cert for $username" | ||
exit 1 | ||
fi | ||
/usr/bin/ssh \ | ||
-i $cert \ | ||
-l $username \ | ||
-o PreferredAuthentications=publickey \ | ||
-o StrictHostKeyChecking=no \ | ||
-p 22 \ | ||
$hostname \ | ||
/global/common/shared/das/jupyterhub/kill-my-old-jupyters.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#!/bin/bash | ||
|
||
# Useful when JupyterHub thinks a user has no server running | ||
# but actually they do, and they still have a cert. | ||
|
||
hostname=$1 | ||
username=$2 | ||
cert=/certs/$username.key | ||
echo $username $cert | ||
if [ ! -f $cert ]; then | ||
echo " ... SKIPPED no cert for $username" | ||
continue | ||
fi | ||
for i in 1 2 3 | ||
do | ||
/usr/bin/ssh \ | ||
-i $cert \ | ||
-l $username \ | ||
-o PreferredAuthentications=publickey \ | ||
-o StrictHostKeyChecking=no \ | ||
-p 22 \ | ||
$hostname \ | ||
killall -u $username | ||
sleep 1 | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
from textwrap import dedent | ||
|
||
from tornado import escape, httpclient | ||
|
||
class Iris: | ||
|
||
def __init__(self, iris_url="https://iris.nersc.gov/graphql"): | ||
self.iris_url = iris_url | ||
|
||
async def query_user(self, name): | ||
query = dedent(""" | ||
query {{ | ||
systemInfo {{ | ||
users(name: "{}") {{ | ||
baseRepos {{ | ||
computeAllocation {{ | ||
repoName | ||
}} | ||
}} | ||
userAllocations {{ | ||
computeAllocation {{ | ||
repoName | ||
}} | ||
userAllocationQos {{ | ||
qos {{ | ||
qos | ||
}} | ||
}} | ||
}} | ||
}} | ||
}} | ||
}}""".format(name)).strip() | ||
data = await self.query(query) | ||
return data["data"]["systemInfo"]["users"][0] | ||
|
||
async def query(self, query): | ||
client = httpclient.AsyncHTTPClient() | ||
request = self.format_request(query) | ||
response = await client.fetch(request) | ||
return escape.json_decode(response.body) | ||
|
||
def format_request(self, query): | ||
return httpclient.HTTPRequest(self.iris_url, | ||
method="POST", | ||
headers={"Content-Type": "application/json"}, | ||
body=escape.json_encode({"query": query})) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.