From 21049d73a513085faf529654559eef3e8e9886d3 Mon Sep 17 00:00:00 2001 From: grossmj Date: Wed, 21 Jun 2023 22:28:09 +0930 Subject: [PATCH] Allow computes to be dynamically or manually allocated --- gns3server/compute/base_manager.py | 2 +- gns3server/controller/__init__.py | 3 ++- gns3server/controller/compute.py | 2 +- gns3server/controller/project.py | 8 +++++--- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/gns3server/compute/base_manager.py b/gns3server/compute/base_manager.py index a96fe2e7..48082e57 100644 --- a/gns3server/compute/base_manager.py +++ b/gns3server/compute/base_manager.py @@ -423,7 +423,7 @@ class BaseManager: # Windows path should not be send to a unix server if re.match(r"^[A-Z]:", path) is not None: raise NodeError( - f"'{path}' is not allowed on this remote server. Please only use a file from '{img_directory}'" + f"'{path}' is not allowed on this remote server (Windows path). Please only use a file from '{img_directory}'" ) if not os.path.isabs(orig_path): diff --git a/gns3server/controller/__init__.py b/gns3server/controller/__init__.py index ca593578..d8f0f229 100644 --- a/gns3server/controller/__init__.py +++ b/gns3server/controller/__init__.py @@ -495,7 +495,8 @@ class Controller: """ if compute_id is None: - computes = list(self._computes.values()) + # get all connected computes + computes = [compute for compute in self._computes.values() if compute.connected is True] if len(computes) == 1: # return the only available compute return computes[0] diff --git a/gns3server/controller/compute.py b/gns3server/controller/compute.py index 35f235cc..40172aaa 100644 --- a/gns3server/controller/compute.py +++ b/gns3server/controller/compute.py @@ -398,7 +398,7 @@ class Compute: raise ControllerNotFoundError(msg) self._capabilities = response.json - if response.json["version"].split("-")[0] != __version__.split("-")[0]: + if response.json["version"].split("+")[0] != __version__.split("+")[0]: if self._name.startswith("GNS3 VM"): msg = ( "GNS3 version {} is not the same as the GNS3 VM version {}. Please upgrade the GNS3 VM.".format( diff --git a/gns3server/controller/project.py b/gns3server/controller/project.py index 7107429a..ec5c7184 100644 --- a/gns3server/controller/project.py +++ b/gns3server/controller/project.py @@ -524,12 +524,14 @@ class Project: template["x"] = x template["y"] = y node_type = template.pop("template_type") - if template.pop("builtin", False) is True: - # compute_id is selected by clients for builtin templates + + if compute_id: + # use a custom compute_id compute = self.controller.get_compute(compute_id) else: - compute = self.controller.get_compute(template.pop("compute_id", compute_id)) + compute = self.controller.get_compute(template.pop("compute_id")) template_name = template.pop("name") + log.info(f'Creating node from template "{template_name}" on compute "{compute.name}" [{compute.id}]') default_name_format = template.pop("default_name_format", "{name}-{0}") if name is None: name = default_name_format.replace("{name}", template_name)