From f20e16074fdb4d86c3964419f0e9fb3bfde8ca59 Mon Sep 17 00:00:00 2001 From: grossmj Date: Mon, 19 Oct 2020 18:28:01 +1030 Subject: [PATCH] Fix Docker dev server script. --- Dockerfile | 7 +++---- gns3server/endpoints/compute/__init__.py | 14 ++------------ gns3server/endpoints/controller/links.py | 7 +++---- scripts/docker_dev_server.sh | 6 ++---- 4 files changed, 10 insertions(+), 24 deletions(-) diff --git a/Dockerfile b/Dockerfile index 118feb61..d7eafeac 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,4 @@ -# Dockerfile for GNS3 server development - -FROM ubuntu:18.04 +FROM ubuntu:20.04 ENV DEBIAN_FRONTEND noninteractive @@ -12,12 +10,13 @@ ENV LC_ALL en_US.UTF-8 RUN apt-get update && apt-get install -y software-properties-common RUN add-apt-repository ppa:gns3/ppa RUN apt-get update && apt-get install -y \ + git \ locales \ python3-pip \ python3-dev \ qemu-system-x86 \ qemu-kvm \ - libvirt-bin \ + libvirt-daemon-system \ x11vnc RUN locale-gen en_US.UTF-8 diff --git a/gns3server/endpoints/compute/__init__.py b/gns3server/endpoints/compute/__init__.py index 045ecfeb..aaaba18a 100644 --- a/gns3server/endpoints/compute/__init__.py +++ b/gns3server/endpoints/compute/__init__.py @@ -14,7 +14,6 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -import asyncio from fastapi import FastAPI, Request from fastapi.responses import JSONResponse @@ -112,7 +111,7 @@ async def image_missing_error_handler(request: Request, exc: ImageMissingError): @compute_api.exception_handler(NodeError) -async def image_missing_error_handler(request: Request, exc: NodeError): +async def node_error_handler(request: Request, exc: NodeError): return JSONResponse( status_code=409, content={"message": str(exc), "exception": exc.__class__.__name__}, @@ -120,21 +119,12 @@ async def image_missing_error_handler(request: Request, exc: NodeError): @compute_api.exception_handler(UbridgeError) -async def image_missing_error_handler(request: Request, exc: UbridgeError): +async def ubridge_error_handler(request: Request, exc: UbridgeError): return JSONResponse( status_code=409, content={"message": str(exc), "exception": exc.__class__.__name__}, ) - -@compute_api.exception_handler(asyncio.CancelledError) -async def image_missing_error_handler(request: Request, exc: asyncio.CancelledError): - return JSONResponse( - status_code=408, - content={"message": "Request for '{}' cancelled".format(request.url.path)}, - ) - - compute_api.include_router(capabilities.router, tags=["Capabilities"]) compute_api.include_router(compute.router, tags=["Compute"]) compute_api.include_router(notifications.router, tags=["Notifications"]) diff --git a/gns3server/endpoints/controller/links.py b/gns3server/endpoints/controller/links.py index 209c261a..5c6bd97a 100644 --- a/gns3server/endpoints/controller/links.py +++ b/gns3server/endpoints/controller/links.py @@ -148,7 +148,7 @@ async def start_capture(capture_data: dict, link: Link = Depends(dep_link)): @router.post("/{link_id}/stop_capture", - status_code=status.HTTP_201_CREATED, + status_code=status.HTTP_204_NO_CONTENT, response_model=schemas.Link, responses=responses) async def stop_capture(link: Link = Depends(dep_link)): @@ -157,7 +157,6 @@ async def stop_capture(link: Link = Depends(dep_link)): """ await link.stop_capture() - return link.__json__() @router.delete("/{link_id}", @@ -201,7 +200,7 @@ async def pcap(request: Request, link: Link = Depends(dep_link)): headers['Router-Host'] = request.client.host body = await request.body() - async def compute_pcpa_stream(): + async def compute_pcap_stream(): connector = aiohttp.TCPConnector(limit=None, force_close=True) async with aiohttp.ClientSession(connector=connector, headers=headers) as session: @@ -211,4 +210,4 @@ async def pcap(request: Request, link: Link = Depends(dep_link)): break yield data - return StreamingResponse(compute_pcpa_stream(), media_type="application/vnd.tcpdump.pcap") + return StreamingResponse(compute_pcap_stream(), media_type="application/vnd.tcpdump.pcap") diff --git a/scripts/docker_dev_server.sh b/scripts/docker_dev_server.sh index 3efef413..c358deea 100755 --- a/scripts/docker_dev_server.sh +++ b/scripts/docker_dev_server.sh @@ -15,9 +15,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -# A docker server use for localy test a remote GNS3 server +# A docker server use for locally test a remote GNS3 server docker build -t gns3-server . -docker run -i -h gns3vm -p 8001:8001/tcp -t gns3-server python3 -m gns3server --port 8001 - - +docker run --privileged -i -h gns3vm -p 8001:8001/tcp -p 5000-5100:5000-5100 -t gns3-server python3 -m gns3server --port 8001