mirror of
https://github.com/GNS3/gns3-server
synced 2025-01-13 01:20:58 +00:00
Allocate compute when compute_id is unset
This commit is contained in:
parent
45738f262b
commit
6165778576
@ -21,6 +21,7 @@ import uuid
|
|||||||
import socket
|
import socket
|
||||||
import shutil
|
import shutil
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import random
|
||||||
|
|
||||||
from ..config import Config
|
from ..config import Config
|
||||||
from .project import Project
|
from .project import Project
|
||||||
@ -439,6 +440,16 @@ class Controller:
|
|||||||
Returns a compute or raise a 404 error.
|
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:
|
try:
|
||||||
return self._computes[compute_id]
|
return self._computes[compute_id]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
Loading…
Reference in New Issue
Block a user