From a581eeba54f2e3fb87921d355e5725c4f42b0a50 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Thu, 11 Feb 2016 16:01:47 +0100 Subject: [PATCH] Check docker minimum API version Fix #423 --- gns3server/modules/docker/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gns3server/modules/docker/__init__.py b/gns3server/modules/docker/__init__.py index f22467ef..22f74b61 100644 --- a/gns3server/modules/docker/__init__.py +++ b/gns3server/modules/docker/__init__.py @@ -24,6 +24,7 @@ import logging import aiohttp import urllib import json +from pkg_resources import parse_version log = logging.getLogger(__name__) @@ -32,6 +33,8 @@ from ..project_manager import ProjectManager from .docker_vm import DockerVM from .docker_error import * +DOCKER_MINIMUM_API_VERSION = "1.21" + class Docker(BaseManager): @@ -50,10 +53,13 @@ class Docker(BaseManager): try: self._connector = aiohttp.connector.UnixConnector(self._server_url) self._connected = True - yield from self.query("GET", "info") + version = yield from self.query("GET", "version") except (aiohttp.errors.ClientOSError, FileNotFoundError): self._connected = False raise DockerError("Can't connect to docker daemon") + + if parse_version(version["ApiVersion"]) < parse_version(DOCKER_MINIMUM_API_VERSION): + raise DockerError("Docker API version is {}. But GNS3 require a minimum API version {}".format(version["ApiVersion"], DOCKER_MINIMUM_API_VERSION)) return self._connector def __del__(self):