mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-09-29 07:10:13 +03:00
Merge pull request #2887 from markparonyan/mypy-compute-docker-vm
fix(typing): resolve mypy errors in compute.docker vm modules
This commit is contained in:
commit
310bb193a5
@ -227,7 +227,11 @@ class DockerVM(BaseNode):
|
|||||||
return display
|
return display
|
||||||
display += 1
|
display += 1
|
||||||
|
|
||||||
@BaseNode.name.setter
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@name.setter
|
||||||
def name(self, new_name):
|
def name(self, new_name):
|
||||||
"""
|
"""
|
||||||
Sets the name of this Qemu VM.
|
Sets the name of this Qemu VM.
|
||||||
@ -737,13 +741,15 @@ class DockerVM(BaseNode):
|
|||||||
params["Env"].append("{}={}".format(var_name, formatted))
|
params["Env"].append("{}={}".format(var_name, formatted))
|
||||||
|
|
||||||
if self._environment:
|
if self._environment:
|
||||||
for e in self._environment.strip().split("\n"):
|
for env in self._environment.strip().split("\n"):
|
||||||
e = e.strip()
|
env = env.strip()
|
||||||
if e.split("=")[0] == "":
|
if env.split("=")[0] == "":
|
||||||
self.project.emit("log.warning", {"message": f"{self.name} has invalid environment variable: {e}"})
|
self.project.emit(
|
||||||
|
"log.warning", {"message": f"{self.name} has invalid environment variable: {env}"}
|
||||||
|
)
|
||||||
continue
|
continue
|
||||||
if not e.startswith("GNS3_"):
|
if not env.startswith("GNS3_"):
|
||||||
formatted = self._format_env(variables, e)
|
formatted = self._format_env(variables, env)
|
||||||
vm_name = self._name.replace(",", ",,")
|
vm_name = self._name.replace(",", ",,")
|
||||||
project_path = self.project.path.replace(",", ",,")
|
project_path = self.project.path.replace(",", ",,")
|
||||||
formatted = formatted.replace("%vm-name%", '"' + vm_name.replace('"', '\\"') + '"')
|
formatted = formatted.replace("%vm-name%", '"' + vm_name.replace('"', '\\"') + '"')
|
||||||
|
|||||||
@ -92,8 +92,8 @@ class IOLDockerVM(VendorDockerVM):
|
|||||||
# controller-allocated application id (MACs would flip to the fallback
|
# controller-allocated application id (MACs would flip to the fallback
|
||||||
# hash, colliding with the allocation pool) and any pending
|
# hash, colliding with the allocation pool) and any pending
|
||||||
# startup-config delivered by a PUT.
|
# startup-config delivered by a PUT.
|
||||||
_application_id = None
|
_application_id: int | None = None
|
||||||
_startup_config_content = None
|
_startup_config_content: str | None = None
|
||||||
_startup_config_dirty = False
|
_startup_config_dirty = False
|
||||||
|
|
||||||
def _parse_vendor_environment(self):
|
def _parse_vendor_environment(self):
|
||||||
@ -119,7 +119,7 @@ class IOLDockerVM(VendorDockerVM):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def application_id(self) -> int:
|
def application_id(self) -> int | None:
|
||||||
"""
|
"""
|
||||||
IOL application ID: drives interface MACs (aabb.cc{app}{iface}) and
|
IOL application ID: drives interface MACs (aabb.cc{app}{iface}) and
|
||||||
the NVRAM file name. Allocated by the controller from the IOL Docker
|
the NVRAM file name. Allocated by the controller from the IOL Docker
|
||||||
@ -178,6 +178,8 @@ class IOLDockerVM(VendorDockerVM):
|
|||||||
initial configuration dialog.
|
initial configuration dialog.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
if self._startup_config_content is None:
|
||||||
|
return
|
||||||
content = self._startup_config_content.replace("%h", self._name)
|
content = self._startup_config_content.replace("%h", self._name)
|
||||||
nvram_file = self._iol_nvram_file()
|
nvram_file = self._iol_nvram_file()
|
||||||
os.makedirs(os.path.dirname(nvram_file), exist_ok=True)
|
os.makedirs(os.path.dirname(nvram_file), exist_ok=True)
|
||||||
@ -189,7 +191,11 @@ class IOLDockerVM(VendorDockerVM):
|
|||||||
raise DockerError(f"Could not write IOL startup-config to NVRAM of container '{self._name}': {e}")
|
raise DockerError(f"Could not write IOL startup-config to NVRAM of container '{self._name}': {e}")
|
||||||
log.debug("IOL container '%s': startup-config written to %s", self._name, nvram_file)
|
log.debug("IOL container '%s': startup-config written to %s", self._name, nvram_file)
|
||||||
|
|
||||||
@DockerVM.name.setter
|
@property
|
||||||
|
def name(self):
|
||||||
|
return self._name
|
||||||
|
|
||||||
|
@name.setter
|
||||||
def name(self, new_name):
|
def name(self, new_name):
|
||||||
"""
|
"""
|
||||||
Override: keep the hostname line inside the NVRAM in sync with the
|
Override: keep the hostname line inside the NVRAM in sync with the
|
||||||
@ -228,7 +234,11 @@ class IOLDockerVM(VendorDockerVM):
|
|||||||
result["startup_config_content"] = self._startup_config_content
|
result["startup_config_content"] = self._startup_config_content
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@DockerVM.adapters.setter
|
@property
|
||||||
|
def adapters(self):
|
||||||
|
return len(self._ethernet_adapters)
|
||||||
|
|
||||||
|
@adapters.setter
|
||||||
def adapters(self, adapters):
|
def adapters(self, adapters):
|
||||||
"""
|
"""
|
||||||
Override: one IOL adapter is a 4-port unit — the IOU model. The
|
Override: one IOL adapter is a 4-port unit — the IOU model. The
|
||||||
|
|||||||
@ -360,8 +360,6 @@ module = [
|
|||||||
"gns3server.api.routes.controller.templates", # 10
|
"gns3server.api.routes.controller.templates", # 10
|
||||||
"gns3server.api.routes.controller.users", # 14
|
"gns3server.api.routes.controller.users", # 14
|
||||||
"gns3server.api.server", # 2
|
"gns3server.api.server", # 2
|
||||||
"gns3server.compute.docker.docker_vm", # 3
|
|
||||||
"gns3server.compute.docker.iol_docker_vm", # 3
|
|
||||||
"gns3server.compute.dynamips.nodes.router", # 2
|
"gns3server.compute.dynamips.nodes.router", # 2
|
||||||
"gns3server.compute.iou.iou_vm", # 4
|
"gns3server.compute.iou.iou_vm", # 4
|
||||||
"gns3server.compute.iou.utils.iou_export", # 2
|
"gns3server.compute.iou.utils.iou_export", # 2
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user