Dissallow parallel pull of docker images

Fix #962
This commit is contained in:
Julien Duponchelle
2017-03-27 20:46:25 +02:00
parent 25c4207661
commit 132bc87081
5 changed files with 91 additions and 66 deletions

View File

@ -24,7 +24,6 @@ import shutil
import psutil
import shlex
import aiohttp
import json
import os
from gns3server.utils.asyncio.telnet_server import AsyncioTelnetServer
@ -767,26 +766,9 @@ class DockerVM(BaseNode):
"""
Pull image from docker repository
"""
log.info("Pull %s from docker hub", image)
response = yield from self.manager.http_query("POST", "images/create", params={"fromImage": image}, timeout=None)
# The pull api will stream status via an HTTP JSON stream
content = ""
while True:
chunk = yield from response.content.read(1024)
if not chunk:
break
content += chunk.decode("utf-8")
try:
while True:
content = content.lstrip(" \r\n\t")
answer, index = json.JSONDecoder().raw_decode(content)
if "progress" in answer:
self.project.emit("log.info", {"message": "Pulling image {}:{}: {}".format(self._image, answer["id"], answer["progress"])})
content = content[index:]
except ValueError: # Partial JSON
pass
self.project.emit("log.info", {"message": "Success pulling image {}".format(self._image)})
def callback(msg):
self.project.emit("log.info", {"message": msg})
yield from self.manager.pull_image(image, progress_callback=callback)
@asyncio.coroutine
def _start_ubridge_capture(self, adapter_number, output_file):