mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-25 00:08:11 +00:00
Fix Docker dev server script.
This commit is contained in:
parent
be6d4771d0
commit
f20e16074f
@ -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
|
||||
|
@ -14,7 +14,6 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
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"])
|
||||
|
@ -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")
|
||||
|
@ -15,9 +15,7 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# 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
|
||||
|
Loading…
Reference in New Issue
Block a user