diff --git a/bibigrid/core/actions/create.py b/bibigrid/core/actions/create.py index e4e6896d..306bdc5b 100644 --- a/bibigrid/core/actions/create.py +++ b/bibigrid/core/actions/create.py @@ -484,7 +484,7 @@ def start_start_server_threads(self): start_server_threads.append(start_server_thread) for worker in configuration.get("workerInstances", []): if not worker.get("onDemand", True): - for _ in range(int(worker["count"])): + for _ in range(int(worker.get("count", 1))): start_server_thread = return_threading.ReturnThread(target=self.start_worker, args=[worker, worker_count, configuration, provider]) @@ -492,7 +492,7 @@ def start_start_server_threads(self): start_server_threads.append(start_server_thread) worker_count += 1 else: - worker_count += worker["count"] + worker_count += worker.get("count", 1) for start_server_thread in start_server_threads: start_server_thread.join() diff --git a/bibigrid/core/rest/models.py b/bibigrid/core/rest/models.py index 7a4fe108..ad7a59f6 100644 --- a/bibigrid/core/rest/models.py +++ b/bibigrid/core/rest/models.py @@ -11,35 +11,35 @@ class Role(BaseModel): class UserRole(BaseModel): hosts: List[str] roles: List[Role] - varsFiles: Optional[List[str]] + varsFiles: Optional[List[str]] = Field(default=[]) class CloudScheduling(BaseModel): sshTimeout: Optional[int] = 5 class BootVolume(BaseModel): - name: Optional[str] + name: Optional[str] = None terminate: Optional[bool] = True size: Optional[int] = 50 class Volume(BaseModel): - name: Optional[str] - snapshot: Optional[str] + name: Optional[str] = None + snapshot: Optional[str] = None permanent: Optional[bool] = False semiPermanent: Optional[bool] = False exists: Optional[bool] = False - mountPoint: Optional[str] + mountPoint: Optional[str] = None size: Optional[int] = 50 - fstype: Optional[str] - type: Optional[str] + fstype: Optional[str] = None + type: Optional[str] = None class Instance(BaseModel): type: str image: str onDemand: Optional[bool] = True - partitions: Optional[List[str]] - features: Optional[List[str]] - bootVolume: Optional[BootVolume] - volumes: Optional[List[Volume]] + partitions: Optional[List[str]] = Field(default=[]) + features: Optional[List[str]] = Field(default=[]) + bootVolume: Optional[BootVolume] = None + volumes: Optional[List[Volume]] = Field(default=[]) class ElasticScheduling(BaseModel): SuspendTime: Optional[int] = 1800 @@ -48,11 +48,11 @@ class ElasticScheduling(BaseModel): TreeWidth: Optional[int] = 128 class SlurmConf(BaseModel): - db: Optional[str] - db_user: Optional[str] - db_password: Optional[str] - munge_key: Optional[str] - elastic_scheduling: Optional[ElasticScheduling] + db: Optional[str] = "slurm" + db_user: Optional[str] = "slurm" + db_password: Optional[str] = "changeme" + munge_key: Optional[str] = None + elastic_scheduling: Optional[ElasticScheduling] = None class Gateway(BaseModel): ip: str @@ -64,29 +64,29 @@ class MasterConfig(BaseModel): sshUser: str subnet: Optional[str] = Field(default=None) network: Optional[str] = Field(default=None) - cloud_identifier: str - sshPublicKeyFiles: Optional[List[str]] + cloud_identifier: Optional[str] = None + sshPublicKeyFiles: Optional[List[str]] = Field(default=[]) sshTimeout: Optional[int] = 5 - cloudScheduling: Optional[CloudScheduling] - nfsShares: Optional[List[str]] - userRoles: Optional[List[UserRole]] + cloudScheduling: Optional[CloudScheduling] = None + nfsShares: Optional[List[str]] = Field(default=[]) + userRoles: Optional[List[UserRole]] = Field(default=[]) localFS: Optional[bool] = False localDNSlookup: Optional[bool] = False slurm: Optional[bool] = True - slurmConf: Optional[SlurmConf] + slurmConf: Optional[SlurmConf] = None zabbix: Optional[bool] = False nfs: Optional[bool] = False ide: Optional[bool] = False useMasterAsCompute: Optional[bool] = True useMasterWithPublicIp: Optional[bool] = True - waitForServices: Optional[List[str]] - gateway: Optional[Gateway] + waitForServices: Optional[List[str]] = Field(default=[]) + gateway: Optional[Gateway] = None dontUploadCredentials: Optional[bool] = False fallbackOnOtherImage: Optional[bool] = False - features: Optional[List[str]] + features: Optional[List[str]] = Field(default=[]) workerInstances: List[Instance] masterInstance: Instance - bootVolume: Optional[BootVolume] + bootVolume: Optional[BootVolume] = None class OtherConfig(BaseModel): infrastructure: str @@ -94,12 +94,12 @@ class OtherConfig(BaseModel): sshUser: str subnet: Optional[str] = Field(default=None) network: Optional[str] = Field(default=None) - cloud_identifier: str - waitForServices: Optional[List[str]] - features: Optional[List[str]] + cloud_identifier: Optional[str] = None + waitForServices: Optional[List[str]] = Field(default=[]) + features: Optional[List[str]] = Field(default=[]) workerInstances: List[Instance] vpnInstance: Instance - bootVolume: Optional[BootVolume] + bootVolume: Optional[BootVolume] = None class ConfigurationsModel(BaseModel): configurations: List[Union[MasterConfig, OtherConfig]] diff --git a/bibigrid/core/startup_rest.py b/bibigrid/core/startup_rest.py index d0678a93..d8a3372b 100644 --- a/bibigrid/core/startup_rest.py +++ b/bibigrid/core/startup_rest.py @@ -150,7 +150,7 @@ async def create_async(): creator.create() try: - configurations = configurations_json.model_dump() + configurations = configurations_json.model_dump(exclude_none=True)["configurations"] providers = provider_handler.get_providers(configurations, log) creator = create.Create(providers=providers, configurations=configurations, log=log, config_path=None, cluster_id=cluster_id)