Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions bibigrid/core/startup.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,13 @@ def set_logger_verbosity(verbosity):
LOG.debug(f"Logging verbosity set to {capped_verbosity}")


def check_cid(cluster_id):
def check_cid(cluster_id, configurations, action):
if action == 'create':
providers = provider_handler.get_providers(configurations, LOG)
if not id_generation.is_unique_cluster_id(cluster_id, providers):
msg = f"Cluster id ({cluster_id}) already exists"
LOG.error(msg)
raise RuntimeError(msg)
if "-" in cluster_id:
new_cid = cluster_id.split("-")[-1]
LOG.info("-cid %s is not a cid, but probably the entire master name. Using '%s' as "
Expand All @@ -68,7 +74,7 @@ def check_cid(cluster_id):
LOG.info("-cid %s is not a cid, but probably the master's ip. "
"Using the master ip instead of cid only works if a cluster key is in your systems default ssh key "
"location (~/.ssh/). Otherwise bibigrid can't identify the cluster key.")
if len(cluster_id) != id_generation.MAX_ID_LENGTH or not set(cluster_id).issubset(
if len(cluster_id) > id_generation.MAX_ID_LENGTH or not set(cluster_id).issubset(
id_generation.CLUSTER_UUID_ALPHABET):
LOG.warning(
f"Cluster id doesn't fit length ({id_generation.MAX_ID_LENGTH}) or defined alphabet "
Expand Down Expand Up @@ -175,14 +181,14 @@ def main(verbose, debug, config_input, default_config_input, enforced_config_inp
default_config_input = expand_path(default_config_input)
enforced_config_input = expand_path(enforced_config_input)

if cluster_id:
cluster_id = check_cid(cluster_id)

configurations = configuration_handler.read_configuration(LOG, config_input)

if not configurations:
sys.exit(1)

if cluster_id:
cluster_id = check_cid(cluster_id, configurations, action)

configurations = configuration_handler.merge_configurations(
user_config=configurations,
default_config_path=default_config_input,
Expand Down
2 changes: 1 addition & 1 deletion bibigrid/core/startup_rest.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def setup(cluster_id, configurations_json=None):
"""
if cluster_id:
if cluster_id and (
len(cluster_id) != id_generation.MAX_ID_LENGTH or not set(cluster_id).issubset(
len(cluster_id) > id_generation.MAX_ID_LENGTH or not set(cluster_id).issubset(
id_generation.CLUSTER_UUID_ALPHABET)):
LOG.warning(f"Cluster id doesn't fit length ({id_generation.MAX_ID_LENGTH}) or defined alphabet "
f"({id_generation.CLUSTER_UUID_ALPHABET}). Aborting.")
Expand Down