Merge remote-tracking branch 'origin/2.2' into 3.0

# Conflicts:
#	.github/workflows/testing.yml
#	CHANGELOG
#	README.md
#	gns3server/appliances/infix.gns3a
#	gns3server/compute/docker/__init__.py
#	gns3server/compute/docker/docker_vm.py
#	gns3server/crash_report.py
#	gns3server/version.py
#	gns3server/web/web_server.py
#	setup.py
#	tests/controller/test_project.py
This commit is contained in:
grossmj committed 2025-11-29 11:42:02 +10:00
commit 60c10e7ecc
18 files changed
+232 -60

No files matched your search

+21 -16
View File
@@ -38,9 +38,9 @@ log = logging.getLogger(__name__)
# Be careful to keep it consistent
DOCKER_MINIMUM_API_VERSION = "1.25"
DOCKER_MINIMUM_VERSION = "1.13"
DOCKER_PREFERRED_API_VERSION = "1.30"
DOCKER_MINIMUM_API_VERSION = "1.40"
DOCKER_MINIMUM_VERSION = "19.03.8"
DOCKER_PREFERRED_API_VERSION = "1.44"
CHUNK_SIZE = 1024 * 8 # 8KB
@@ -125,22 +125,28 @@ class Docker(BaseManager):
if not self._connected:
try:
self._connected = True
version = await self.query("GET", "version")
docker_info = await self.query("GET", "version")
except (aiohttp.ClientError, FileNotFoundError):
self._connected = False
raise DockerError("Can't connect to docker daemon")
raise DockerError("Can't connect to Docker daemon")
docker_version = parse_version(version["ApiVersion"])
api_version = parse_version(docker_info['ApiVersion'])
version = docker_info["Version"]
if docker_version < parse_version(DOCKER_MINIMUM_API_VERSION):
raise DockerError(
f"Docker version is {version['Version']}. "
f"GNS3 requires a minimum version of {DOCKER_MINIMUM_VERSION}"
if api_version < parse_version(DOCKER_MINIMUM_API_VERSION):
raise DockerError(f"Docker version is {version}. "
f"GNS3 requires a minimum version of {DOCKER_MINIMUM_VERSION}"
)
preferred_api_version = parse_version(DOCKER_PREFERRED_API_VERSION)
if docker_version >= preferred_api_version:
if api_version >= preferred_api_version:
self._api_version = DOCKER_PREFERRED_API_VERSION
else:
# use the Min API version supported by the daemon
self._api_version = docker_info['MinAPIVersion']
log.warning("Using Docker client with the minimum API version {}".format(self._api_version))
log.info("Connected to Docker daemon version {} using API version {}".format(version, self._api_version))
def connector(self):
@@ -188,7 +194,7 @@ class Docker(BaseManager):
:param method: HTTP method
:param path: Endpoint in API
:param data: Dictionnary with the body. Will be transformed to a JSON
:param data: Dictionary with the body. Will be transformed to a JSON
:param params: Parameters added as a query arg
:param timeout: Timeout
:returns: HTTP response
@@ -199,12 +205,11 @@ class Docker(BaseManager):
timeout = 60 * 60 * 24 * 31 # One month timeout
if path == 'version':
url = "http://docker/v1.24/" + path
url = "http://docker/" + path
else:
url = "http://docker/v" + DOCKER_MINIMUM_API_VERSION + "/" + path
await self._check_connection() # version is use by check connection
url = "http://docker/v" + self._api_version + "/" + path
try:
if path != "version": # version is use by check connection
await self._check_connection()
if self._session is None or self._session.closed:
connector = self.connector()
self._session = aiohttp.ClientSession(connector=connector)
+10 -1
View File
@@ -195,6 +195,14 @@ class DockerVM(BaseNode):
def ethernet_adapters(self):
return self._ethernet_adapters
@property
def docker_name(self):
"""
Container name in Docker
"""
return "GNS3.{}.{}".format(self.name, self._project.id)
@property
def mac_address(self):
"""
@@ -539,7 +547,8 @@ class DockerVM(BaseNode):
if extra_hosts:
params["Env"].append(f"GNS3_EXTRA_HOSTS={extra_hosts}")
result = await self.manager.query("POST", "containers/create", data=params)
# Support name in Doker: [a-zA-Z0-9][a-zA-Z0-9_.-]
result = await self.manager.query("POST", f"containers/create?name={self.docker_name}", data=params)
self._cid = result["Id"]
log.info(f"Docker container '{self._name}' [{self._id}] created")
if self._cpus > 0: