diff --git a/create-cloudbank.py b/create-cloudbank.py index fce2da9191..dfa0e21235 100644 --- a/create-cloudbank.py +++ b/create-cloudbank.py @@ -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"] @@ -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"]=['ericvd@berkeley.edu', 'sean.smorris@berkeley.edu'] -args["admins"]=["mseidel@peralta.edu"] + + +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"] = ["ericvd@berkeley.edu", "sean.smorris@berkeley.edu"] +args["admins"] = ["mseidel@peralta.edu"] path = create_values(args["hub_name"]) -modify_values(path, args) \ No newline at end of file +modify_values(path, args)