forked from 2i2c-org/infrastructure
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c9bc47e
commit 9f6afdd
Showing
2 changed files
with
77 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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] | ||
|
@@ -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)$' |
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,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) |