1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-18 06:18:08 +00:00

Check docker minimum API version

Fix #423
This commit is contained in:
Julien Duponchelle 2016-02-11 16:01:47 +01:00
parent 9b0088728f
commit a581eeba54
No known key found for this signature in database
GPG Key ID: F1E2485547D4595D

View File

@ -24,6 +24,7 @@ import logging
import aiohttp import aiohttp
import urllib import urllib
import json import json
from pkg_resources import parse_version
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
@ -32,6 +33,8 @@ from ..project_manager import ProjectManager
from .docker_vm import DockerVM from .docker_vm import DockerVM
from .docker_error import * from .docker_error import *
DOCKER_MINIMUM_API_VERSION = "1.21"
class Docker(BaseManager): class Docker(BaseManager):
@ -50,10 +53,13 @@ class Docker(BaseManager):
try: try:
self._connector = aiohttp.connector.UnixConnector(self._server_url) self._connector = aiohttp.connector.UnixConnector(self._server_url)
self._connected = True self._connected = True
yield from self.query("GET", "info") version = yield from self.query("GET", "version")
except (aiohttp.errors.ClientOSError, FileNotFoundError): except (aiohttp.errors.ClientOSError, FileNotFoundError):
self._connected = False self._connected = False
raise DockerError("Can't connect to docker daemon") 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 return self._connector
def __del__(self): def __del__(self):