def delete(self) -> None: """Delete the MARO Cluster. Returns: None. """ logger.info(f"Deleting cluster '{self.cluster_name}'") # Get resource list resource_list = AzureController.list_resources( resource_group=self.resource_group) # Filter resources deletable_ids = [] for resource in resource_list: if resource["name"].startswith(self.cluster_id): deletable_ids.append(resource["id"]) # Delete resources if deletable_ids: AzureController.delete_resources(resource_ids=deletable_ids) # Delete cluster folder shutil.rmtree(f"{GlobalPaths.ABS_MARO_CLUSTERS}/{self.cluster_name}") logger.info_green(f"Cluster '{self.cluster_name}' is deleted")
def _delete_resources(resource_group: str, cluster_id: int, resource_name: str) -> None: """Delete resources in the resource group. Args: resource_group (str): name of the resource group. cluster_id (id): id of the MARO Cluster. resource_name (str): name of the MARO Resource. e.g. node_name Returns: None. """ # Get resource list resource_list = AzureController.list_resources( resource_group=resource_group) # Filter resources deletable_ids = [] for resource_info in resource_list: if resource_info["name"].startswith( f"{cluster_id}-{resource_name}"): deletable_ids.append(resource_info["id"]) # Delete resources if len(deletable_ids) > 0: AzureController.delete_resources(resource_ids=deletable_ids)