2015-10-05 09:07:15 +00:00
|
|
|
#!/usr/bin/env python
|
|
|
|
#
|
|
|
|
# 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/>.
|
|
|
|
|
|
|
|
|
2016-05-11 17:35:36 +00:00
|
|
|
NODE_LIST_IMAGES_SCHEMA = {
|
2015-10-05 09:07:15 +00:00
|
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
|
|
"description": "List of disk images",
|
|
|
|
"type": "array",
|
|
|
|
"items": [
|
|
|
|
{
|
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
|
|
|
"filename": {
|
|
|
|
"description": "Image filename",
|
2015-11-05 15:28:11 +00:00
|
|
|
"type": "string",
|
|
|
|
"minLength": 1
|
2015-10-05 09:07:15 +00:00
|
|
|
},
|
|
|
|
"path": {
|
|
|
|
"description": "Image path",
|
2015-11-05 15:28:11 +00:00
|
|
|
"type": "string",
|
|
|
|
"minLength": 1
|
2015-10-05 09:07:15 +00:00
|
|
|
}
|
|
|
|
},
|
2015-11-05 15:28:11 +00:00
|
|
|
"required": ["filename", "path"],
|
2015-10-05 09:07:15 +00:00
|
|
|
"additionalProperties": False
|
|
|
|
}
|
|
|
|
],
|
|
|
|
"additionalProperties": False,
|
|
|
|
}
|
2016-02-09 15:07:33 +00:00
|
|
|
|
|
|
|
|
2016-05-11 17:35:36 +00:00
|
|
|
NODE_CAPTURE_SCHEMA = {
|
2016-02-09 15:07:33 +00:00
|
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
|
|
"description": "Request validation to start a packet capture on a port",
|
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
|
|
|
"capture_file_name": {
|
|
|
|
"description": "Capture file name",
|
|
|
|
"type": "string",
|
|
|
|
"minLength": 1,
|
|
|
|
},
|
|
|
|
"data_link_type": {
|
2016-04-21 10:14:09 +00:00
|
|
|
"description": "PCAP data link type (http://www.tcpdump.org/linktypes.html)",
|
|
|
|
"enum": ["DLT_ATM_RFC1483", "DLT_EN10MB", "DLT_FRELAY", "DLT_C_HDLC"]
|
2016-02-09 15:07:33 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"additionalProperties": False,
|
|
|
|
"required": ["capture_file_name"]
|
|
|
|
}
|
2016-03-10 20:51:29 +00:00
|
|
|
|
|
|
|
|
2016-05-11 17:35:36 +00:00
|
|
|
NODE_OBJECT_SCHEMA = {
|
2016-03-10 20:51:29 +00:00
|
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
2016-05-11 17:35:36 +00:00
|
|
|
"description": "A node object",
|
2016-03-10 20:51:29 +00:00
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
2016-04-15 15:57:06 +00:00
|
|
|
"compute_id": {
|
2016-04-18 18:55:22 +00:00
|
|
|
"description": "Compute identifier",
|
2016-03-11 14:06:14 +00:00
|
|
|
"type": "string"
|
|
|
|
},
|
|
|
|
"project_id": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Project UUID",
|
|
|
|
"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-03-10 20:51:29 +00:00
|
|
|
},
|
2016-05-11 17:35:36 +00:00
|
|
|
"node_id": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Node UUID",
|
2016-03-10 20:51:29 +00:00
|
|
|
"type": "string",
|
2016-03-11 14:06:14 +00:00
|
|
|
"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-03-10 20:51:29 +00:00
|
|
|
},
|
2016-05-11 17:35:36 +00:00
|
|
|
"node_type": {
|
|
|
|
"description": "Type of node",
|
2016-04-20 14:32:32 +00:00
|
|
|
"enum": ["docker", "dynamips", "vpcs", "virtualbox", "vmware", "iou", "qemu"]
|
2016-03-10 20:51:29 +00:00
|
|
|
},
|
2016-05-12 08:39:50 +00:00
|
|
|
"node_directory": {
|
|
|
|
"description": "Working directory of the node. Read only",
|
|
|
|
"type": ["null", "string"]
|
|
|
|
},
|
|
|
|
"command_line": {
|
|
|
|
"description": "Command line use to start the node",
|
|
|
|
"type": ["null", "string"]
|
|
|
|
},
|
2016-03-10 20:51:29 +00:00
|
|
|
"name": {
|
2016-05-11 17:35:36 +00:00
|
|
|
"description": "Node name",
|
2016-03-10 20:51:29 +00:00
|
|
|
"type": "string",
|
|
|
|
"minLength": 1,
|
|
|
|
},
|
|
|
|
"console": {
|
|
|
|
"description": "Console TCP port",
|
|
|
|
"minimum": 1,
|
|
|
|
"maximum": 65535,
|
|
|
|
"type": ["integer", "null"]
|
|
|
|
},
|
|
|
|
"console_type": {
|
|
|
|
"description": "Console type",
|
|
|
|
"enum": ["serial", "vnc", "telnet"]
|
|
|
|
},
|
|
|
|
"properties": {
|
|
|
|
"description": "Properties specific to an emulator",
|
|
|
|
"type": "object"
|
2016-05-12 17:15:46 +00:00
|
|
|
},
|
|
|
|
"status": {
|
|
|
|
"description": "Status of the node",
|
|
|
|
"enum": ["stopped", "started"]
|
2016-03-10 20:51:29 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"additionalProperties": False,
|
2016-05-11 17:35:36 +00:00
|
|
|
"required": ["name", "node_type", "compute_id"]
|
2016-03-10 20:51:29 +00:00
|
|
|
}
|
2016-04-18 16:56:03 +00:00
|
|
|
|
2016-05-11 17:35:36 +00:00
|
|
|
NODE_UPDATE_SCHEMA = NODE_OBJECT_SCHEMA
|
|
|
|
del NODE_UPDATE_SCHEMA["required"]
|