in azure-slurm-install/install.py [0:0]
def __init__(self, config: Dict, platform_family: str, mode: str) -> None:
self.config = config
if "slurm" not in config:
config["slurm"] = {}
if "accounting" not in config["slurm"]:
config["slurm"]["acccounting"] = {}
if "user" not in config["slurm"]:
config["slurm"]["user"] = {}
if "munge" not in config:
config["munge"] = {}
if "user" not in config["munge"]:
config["munge"]["user"] = {}
self.autoscale_dir = (
config["slurm"].get("autoscale_dir") or "/opt/azurehpc/slurm"
)
self.cyclecloud_cluster_name = config["cluster_name"]
# We use a "safe" form of the CycleCloud ClusterName
# First we lowercase the cluster name, then replace anything
# that is not letters, digits and '-' with a '-'
# eg My Cluster == my-cluster.
# This is needed because cluster names are used to create hostnames
# hostname conventions do not allow underscores and spaces
# https://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names.
# Since this PR: https://github.com/Azure/cyclecloud-slurm/pull/241 we now have
# to use cluster name to create a database name if one is not provided. But database naming
# conventions conflict witn hostname naming conventions and it cannot contain "-" hyphens.
# For now we use a second sanitized cluster name that derives from the escaped cluster name
# but converts all hyphens to underscores.
self.slurm_cluster_name = _escape(self.cyclecloud_cluster_name)
self.slurm_db_cluster_name = re.sub(r'-', '_', self.slurm_cluster_name)
self.node_name = config["node_name"]
self.hostname = config["hostname"]
self.ipv4 = config["ipaddress"]
self.slurmver = config["slurm"]["version"]
self.vm_size = config["azure"]["metadata"]["compute"]["vmSize"]
self.slurm_user: str = config["slurm"]["user"].get("name") or "slurm"
self.slurm_grp: str = config["slurm"]["user"].get("group") or "slurm"
self.slurm_uid: str = config["slurm"]["user"].get("uid") or "11100"
self.slurm_gid: str = config["slurm"]["user"].get("gid") or "11100"
self.munge_user: str = config["munge"]["user"].get("name") or "munge"
self.munge_grp: str = config["munge"]["user"].get("group") or "munge"
self.munge_uid: str = config["munge"]["user"].get("uid") or "11101"
self.munge_gid: str = config["munge"]["user"].get("gid") or "11101"
self.acct_enabled: bool = config["slurm"]["accounting"].get("enabled", False)
self.acct_user: Optional[str] = config["slurm"]["accounting"].get("user")
self.acct_pass: Optional[str] = config["slurm"]["accounting"].get("password")
self.acct_url: Optional[str] = config["slurm"]["accounting"].get("url")
self.acct_cert_url: Optional[str] = config["slurm"]["accounting"].get("certificate_url")
self.acct_storageloc :Optional[str] = config["slurm"]["accounting"].get("storageloc")
self.use_nodename_as_hostname = config["slurm"].get(
"use_nodename_as_hostname", False
)
self.node_name_prefix = config["slurm"].get("node_prefix")
if self.node_name_prefix:
self.node_name_prefix = re.sub(
"[^a-zA-Z0-9-]", "-", self.node_name_prefix
).lower()
self.ensure_waagent_monitor_hostname = config["slurm"].get(
"ensure_waagent_monitor_hostname", True
)
self.platform_family = platform_family
self.mode = mode
self.dynamic_config = config["slurm"].get("dynamic_config", None)
self.dynamic_feature = config["slurm"].get("dynamic_feature", None)
#TODO: Dynamic_config will be deprecated. Remove for 4.x
if self.dynamic_config:
self.dynamic_config = _inject_vm_size(self.dynamic_config, self.vm_size)
elif self.dynamic_feature:
self.dynamic_feature = f"{self.dynamic_feature},{self.vm_size}"
self.max_node_count = int(config["slurm"].get("max_node_count", 10000))
self.additonal_slurm_config = (
config["slurm"].get("additional", {}).get("config")
)
self.secondary_scheduler_name = config["slurm"].get("secondary_scheduler_name")
self.is_primary_scheduler = config["slurm"].get("is_primary_scheduler", self.mode == "scheduler")
self.config_dir = f"/sched/{self.slurm_cluster_name}"
# Leave the ability to disable this.
self.ubuntu22_waagent_fix = config["slurm"].get("ubuntu22_waagent_fix", True)