2015-09-08 08:29:30 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
#
|
|
|
|
# Copyright (C) 2015 GNS3 Technologies Inc.
|
|
|
|
#
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
|
|
|
|
DOCKER_CREATE_SCHEMA = {
|
|
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
|
|
"description": "Request validation to create a new Docker container",
|
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
2016-05-11 17:35:36 +00:00
|
|
|
"node_id": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Node UUID",
|
2015-10-14 16:10:05 +00:00
|
|
|
"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}$"
|
2015-06-17 08:36:55 +00:00
|
|
|
},
|
2015-09-08 08:29:30 +00:00
|
|
|
"name": {
|
|
|
|
"description": "Docker container name",
|
|
|
|
"type": "string",
|
|
|
|
"minLength": 1,
|
|
|
|
},
|
2015-10-14 16:10:05 +00:00
|
|
|
"console": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Console TCP port",
|
2015-10-14 16:10:05 +00:00
|
|
|
"minimum": 1,
|
|
|
|
"maximum": 65535,
|
|
|
|
"type": ["integer", "null"]
|
|
|
|
},
|
2016-02-29 20:08:25 +00:00
|
|
|
"console_type": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Console type",
|
2016-05-03 14:49:33 +00:00
|
|
|
"enum": ["telnet", "vnc", "http", "https"]
|
2016-02-29 20:08:25 +00:00
|
|
|
},
|
2016-04-07 11:29:11 +00:00
|
|
|
"console_resolution": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Console resolution for VNC",
|
2016-04-07 11:29:11 +00:00
|
|
|
"type": ["string", "null"],
|
|
|
|
"pattern": "^[0-9]+x[0-9]+$"
|
|
|
|
},
|
2016-05-03 14:49:33 +00:00
|
|
|
"console_http_port": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Internal port in the container for the HTTP server",
|
2016-05-03 14:49:33 +00:00
|
|
|
"type": "integer",
|
|
|
|
},
|
|
|
|
"console_http_path": {
|
|
|
|
"description": "Path of the web interface",
|
|
|
|
"type": "string",
|
|
|
|
},
|
2016-02-29 09:38:30 +00:00
|
|
|
"aux": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Auxiliary TCP port",
|
2016-02-29 09:38:30 +00:00
|
|
|
"minimum": 1,
|
|
|
|
"maximum": 65535,
|
|
|
|
"type": ["integer", "null"]
|
|
|
|
},
|
2015-10-14 16:10:05 +00:00
|
|
|
"start_command": {
|
2015-06-17 08:36:55 +00:00
|
|
|
"description": "Docker CMD entry",
|
2015-10-14 16:10:05 +00:00
|
|
|
"type": ["string", "null"],
|
|
|
|
"minLength": 0,
|
2015-06-17 08:36:55 +00:00
|
|
|
},
|
2015-10-14 16:10:05 +00:00
|
|
|
"image": {
|
2015-09-08 08:29:30 +00:00
|
|
|
"description": "Docker image name",
|
|
|
|
"type": "string",
|
|
|
|
"minLength": 1,
|
|
|
|
},
|
|
|
|
"adapters": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Number of adapters",
|
2015-10-14 16:10:05 +00:00
|
|
|
"type": ["integer", "null"],
|
2015-09-08 08:29:30 +00:00
|
|
|
"minimum": 0,
|
2015-10-14 16:10:05 +00:00
|
|
|
"maximum": 99,
|
2015-06-15 17:30:09 +00:00
|
|
|
},
|
2015-10-14 16:10:05 +00:00
|
|
|
"environment": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Docker environment variables",
|
2015-10-14 16:10:05 +00:00
|
|
|
"type": ["string", "null"],
|
|
|
|
"minLength": 0,
|
|
|
|
}
|
|
|
|
|
2015-09-08 08:29:30 +00:00
|
|
|
},
|
|
|
|
"additionalProperties": False,
|
2016-05-16 16:32:29 +00:00
|
|
|
"required": ["name", "image"]
|
2015-09-08 08:29:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
DOCKER_OBJECT_SCHEMA = {
|
|
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Docker container instance",
|
2015-09-08 08:29:30 +00:00
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
|
|
|
"name": {
|
|
|
|
"description": "Docker container name",
|
|
|
|
"type": "string",
|
|
|
|
"minLength": 1,
|
|
|
|
},
|
2016-05-11 17:35:36 +00:00
|
|
|
"node_id": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Node UUID",
|
2015-06-17 08:36:55 +00:00
|
|
|
"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}$"
|
|
|
|
},
|
2016-02-29 09:38:30 +00:00
|
|
|
"aux": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Auxiliary TCP port",
|
2016-02-29 09:38:30 +00:00
|
|
|
"minimum": 1,
|
|
|
|
"maximum": 65535,
|
2016-04-07 11:29:11 +00:00
|
|
|
"type": "integer"
|
2016-02-29 09:38:30 +00:00
|
|
|
},
|
2015-10-14 16:10:05 +00:00
|
|
|
"console": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Console TCP port",
|
2015-10-14 16:10:05 +00:00
|
|
|
"minimum": 1,
|
|
|
|
"maximum": 65535,
|
2016-04-07 11:29:11 +00:00
|
|
|
"type": "integer"
|
|
|
|
},
|
|
|
|
"console_resolution": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Console resolution for VNC",
|
2016-04-07 11:29:11 +00:00
|
|
|
"type": "string",
|
|
|
|
"pattern": "^[0-9]+x[0-9]+$"
|
2015-10-14 16:10:05 +00:00
|
|
|
},
|
2016-02-29 20:08:25 +00:00
|
|
|
"console_type": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Console type",
|
2016-05-03 14:49:33 +00:00
|
|
|
"enum": ["telnet", "vnc", "http", "https"]
|
|
|
|
},
|
|
|
|
"console_http_port": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Internal port in the container for the HTTP server",
|
2016-05-03 14:49:33 +00:00
|
|
|
"type": "integer",
|
|
|
|
},
|
|
|
|
"console_http_path": {
|
|
|
|
"description": "Path of the web interface",
|
|
|
|
"type": "string",
|
2016-02-29 20:08:25 +00:00
|
|
|
},
|
2015-10-14 16:10:05 +00:00
|
|
|
"container_id": {
|
2016-07-12 10:17:19 +00:00
|
|
|
"description": "Docker container ID Read only",
|
2015-09-08 08:29:30 +00:00
|
|
|
"type": "string",
|
2015-10-14 16:10:05 +00:00
|
|
|
"minLength": 12,
|
2015-09-08 08:29:30 +00:00
|
|
|
"maxLength": 64,
|
2015-10-14 16:10:05 +00:00
|
|
|
"pattern": "^[a-f0-9]+$"
|
2015-09-08 08:29:30 +00:00
|
|
|
},
|
|
|
|
"project_id": {
|
2016-07-12 10:17:19 +00:00
|
|
|
"description": "Project UUID Read only",
|
2015-09-08 08:29:30 +00:00
|
|
|
"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": {
|
2016-07-12 10:17:19 +00:00
|
|
|
"description": "Docker image name Read only",
|
2015-09-08 08:29:30 +00:00
|
|
|
"type": "string",
|
|
|
|
"minLength": 1,
|
|
|
|
},
|
|
|
|
"adapters": {
|
|
|
|
"description": "number of adapters",
|
2015-10-14 16:10:05 +00:00
|
|
|
"type": ["integer", "null"],
|
2015-09-08 08:29:30 +00:00
|
|
|
"minimum": 0,
|
2015-10-14 16:10:05 +00:00
|
|
|
"maximum": 99,
|
2015-09-08 08:29:30 +00:00
|
|
|
},
|
2015-10-14 16:10:05 +00:00
|
|
|
"start_command": {
|
|
|
|
"description": "Docker CMD entry",
|
|
|
|
"type": ["string", "null"],
|
|
|
|
"minLength": 0,
|
|
|
|
},
|
|
|
|
"environment": {
|
|
|
|
"description": "Docker environment",
|
|
|
|
"type": ["string", "null"],
|
|
|
|
"minLength": 0,
|
2016-02-12 10:57:56 +00:00
|
|
|
},
|
2016-05-12 08:39:50 +00:00
|
|
|
"node_directory": {
|
2016-07-12 10:17:19 +00:00
|
|
|
"description": "Path to the node working directory Read only",
|
2016-02-12 10:57:56 +00:00
|
|
|
"type": "string"
|
2016-05-17 17:51:06 +00:00
|
|
|
},
|
|
|
|
"status": {
|
2016-07-12 10:17:19 +00:00
|
|
|
"description": "VM status Read only",
|
2016-05-17 17:51:06 +00:00
|
|
|
"enum": ["started", "stopped", "suspended"]
|
|
|
|
},
|
2015-09-08 08:29:30 +00:00
|
|
|
},
|
|
|
|
"additionalProperties": False,
|
2015-10-14 16:10:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
DOCKER_LIST_IMAGES_SCHEMA = {
|
|
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
|
|
"description": "Docker list of images",
|
|
|
|
"type": "array",
|
|
|
|
"items": [
|
|
|
|
{
|
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
|
|
|
"image": {
|
|
|
|
"description": "Docker image name",
|
|
|
|
"type": "string",
|
|
|
|
"minLength": 1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
2015-09-08 08:29:30 +00:00
|
|
|
}
|