From 61657785762009187bf4a5d54724b5f299f4ee80 Mon Sep 17 00:00:00 2001 From: grossmj Date: Fri, 22 Oct 2021 22:03:51 +1030 Subject: [PATCH] Allocate compute when compute_id is unset --- gns3server/controller/__init__.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gns3server/controller/__init__.py b/gns3server/controller/__init__.py index 22be7f8d..ab6a27a2 100644 --- a/gns3server/controller/__init__.py +++ b/gns3server/controller/__init__.py @@ -21,6 +21,7 @@ import uuid import socket import shutil import asyncio +import random from ..config import Config from .project import Project @@ -439,6 +440,16 @@ class Controller: Returns a compute or raise a 404 error. """ + if compute_id is None: + computes = list(self._computes.values()) + if len(computes) == 1: + # return the only available compute + return computes[0] + else: + # randomly pick a compute until we have proper scalability handling + # https://github.com/GNS3/gns3-server/issues/1676 + return random.choice(computes) + try: return self._computes[compute_id] except KeyError: