Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Jun 21, 2023
1 parent ebfdbc7 commit 6e974af
Showing 1 changed file with 35 additions and 27 deletions.
62 changes: 35 additions & 27 deletions create-cloudbank.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
import shutil
import os
import shutil

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"
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:
with open(name_path) as f:
data = yaml.safe_load(f)

org = data["jupyterhub"]["custom"]["homepage"]["templateVars"]["org"]
org["name"] = args["name"]
org["logo_url"] = args["logo"]
Expand All @@ -25,50 +27,56 @@ def modify_values(name_path, args):
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"
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:

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:
with open(name_path) 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:
CLUSTER_VALUES = f"{PARENT_PATH}/config/clusters/cloudbank/cluster.yaml"
with open(CLUSTER_VALUES) as file:
data = yaml.safe_load(file)
files= [
files = [
"common.values.yaml",
f"{args['hub_name']}.values.yaml",
f"enc-{args['hub_name']}.secret.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
"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]"]


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)
modify_values(path, args)

0 comments on commit 6e974af

Please sign in to comment.