Skip to content

Commit

Permalink
[CloudBank] Fixed Pasadena
Browse files Browse the repository at this point in the history
  • Loading branch information
sean-morris committed Jun 21, 2023
1 parent c9bc47e commit 9f6afdd
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 3 deletions.
6 changes: 3 additions & 3 deletions config/clusters/cloudbank/pasadena.values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ jupyterhub:
url: http://cloudbank.org/
hub:
config:
JupyterHub:
authenticator_class: cilogon
CILogonOAuthenticator:
oauth_callback_url: https://pasadena.cloudbank.2i2c.cloud/hub/oauth_callback
username_claim: email
JupyterHub:
authenticator_class: cilogon
Authenticator:
admin_users:
- [email protected]
Expand All @@ -44,4 +44,4 @@ jupyterhub:
- [email protected]
- [email protected]
- [email protected]
username_pattern: '^(.+@2i2c\.org|.+@berkeley\.edu|.+@go\.pasadena\.edu|yccdharma@gmail\.com|deployment-service-check)$'
username_pattern: '^(.+@2i2c\.org|.+@berkeley\.edu|.+@pasadena\.edu|.+@go\.pasadena\.edu|yccdharma@gmail\.com|deployment-service-check)$'
74 changes: 74 additions & 0 deletions create-cloudbank.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import shutil
import os
import yaml


def create_values(name):
PARENT_PATH = os.getcwd()
ORIGINAL_VALUES=f"{PARENT_PATH}/config/clusters/cloudbank/csulb.values.yaml"
NEW_VALUES=f"{PARENT_PATH}/config/clusters/cloudbank/{name}.values.yaml"
shutil.copyfile(ORIGINAL_VALUES, NEW_VALUES)
return NEW_VALUES

def modify_values(name_path, args):
with open(name_path, "r") as f:
data = yaml.safe_load(f)

org = data["jupyterhub"]["custom"]["homepage"]["templateVars"]["org"]
org["name"] = args["name"]
org["logo_url"] = args["logo"]
org["url"] = args["url"]

auth = data["jupyterhub"]["hub"]["config"]["Authenticator"]
admin_users = args["berk_admins"] + args["admins"]
admin_users = {"sacramento_users": admin_users}
auth["admin_users"] = admin_users["sacramento_users"]
auth["allowed_users"] = admin_users["sacramento_users"]
login = data["jupyterhub"]["hub"]["config"]["CILogonOAuthenticator"]
login["oauth_callback_url"] = f"https://{args['hub_name']}.cloudbank.2i2c.cloud/hub/oauth_callback"

ingress = data["jupyterhub"]["ingress"]

ingress["hosts"] = [f"{args['hub_name']}.cloudbank.2i2c.cloud"]
ingress["tls"][0]["hosts"] = [f"{args['hub_name']}.cloudbank.2i2c.cloud"]

with open(name_path, 'w') as file:
yaml.dump(data, file)

with open(name_path, 'r') as file:
str_file=file.read()
str_file=str_file.replace("id001", f"{args['hub_name']}_users")
with open(name_path, 'w') as file:
file.write(str_file)

def add_to_cluster(path, args):
PARENT_PATH = os.getcwd()
CLUSTER_VALUES=f"{PARENT_PATH}/config/clusters/cloudbank/cluster.yaml"
with open(CLUSTER_VALUES, "r") as file:
data = yaml.safe_load(file)
files= [
"common.values.yaml",
f"{args['hub_name']}.values.yaml",
f"enc-{args['hub_name']}.secret.values.yaml"
]
item = {
"name": args["hub_name"],
"display_name": args["name"],
"domain": f"{args['hub_name']}.cloudbank.2i2c.cloud",
"helm_chart": "basehub",
"helm_chart_values_files": files
}
data["hubs"].append(item)
with open(CLUSTER_VALUES, "w") as file:
yaml.safe_dump(data, file)

args= {}
args["name"]="Diable Valley College"
args["url"]="https://www.berkeleycitycollege.edu/"
args["logo"]="https://www.berkeleycitycollege.edu/wp-content/blogs.dir/1/files/2019/02/Berkeley-City-College-Logo-and-name.png"
args["hub_name"]="bcc"
args["berk_admins"]=['[email protected]', '[email protected]']
args["admins"]=["[email protected]"]

path = create_values(args["hub_name"])
modify_values(path, args)

0 comments on commit 9f6afdd

Please sign in to comment.