2016-03-03 15:02:27 +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/>.
|
|
|
|
|
2017-04-11 08:57:01 +00:00
|
|
|
import copy
|
2016-08-29 13:53:10 +00:00
|
|
|
from .capabilities import CAPABILITIES_SCHEMA
|
2016-03-03 15:02:27 +00:00
|
|
|
|
2016-04-15 15:57:06 +00:00
|
|
|
COMPUTE_CREATE_SCHEMA = {
|
2016-03-03 15:02:27 +00:00
|
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
2016-04-15 15:57:06 +00:00
|
|
|
"description": "Request validation to register a GNS3 compute instance",
|
2016-03-03 15:02:27 +00:00
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
2016-04-15 15:57:06 +00:00
|
|
|
"compute_id": {
|
2016-03-03 15:02:27 +00:00
|
|
|
"description": "Server identifier",
|
|
|
|
"type": "string"
|
|
|
|
},
|
2016-05-23 09:20:52 +00:00
|
|
|
"name": {
|
|
|
|
"description": "Server name",
|
|
|
|
"type": "string"
|
|
|
|
},
|
2016-03-03 15:02:27 +00:00
|
|
|
"protocol": {
|
|
|
|
"description": "Server protocol",
|
|
|
|
"enum": ["http", "https"]
|
|
|
|
},
|
|
|
|
"host": {
|
|
|
|
"description": "Server host",
|
|
|
|
"type": "string"
|
|
|
|
},
|
|
|
|
"port": {
|
|
|
|
"description": "Server port",
|
|
|
|
"type": "integer"
|
|
|
|
},
|
|
|
|
"user": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "User for authentication",
|
2016-05-26 08:11:11 +00:00
|
|
|
"type": ["string", "null"]
|
2016-03-03 15:02:27 +00:00
|
|
|
},
|
|
|
|
"password": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "Password for authentication",
|
2016-05-26 08:11:11 +00:00
|
|
|
"type": ["string", "null"]
|
2016-03-03 15:02:27 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
"additionalProperties": False,
|
2017-04-11 08:57:01 +00:00
|
|
|
"required": ["protocol", "host", "port"]
|
2016-03-03 15:02:27 +00:00
|
|
|
}
|
|
|
|
|
2017-04-11 08:57:01 +00:00
|
|
|
COMPUTE_UPDATE_SCHEMA = copy.deepcopy(COMPUTE_CREATE_SCHEMA)
|
2016-05-25 09:48:09 +00:00
|
|
|
del COMPUTE_UPDATE_SCHEMA["required"]
|
2016-05-25 09:27:41 +00:00
|
|
|
|
2016-04-15 15:57:06 +00:00
|
|
|
COMPUTE_OBJECT_SCHEMA = {
|
2016-03-03 15:02:27 +00:00
|
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
2016-04-15 15:57:06 +00:00
|
|
|
"description": "Request validation to a GNS3 compute object instance",
|
2016-03-03 15:02:27 +00:00
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
2016-04-15 15:57:06 +00:00
|
|
|
"compute_id": {
|
2016-03-03 15:02:27 +00:00
|
|
|
"description": "Server identifier",
|
|
|
|
"type": "string"
|
|
|
|
},
|
2016-05-23 09:20:52 +00:00
|
|
|
"name": {
|
|
|
|
"description": "Server name",
|
|
|
|
"type": "string"
|
|
|
|
},
|
2016-03-03 15:02:27 +00:00
|
|
|
"protocol": {
|
|
|
|
"description": "Server protocol",
|
|
|
|
"enum": ["http", "https"]
|
|
|
|
},
|
|
|
|
"host": {
|
|
|
|
"description": "Server host",
|
|
|
|
"type": "string"
|
|
|
|
},
|
|
|
|
"port": {
|
|
|
|
"description": "Server port",
|
|
|
|
"type": "integer"
|
|
|
|
},
|
|
|
|
"user": {
|
2016-05-13 01:07:25 +00:00
|
|
|
"description": "User for authentication",
|
2016-05-26 08:11:11 +00:00
|
|
|
"type": ["string", "null"]
|
2016-03-03 15:02:27 +00:00
|
|
|
},
|
|
|
|
"connected": {
|
2018-11-27 11:14:51 +00:00
|
|
|
"description": "Whether the controller is connected to the compute or not",
|
2016-03-03 15:02:27 +00:00
|
|
|
"type": "boolean"
|
|
|
|
},
|
2016-06-30 07:45:11 +00:00
|
|
|
"cpu_usage_percent": {
|
|
|
|
"description": "CPU usage of the compute. Read only",
|
|
|
|
"type": ["number", "null"],
|
|
|
|
"maximum": 100,
|
|
|
|
"minimum": 0
|
|
|
|
},
|
|
|
|
"memory_usage_percent": {
|
|
|
|
"description": "RAM usage of the compute. Read only",
|
|
|
|
"type": ["number", "null"],
|
|
|
|
"maximum": 100,
|
|
|
|
"minimum": 0
|
|
|
|
},
|
2018-08-22 09:54:43 +00:00
|
|
|
"last_error": {
|
|
|
|
"description": "Last error on the compute",
|
|
|
|
"type": ["string", "null"]
|
|
|
|
},
|
2016-08-29 13:53:10 +00:00
|
|
|
"capabilities": CAPABILITIES_SCHEMA
|
2016-03-03 15:02:27 +00:00
|
|
|
},
|
|
|
|
"additionalProperties": False,
|
2016-07-11 13:36:52 +00:00
|
|
|
"required": ["compute_id", "protocol", "host", "port", "name"]
|
2016-03-03 15:02:27 +00:00
|
|
|
}
|
2017-10-13 09:03:56 +00:00
|
|
|
|
|
|
|
COMPUTE_ENDPOINT_OUTPUT_OBJECT_SCHEMA = {
|
|
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
|
|
"description": "Output schema for obtaining endpoint on compute",
|
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
|
|
|
"endpoint": {
|
|
|
|
"description": "URL to endpoint on specific compute and to particular action",
|
|
|
|
"type": "string"
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"additionalProperties": False,
|
|
|
|
}
|
|
|
|
|
2018-10-05 10:48:20 +00:00
|
|
|
COMPUTE_PORTS_OBJECT_SCHEMA = {
|
|
|
|
"$schema": "http://json-schema.org/draft-04/schema#",
|
|
|
|
"description": "Output schema for open ports on a compute",
|
|
|
|
"type": "object",
|
|
|
|
"properties": {
|
|
|
|
"console_port_range": {
|
|
|
|
"description": "Console port range",
|
|
|
|
"type": "array",
|
|
|
|
"uniqueItems": True,
|
|
|
|
"minItems": 2,
|
|
|
|
"maxItems": 2,
|
|
|
|
"items": {
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"maximum": 65535
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"console_ports": {
|
|
|
|
"description": "Console ports used by the compute",
|
|
|
|
"type": "array",
|
|
|
|
"uniqueItems": True,
|
|
|
|
"items": {
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"maximum": 65535
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"udp_port_range": {
|
|
|
|
"description": "UDP port range",
|
|
|
|
"type": "array",
|
|
|
|
"uniqueItems": True,
|
|
|
|
"minItems": 2,
|
|
|
|
"maxItems": 2,
|
|
|
|
"items": {
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"maximum": 65535
|
|
|
|
}
|
|
|
|
},
|
|
|
|
"udp_ports": {
|
|
|
|
"description": "UDP ports used by the compute",
|
|
|
|
"type": "array",
|
|
|
|
"uniqueItems": True,
|
|
|
|
"items": {
|
|
|
|
"type": "integer",
|
|
|
|
"minimum": 1,
|
|
|
|
"maximum": 65535
|
|
|
|
}
|
|
|
|
},
|
|
|
|
},
|
|
|
|
"additionalProperties": False,
|
|
|
|
}
|
|
|
|
|