From 9cd3231de33fbe0fd7048848ec2d5921514ae332 Mon Sep 17 00:00:00 2001 From: Julien Duponchelle Date: Tue, 12 Jul 2016 12:17:19 +0200 Subject: [PATCH] Fix docker support in 2.0 --- .../handlers/api/compute/docker_handler.py | 3 +- gns3server/schemas/docker.py | 83 ++----------------- .../before/1_5_docker_remote.gns3 | 58 +++++++++++++ 3 files changed, 64 insertions(+), 80 deletions(-) create mode 100644 tests/topologies/1_5_docker_remote/before/1_5_docker_remote.gns3 diff --git a/gns3server/handlers/api/compute/docker_handler.py b/gns3server/handlers/api/compute/docker_handler.py index 31fc77ea..738d397c 100644 --- a/gns3server/handlers/api/compute/docker_handler.py +++ b/gns3server/handlers/api/compute/docker_handler.py @@ -26,7 +26,6 @@ from gns3server.schemas.nio import NIO_SCHEMA from gns3server.schemas.docker import ( DOCKER_CREATE_SCHEMA, DOCKER_OBJECT_SCHEMA, - DOCKER_UPDATE_SCHEMA, DOCKER_LIST_IMAGES_SCHEMA ) @@ -238,7 +237,7 @@ class DockerHandler: 409: "Conflict" }, description="Update a Docker instance", - input=DOCKER_UPDATE_SCHEMA, + input=DOCKER_OBJECT_SCHEMA, output=DOCKER_OBJECT_SCHEMA) def update(request, response): diff --git a/gns3server/schemas/docker.py b/gns3server/schemas/docker.py index d0d22ee3..d6c3263e 100644 --- a/gns3server/schemas/docker.py +++ b/gns3server/schemas/docker.py @@ -89,66 +89,6 @@ DOCKER_CREATE_SCHEMA = { "required": ["name", "image"] } - -DOCKER_UPDATE_SCHEMA = { - "$schema": "http://json-schema.org/draft-04/schema#", - "description": "Request validation to update a Docker container", - "type": "object", - "properties": { - "name": { - "description": "Docker container name", - "type": "string", - "minLength": 1, - }, - "console": { - "description": "Console TCP port", - "minimum": 1, - "maximum": 65535, - "type": ["integer", "null"] - }, - "console_resolution": { - "description": "Console resolution for VNC", - "type": ["string", "null"], - "pattern": "^[0-9]+x[0-9]+$" - }, - "console_type": { - "description": "console type", - "enum": ["telnet", "vnc", "http", "https"] - }, - "console_http_port": { - "description": "Internal port in the container for the HTTP server", - "type": "integer", - }, - "console_http_path": { - "description": "Path of the web interface", - "type": "string", - }, - "aux": { - "description": "Auxiliary TCP port", - "minimum": 1, - "maximum": 65535, - "type": ["integer", "null"] - }, - "start_command": { - "description": "Docker CMD entry", - "type": ["string", "null"], - "minLength": 0, - }, - "environment": { - "description": "Docker environment variables", - "type": ["string", "null"], - "minLength": 0, - }, - "adapters": { - "description": "Number of adapters", - "type": ["integer", "null"], - "minimum": 0, - "maximum": 99, - } - }, - "additionalProperties": False, -} - DOCKER_OBJECT_SCHEMA = { "$schema": "http://json-schema.org/draft-04/schema#", "description": "Docker container instance", @@ -196,21 +136,21 @@ DOCKER_OBJECT_SCHEMA = { "type": "string", }, "container_id": { - "description": "Docker container ID", + "description": "Docker container ID Read only", "type": "string", "minLength": 12, "maxLength": 64, "pattern": "^[a-f0-9]+$" }, "project_id": { - "description": "Project UUID", + "description": "Project UUID Read only", "type": "string", "minLength": 36, "maxLength": 36, "pattern": "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" }, "image": { - "description": "Docker image name", + "description": "Docker image name Read only", "type": "string", "minLength": 1, }, @@ -231,28 +171,15 @@ DOCKER_OBJECT_SCHEMA = { "minLength": 0, }, "node_directory": { - "description": "Path to the node working directory", + "description": "Path to the node working directory Read only", "type": "string" }, "status": { - "description": "VM status", + "description": "VM status Read only", "enum": ["started", "stopped", "suspended"] }, }, "additionalProperties": False, - "required": ["node_id", - "project_id", - "image", - "container_id", - "adapters", - "aux", - "console", - "console_type", - "console_resolution", - "start_command", - "environment", - "node_directory", - "status"] } diff --git a/tests/topologies/1_5_docker_remote/before/1_5_docker_remote.gns3 b/tests/topologies/1_5_docker_remote/before/1_5_docker_remote.gns3 new file mode 100644 index 00000000..365c04c0 --- /dev/null +++ b/tests/topologies/1_5_docker_remote/before/1_5_docker_remote.gns3 @@ -0,0 +1,58 @@ +{ + "auto_start": false, + "name": "untitled", + "project_id": "926e5c9e-887c-41b2-9214-fbd5fb628fe8", + "revision": 4, + "topology": { + "nodes": [ + { + "description": "Docker container", + "id": 1, + "label": { + "color": "#ff000000", + "font": "TypeWriter,10,-1,5,75,0,0,0,0,0", + "text": "remote_busybox-1", + "x": -20.4453125, + "y": -25.0 + }, + "ports": [ + { + "adapter_number": 0, + "id": 1, + "name": "eth0", + "port_number": 0 + } + ], + "properties": { + "adapters": 1, + "aux": 6002, + "console": 6001, + "console_http_path": "/", + "console_http_port": 80, + "console_resolution": "1024x768", + "console_type": "telnet", + "image": "busybox:latest", + "name": "remote_busybox-1" + }, + "server_id": 2, + "type": "DockerVM", + "vm_id": "d397ef5a-84f1-4b6b-9d44-671937ec7781", + "x": -53.5, + "y": -69.5 + } + ], + "servers": [ + { + "host": "127.0.0.1", + "id": 2, + "local": false, + "port": 8001, + "protocol": "http", + "user": "", + "vm": false + } + ] + }, + "type": "topology", + "version": "1.5.1dev1" +} \ No newline at end of file