diff --git a/gns3server/compute/qemu/qemu_vm.py b/gns3server/compute/qemu/qemu_vm.py
index 64e5c637..68bd9e75 100644
--- a/gns3server/compute/qemu/qemu_vm.py
+++ b/gns3server/compute/qemu/qemu_vm.py
@@ -44,11 +44,11 @@ from ..error import NodeError, ImageMissingError
from ..nios.nio_udp import NIOUDP
from ..nios.nio_tap import NIOTAP
from ..base_node import BaseNode
-from ...schemas.qemu import QEMU_OBJECT_SCHEMA, QEMU_PLATFORMS
from ...utils.asyncio import monitor_process
from ...utils.images import md5sum
from ...utils import macaddress_to_int, int_to_macaddress
+from gns3server.schemas.qemu_nodes import Qemu, QemuPlatform
import logging
log = logging.getLogger(__name__)
@@ -216,7 +216,10 @@ class QemuVM(BaseNode):
self._platform = "i386"
else:
self._platform = re.sub(r'^qemu-system-(.*)$', r'\1', qemu_bin, re.IGNORECASE)
- if self._platform.split(".")[0] not in QEMU_PLATFORMS:
+
+ try:
+ QemuPlatform(self._platform.split(".")[0])
+ except ValueError:
raise QemuError("Platform {} is unknown".format(self._platform))
log.info('QEMU VM "{name}" [{id}] has set the QEMU path to {qemu_path}'.format(name=self._name,
id=self._id,
@@ -2288,7 +2291,7 @@ class QemuVM(BaseNode):
"node_directory": self.working_path
}
# Qemu has a long list of options. The JSON schema is the single source of information
- for field in QEMU_OBJECT_SCHEMA["required"]:
+ for field in Qemu.schema()["properties"]:
if field not in answer:
try:
answer[field] = getattr(self, field)
diff --git a/gns3server/controller/schemas/__init__.py b/gns3server/controller/schemas/__init__.py
deleted file mode 100644
index dcb72c6c..00000000
--- a/gns3server/controller/schemas/__init__.py
+++ /dev/null
@@ -1,36 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2020 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 .
-
-from .vpcs_templates import VPCSTemplate
-from .cloud_templates import CloudTemplate
-from .iou_templates import IOUTemplate
-from .docker_templates import DockerTemplate
-from .ethernet_hub_templates import EthernetHubTemplate
-from .ethernet_switch_templates import EthernetSwitchTemplate
-from .virtualbox_templates import VirtualBoxTemplate
-from .vmware_templates import VMwareTemplate
-from .qemu_templates import QemuTemplate
-from .dynamips_templates import (
- DynamipsTemplate,
- C1700DynamipsTemplate,
- C2600DynamipsTemplate,
- C2691DynamipsTemplate,
- C3600DynamipsTemplate,
- C3725DynamipsTemplate,
- C3745DynamipsTemplate,
- C7200DynamipsTemplate
-)
diff --git a/gns3server/controller/schemas/topology.py b/gns3server/controller/schemas/topology.py
deleted file mode 100644
index 162b2eea..00000000
--- a/gns3server/controller/schemas/topology.py
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/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 .
-
-#
-# This file contains the validation for checking a .gns3 file
-#
-
-from gns3server.endpoints.schemas.computes import Compute
-from gns3server.endpoints.schemas.drawings import Drawing
-from gns3server.endpoints.schemas.links import Link
-from gns3server.endpoints.schemas.nodes import Node
-
-from gns3server.endpoints.schemas.projects import (
- Supplier,
- Variable
-)
-
-from pydantic import BaseModel, Field
-from typing import Optional, List
-from enum import Enum
-from uuid import UUID
-
-
-class TopologyType(str, Enum):
-
- topology = "topology"
-
-
-class TopologyContent(BaseModel):
-
- computes: List[Compute] = Field(..., description="List of computes")
- drawings: List[Drawing] = Field(..., description="List of drawings")
- links: List[Link] = Field(..., description="List of links")
- nodes: List[Node] = Field(..., description="List of nodes")
-
-
-class Topology(BaseModel):
-
- project_id: UUID = Field(..., description="Project UUID")
- type: TopologyType = Field(..., description="Type of file. It's always topology")
- revision: int = Field(..., description="Version of the .gns3 specification")
- version: str = Field(..., description="Version of the GNS3 software which have update the file for the last time")
- name: str = Field(..., description="Name of the project")
- topology: TopologyContent = Field(..., description="Topology content")
- auto_start: Optional[bool] = Field(None, description="Start the topology when opened")
- auto_close: Optional[bool] = Field(None, description="Close the topology when no client is connected")
- scene_height: Optional[int] = Field(None, description="Height of the drawing area")
- scene_width: Optional[int] = Field(None, description="Width of the drawing area")
- zoom: Optional[int] = Field(None, description="Zoom of the drawing area")
- show_layers: Optional[bool] = Field(None, description="Show layers on the drawing area")
- snap_to_grid: Optional[bool] = Field(None, description="Snap to grid on the drawing area")
- show_grid: Optional[bool] = Field(None, description="Show the grid on the drawing area")
- grid_size: Optional[int] = Field(None, description="Grid size for the drawing area for nodes")
- drawing_grid_size: Optional[int] = Field(None, description="Grid size for the drawing area for drawings")
- show_interface_labels: Optional[bool] = Field(None, description="Show interface labels on the drawing area")
- supplier: Optional[Supplier] = Field(None, description="Supplier of the project")
- variables: Optional[List[Variable]] = Field(None, description="Variables required to run the project")
-
-
-def main():
-
- import json
- import sys
-
- with open(sys.argv[1]) as f:
- data = json.load(f)
- Topology.parse_obj(data)
-
-
-if __name__ == '__main__':
- main()
diff --git a/gns3server/controller/template.py b/gns3server/controller/template.py
index 1774ddac..a5c725de 100644
--- a/gns3server/controller/template.py
+++ b/gns3server/controller/template.py
@@ -20,7 +20,7 @@ import uuid
from pydantic import ValidationError
from fastapi.encoders import jsonable_encoder
-from gns3server.controller import schemas
+from gns3server import schemas
import logging
log = logging.getLogger(__name__)
diff --git a/gns3server/controller/topology.py b/gns3server/controller/topology.py
index bdf65c11..f934b569 100644
--- a/gns3server/controller/topology.py
+++ b/gns3server/controller/topology.py
@@ -31,8 +31,8 @@ from ..utils.qt import qt_font_to_style
from ..compute.dynamips import PLATFORMS_DEFAULT_RAM
from .controller_error import ControllerError
-from gns3server.controller.schemas.topology import Topology
-from gns3server.endpoints.schemas.dynamips_nodes import DynamipsCreate, NodeStatus
+from gns3server.schemas.topology import Topology
+from gns3server.schemas.dynamips_nodes import DynamipsCreate
import logging
log = logging.getLogger(__name__)
diff --git a/gns3server/endpoints/compute/atm_switch_nodes.py b/gns3server/endpoints/compute/atm_switch_nodes.py
index 01fefef8..9f862967 100644
--- a/gns3server/endpoints/compute/atm_switch_nodes.py
+++ b/gns3server/endpoints/compute/atm_switch_nodes.py
@@ -26,7 +26,7 @@ from fastapi.encoders import jsonable_encoder
from fastapi.responses import StreamingResponse
from uuid import UUID
-from gns3server.endpoints import schemas
+from gns3server import schemas
from gns3server.compute.dynamips import Dynamips
from gns3server.compute.dynamips.nodes.atm_switch import ATMSwitch
diff --git a/gns3server/endpoints/compute/capabilities.py b/gns3server/endpoints/compute/capabilities.py
index bf930c38..67f0d567 100644
--- a/gns3server/endpoints/compute/capabilities.py
+++ b/gns3server/endpoints/compute/capabilities.py
@@ -27,7 +27,7 @@ from fastapi import APIRouter
from gns3server.version import __version__
from gns3server.compute import MODULES
from gns3server.utils.path import get_default_project_directory
-from gns3server.endpoints import schemas
+from gns3server import schemas
router = APIRouter()
diff --git a/gns3server/endpoints/compute/cloud_nodes.py b/gns3server/endpoints/compute/cloud_nodes.py
index af22cfa3..85a7c632 100644
--- a/gns3server/endpoints/compute/cloud_nodes.py
+++ b/gns3server/endpoints/compute/cloud_nodes.py
@@ -27,7 +27,7 @@ from fastapi.responses import StreamingResponse
from typing import Union
from uuid import UUID
-from gns3server.endpoints import schemas
+from gns3server import schemas
from gns3server.compute.builtin import Builtin
from gns3server.compute.builtin.nodes.cloud import Cloud
diff --git a/gns3server/endpoints/compute/compute.py b/gns3server/endpoints/compute/compute.py
index 225c9bd9..854428e0 100644
--- a/gns3server/endpoints/compute/compute.py
+++ b/gns3server/endpoints/compute/compute.py
@@ -33,7 +33,7 @@ from gns3server.utils.interfaces import interfaces
from gns3server.compute.qemu import Qemu
from gns3server.compute.virtualbox import VirtualBox
from gns3server.compute.vmware import VMware
-from gns3server.endpoints import schemas
+from gns3server import schemas
from fastapi import APIRouter, HTTPException, Body, status
from fastapi.encoders import jsonable_encoder
diff --git a/gns3server/endpoints/compute/docker_nodes.py b/gns3server/endpoints/compute/docker_nodes.py
index 199c1664..44ff5e06 100644
--- a/gns3server/endpoints/compute/docker_nodes.py
+++ b/gns3server/endpoints/compute/docker_nodes.py
@@ -26,7 +26,7 @@ from fastapi.encoders import jsonable_encoder
from fastapi.responses import StreamingResponse
from uuid import UUID
-from gns3server.endpoints import schemas
+from gns3server import schemas
from gns3server.compute.docker import Docker
from gns3server.compute.docker.docker_vm import DockerVM
diff --git a/gns3server/endpoints/compute/dynamips_nodes.py b/gns3server/endpoints/compute/dynamips_nodes.py
index bee788ba..890e4d30 100644
--- a/gns3server/endpoints/compute/dynamips_nodes.py
+++ b/gns3server/endpoints/compute/dynamips_nodes.py
@@ -31,7 +31,7 @@ from uuid import UUID
from gns3server.compute.dynamips import Dynamips
from gns3server.compute.dynamips.nodes.router import Router
from gns3server.compute.dynamips.dynamips_error import DynamipsError
-from gns3server.endpoints import schemas
+from gns3server import schemas
router = APIRouter()
diff --git a/gns3server/endpoints/compute/ethernet_hub_nodes.py b/gns3server/endpoints/compute/ethernet_hub_nodes.py
index bfb7aef1..c25aa5d8 100644
--- a/gns3server/endpoints/compute/ethernet_hub_nodes.py
+++ b/gns3server/endpoints/compute/ethernet_hub_nodes.py
@@ -28,7 +28,7 @@ from uuid import UUID
from gns3server.compute.dynamips import Dynamips
from gns3server.compute.dynamips.nodes.ethernet_hub import EthernetHub
-from gns3server.endpoints import schemas
+from gns3server import schemas
router = APIRouter()
diff --git a/gns3server/endpoints/compute/ethernet_switch_nodes.py b/gns3server/endpoints/compute/ethernet_switch_nodes.py
index be7e37aa..42fab5e5 100644
--- a/gns3server/endpoints/compute/ethernet_switch_nodes.py
+++ b/gns3server/endpoints/compute/ethernet_switch_nodes.py
@@ -28,7 +28,7 @@ from uuid import UUID
from gns3server.compute.dynamips import Dynamips
from gns3server.compute.dynamips.nodes.ethernet_switch import EthernetSwitch
-from gns3server.endpoints import schemas
+from gns3server import schemas
router = APIRouter()
diff --git a/gns3server/endpoints/compute/frame_relay_switch_nodes.py b/gns3server/endpoints/compute/frame_relay_switch_nodes.py
index 911c6f08..daff363e 100644
--- a/gns3server/endpoints/compute/frame_relay_switch_nodes.py
+++ b/gns3server/endpoints/compute/frame_relay_switch_nodes.py
@@ -26,7 +26,7 @@ from fastapi.encoders import jsonable_encoder
from fastapi.responses import StreamingResponse
from uuid import UUID
-from gns3server.endpoints import schemas
+from gns3server import schemas
from gns3server.compute.dynamips import Dynamips
from gns3server.compute.dynamips.nodes.frame_relay_switch import FrameRelaySwitch
diff --git a/gns3server/endpoints/compute/iou_nodes.py b/gns3server/endpoints/compute/iou_nodes.py
index 667bb9e4..21995938 100644
--- a/gns3server/endpoints/compute/iou_nodes.py
+++ b/gns3server/endpoints/compute/iou_nodes.py
@@ -27,7 +27,7 @@ from fastapi.responses import StreamingResponse
from typing import Union
from uuid import UUID
-from gns3server.endpoints import schemas
+from gns3server import schemas
from gns3server.compute.iou import IOU
from gns3server.compute.iou.iou_vm import IOUVM
diff --git a/gns3server/endpoints/compute/nat_nodes.py b/gns3server/endpoints/compute/nat_nodes.py
index a2c40f89..62a5cb3b 100644
--- a/gns3server/endpoints/compute/nat_nodes.py
+++ b/gns3server/endpoints/compute/nat_nodes.py
@@ -27,7 +27,7 @@ from fastapi.responses import StreamingResponse
from typing import Union
from uuid import UUID
-from gns3server.endpoints import schemas
+from gns3server import schemas
from gns3server.compute.builtin import Builtin
from gns3server.compute.builtin.nodes.nat import Nat
diff --git a/gns3server/endpoints/compute/projects.py b/gns3server/endpoints/compute/projects.py
index 8d392da9..dda59bc7 100644
--- a/gns3server/endpoints/compute/projects.py
+++ b/gns3server/endpoints/compute/projects.py
@@ -32,7 +32,7 @@ from uuid import UUID
from gns3server.compute.project_manager import ProjectManager
from gns3server.compute.project import Project
-from gns3server.endpoints import schemas
+from gns3server import schemas
router = APIRouter()
diff --git a/gns3server/endpoints/compute/qemu_nodes.py b/gns3server/endpoints/compute/qemu_nodes.py
index 222ac001..c1988fcd 100644
--- a/gns3server/endpoints/compute/qemu_nodes.py
+++ b/gns3server/endpoints/compute/qemu_nodes.py
@@ -27,7 +27,7 @@ from fastapi.encoders import jsonable_encoder
from fastapi.responses import StreamingResponse
from uuid import UUID
-from gns3server.endpoints import schemas
+from gns3server import schemas
from gns3server.compute.project_manager import ProjectManager
from gns3server.compute.qemu import Qemu
from gns3server.compute.qemu.qemu_vm import QemuVM
diff --git a/gns3server/endpoints/compute/virtualbox_nodes.py b/gns3server/endpoints/compute/virtualbox_nodes.py
index 661560cf..441d782b 100644
--- a/gns3server/endpoints/compute/virtualbox_nodes.py
+++ b/gns3server/endpoints/compute/virtualbox_nodes.py
@@ -26,7 +26,7 @@ from fastapi.encoders import jsonable_encoder
from fastapi.responses import StreamingResponse
from uuid import UUID
-from gns3server.endpoints import schemas
+from gns3server import schemas
from gns3server.compute.virtualbox import VirtualBox
from gns3server.compute.virtualbox.virtualbox_error import VirtualBoxError
from gns3server.compute.project_manager import ProjectManager
diff --git a/gns3server/endpoints/compute/vmware_nodes.py b/gns3server/endpoints/compute/vmware_nodes.py
index b456ca0c..12b435b1 100644
--- a/gns3server/endpoints/compute/vmware_nodes.py
+++ b/gns3server/endpoints/compute/vmware_nodes.py
@@ -26,7 +26,7 @@ from fastapi.encoders import jsonable_encoder
from fastapi.responses import StreamingResponse
from uuid import UUID
-from gns3server.endpoints import schemas
+from gns3server import schemas
from gns3server.compute.vmware import VMware
from gns3server.compute.project_manager import ProjectManager
from gns3server.compute.vmware.vmware_vm import VMwareVM
diff --git a/gns3server/endpoints/compute/vpcs_nodes.py b/gns3server/endpoints/compute/vpcs_nodes.py
index abd64930..a661ad66 100644
--- a/gns3server/endpoints/compute/vpcs_nodes.py
+++ b/gns3server/endpoints/compute/vpcs_nodes.py
@@ -26,7 +26,7 @@ from fastapi.encoders import jsonable_encoder
from fastapi.responses import StreamingResponse
from uuid import UUID
-from gns3server.endpoints import schemas
+from gns3server import schemas
from gns3server.compute.vpcs import VPCS
from gns3server.compute.vpcs.vpcs_vm import VPCSVM
diff --git a/gns3server/endpoints/controller/computes.py b/gns3server/endpoints/controller/computes.py
index 8a76b239..8d33e4b6 100644
--- a/gns3server/endpoints/controller/computes.py
+++ b/gns3server/endpoints/controller/computes.py
@@ -25,22 +25,21 @@ from typing import List, Union
from uuid import UUID
from gns3server.controller import Controller
-from gns3server.endpoints.schemas.common import ErrorMessage
-from gns3server.endpoints import schemas
+from gns3server import schemas
router = APIRouter()
responses = {
- 404: {"model": ErrorMessage, "description": "Compute not found"}
+ 404: {"model": schemas.ErrorMessage, "description": "Compute not found"}
}
@router.post("",
status_code=status.HTTP_201_CREATED,
response_model=schemas.Compute,
- responses={404: {"model": ErrorMessage, "description": "Could not connect to compute"},
- 409: {"model": ErrorMessage, "description": "Could not create compute"},
- 401: {"model": ErrorMessage, "description": "Invalid authentication for compute"}})
+ responses={404: {"model": schemas.ErrorMessage, "description": "Could not connect to compute"},
+ 409: {"model": schemas.ErrorMessage, "description": "Could not create compute"},
+ 401: {"model": schemas.ErrorMessage, "description": "Invalid authentication for compute"}})
async def create_compute(compute_data: schemas.ComputeCreate):
"""
Create a new compute on the controller.
diff --git a/gns3server/endpoints/controller/controller.py b/gns3server/endpoints/controller/controller.py
index a1e3d0c9..458eb9e5 100644
--- a/gns3server/endpoints/controller/controller.py
+++ b/gns3server/endpoints/controller/controller.py
@@ -26,8 +26,7 @@ from gns3server.config import Config
from gns3server.controller import Controller
from gns3server.version import __version__
from gns3server.controller.controller_error import ControllerError, ControllerForbiddenError
-from gns3server.endpoints.schemas.common import ErrorMessage
-from gns3server.endpoints import schemas
+from gns3server import schemas
import logging
@@ -38,7 +37,7 @@ router = APIRouter()
@router.post("/shutdown",
status_code=status.HTTP_204_NO_CONTENT,
- responses={403: {"model": ErrorMessage, "description": "Server shutdown not allowed"}})
+ responses={403: {"model": schemas.ErrorMessage, "description": "Server shutdown not allowed"}})
async def shutdown():
"""
Shutdown the local server
@@ -85,7 +84,7 @@ def version():
@router.post("/version",
response_model=schemas.Version,
response_model_exclude_defaults=True,
- responses={409: {"model": ErrorMessage, "description": "Invalid version"}})
+ responses={409: {"model": schemas.ErrorMessage, "description": "Invalid version"}})
def check_version(version: schemas.Version):
"""
Check if version is the same as the server.
diff --git a/gns3server/endpoints/controller/drawings.py b/gns3server/endpoints/controller/drawings.py
index fbb3967c..2baf14db 100644
--- a/gns3server/endpoints/controller/drawings.py
+++ b/gns3server/endpoints/controller/drawings.py
@@ -25,18 +25,17 @@ from typing import List
from uuid import UUID
from gns3server.controller import Controller
-from gns3server.endpoints.schemas.common import ErrorMessage
-from gns3server.endpoints.schemas.drawings import Drawing
+from gns3server import schemas
router = APIRouter()
responses = {
- 404: {"model": ErrorMessage, "description": "Project or drawing not found"}
+ 404: {"model": schemas.ErrorMessage, "description": "Project or drawing not found"}
}
@router.get("",
- response_model=List[Drawing],
+ response_model=List[schemas.Drawing],
response_model_exclude_unset=True)
async def get_drawings(project_id: UUID):
"""
@@ -49,9 +48,9 @@ async def get_drawings(project_id: UUID):
@router.post("",
status_code=status.HTTP_201_CREATED,
- response_model=Drawing,
+ response_model=schemas.Drawing,
responses=responses)
-async def create_drawing(project_id: UUID, drawing_data: Drawing):
+async def create_drawing(project_id: UUID, drawing_data: schemas.Drawing):
"""
Create a new drawing.
"""
@@ -62,7 +61,7 @@ async def create_drawing(project_id: UUID, drawing_data: Drawing):
@router.get("/{drawing_id}",
- response_model=Drawing,
+ response_model=schemas.Drawing,
response_model_exclude_unset=True,
responses=responses)
async def get_drawing(project_id: UUID, drawing_id: UUID):
@@ -76,10 +75,10 @@ async def get_drawing(project_id: UUID, drawing_id: UUID):
@router.put("/{drawing_id}",
- response_model=Drawing,
+ response_model=schemas.Drawing,
response_model_exclude_unset=True,
responses=responses)
-async def update_drawing(project_id: UUID, drawing_id: UUID, drawing_data: Drawing):
+async def update_drawing(project_id: UUID, drawing_id: UUID, drawing_data: schemas.Drawing):
"""
Update a drawing.
"""
diff --git a/gns3server/endpoints/controller/gns3vm.py b/gns3server/endpoints/controller/gns3vm.py
index 16669350..9910df6b 100644
--- a/gns3server/endpoints/controller/gns3vm.py
+++ b/gns3server/endpoints/controller/gns3vm.py
@@ -23,7 +23,7 @@ from fastapi import APIRouter
from fastapi.encoders import jsonable_encoder
from gns3server.controller import Controller
-from gns3server.endpoints.schemas.gns3vm import GNS3VM
+from gns3server import schemas
router = APIRouter()
@@ -48,7 +48,7 @@ async def get_vms(engine: str):
return vms
-@router.get("", response_model=GNS3VM)
+@router.get("", response_model=schemas.GNS3VM)
async def get_gns3vm_settings():
"""
Return the GNS3 VM settings.
@@ -57,8 +57,8 @@ async def get_gns3vm_settings():
return Controller.instance().gns3vm.__json__()
-@router.put("", response_model=GNS3VM, response_model_exclude_unset=True)
-async def update_gns3vm_settings(gns3vm_data: GNS3VM):
+@router.put("", response_model=schemas.GNS3VM, response_model_exclude_unset=True)
+async def update_gns3vm_settings(gns3vm_data: schemas.GNS3VM):
"""
Update the GNS3 VM settings.
"""
diff --git a/gns3server/endpoints/controller/links.py b/gns3server/endpoints/controller/links.py
index ff1c393d..80fa9d0b 100644
--- a/gns3server/endpoints/controller/links.py
+++ b/gns3server/endpoints/controller/links.py
@@ -32,8 +32,7 @@ from gns3server.controller import Controller
from gns3server.controller.controller_error import ControllerError
from gns3server.controller.link import Link
from gns3server.utils.http_client import HTTPClient
-from gns3server.endpoints.schemas.common import ErrorMessage
-from gns3server.endpoints import schemas
+from gns3server import schemas
import logging
log = logging.getLogger(__name__)
@@ -41,7 +40,7 @@ log = logging.getLogger(__name__)
router = APIRouter()
responses = {
- 404: {"model": ErrorMessage, "description": "Could not find project or link"}
+ 404: {"model": schemas.ErrorMessage, "description": "Could not find project or link"}
}
@@ -70,8 +69,8 @@ async def get_links(project_id: UUID):
@router.post("",
status_code=status.HTTP_201_CREATED,
response_model=schemas.Link,
- responses={404: {"model": ErrorMessage, "description": "Could not find project"},
- 409: {"model": ErrorMessage, "description": "Could not create link"}})
+ responses={404: {"model": schemas.ErrorMessage, "description": "Could not find project"},
+ 409: {"model": schemas.ErrorMessage, "description": "Could not create link"}})
async def create_link(project_id: UUID, link_data: schemas.Link):
"""
Create a new link.
diff --git a/gns3server/endpoints/controller/nodes.py b/gns3server/endpoints/controller/nodes.py
index c2f6cca0..42c3cb6a 100644
--- a/gns3server/endpoints/controller/nodes.py
+++ b/gns3server/endpoints/controller/nodes.py
@@ -34,8 +34,7 @@ from gns3server.controller.project import Project
from gns3server.utils import force_unix_path
from gns3server.utils.http_client import HTTPClient
from gns3server.controller.controller_error import ControllerForbiddenError
-from gns3server.endpoints.schemas.common import ErrorMessage
-from gns3server.endpoints import schemas
+from gns3server import schemas
import logging
log = logging.getLogger(__name__)
@@ -80,7 +79,7 @@ class NodeConcurrency(APIRoute):
router = APIRouter(route_class=NodeConcurrency)
responses = {
- 404: {"model": ErrorMessage, "description": "Could not find project or node"}
+ 404: {"model": schemas.ErrorMessage, "description": "Could not find project or node"}
}
@@ -105,8 +104,8 @@ async def dep_node(node_id: UUID, project: Project = Depends(dep_project)):
@router.post("",
status_code=status.HTTP_201_CREATED,
response_model=schemas.Node,
- responses={404: {"model": ErrorMessage, "description": "Could not find project"},
- 409: {"model": ErrorMessage, "description": "Could not create node"}})
+ responses={404: {"model": schemas.ErrorMessage, "description": "Could not find project"},
+ 409: {"model": schemas.ErrorMessage, "description": "Could not create node"}})
async def create_node(node_data: schemas.Node, project: Project = Depends(dep_project)):
"""
Create a new node.
@@ -212,7 +211,7 @@ async def update_node(node_data: schemas.NodeUpdate, node: Node = Depends(dep_no
@router.delete("/{node_id}",
status_code=status.HTTP_204_NO_CONTENT,
responses={**responses,
- 409: {"model": ErrorMessage, "description": "Cannot delete node"}})
+ 409: {"model": schemas.ErrorMessage, "description": "Cannot delete node"}})
async def delete_node(node_id: UUID, project: Project = Depends(dep_project)):
"""
Delete a node from a project.
diff --git a/gns3server/endpoints/controller/projects.py b/gns3server/endpoints/controller/projects.py
index a4bd174d..6e965833 100644
--- a/gns3server/endpoints/controller/projects.py
+++ b/gns3server/endpoints/controller/projects.py
@@ -37,8 +37,7 @@ from typing import List, Optional
from uuid import UUID
from pathlib import Path
-from gns3server.endpoints.schemas.common import ErrorMessage
-from gns3server.endpoints import schemas
+from gns3server import schemas
from gns3server.controller import Controller
from gns3server.controller.project import Project
from gns3server.controller.controller_error import ControllerError, ControllerForbiddenError
@@ -51,7 +50,7 @@ from gns3server.config import Config
router = APIRouter()
responses = {
- 404: {"model": ErrorMessage, "description": "Could not find project"}
+ 404: {"model": schemas.ErrorMessage, "description": "Could not find project"}
}
@@ -83,7 +82,7 @@ def get_projects():
status_code=status.HTTP_201_CREATED,
response_model=schemas.Project,
response_model_exclude_unset=True,
- responses={409: {"model": ErrorMessage, "description": "Could not create project"}})
+ responses={409: {"model": schemas.ErrorMessage, "description": "Could not create project"}})
async def create_project(project_data: schemas.ProjectCreate):
"""
Create a new project.
@@ -145,7 +144,7 @@ def get_project_stats(project: Project = Depends(dep_project)):
status_code=status.HTTP_204_NO_CONTENT,
responses={
**responses,
- 409: {"model": ErrorMessage, "description": "Could not close project"}
+ 409: {"model": schemas.ErrorMessage, "description": "Could not close project"}
})
async def close_project(project: Project = Depends(dep_project)):
"""
@@ -160,7 +159,7 @@ async def close_project(project: Project = Depends(dep_project)):
response_model=schemas.Project,
responses={
**responses,
- 409: {"model": ErrorMessage, "description": "Could not open project"}
+ 409: {"model": schemas.ErrorMessage, "description": "Could not open project"}
})
async def open_project(project: Project = Depends(dep_project)):
"""
@@ -176,7 +175,7 @@ async def open_project(project: Project = Depends(dep_project)):
response_model=schemas.Project,
responses={
**responses,
- 409: {"model": ErrorMessage, "description": "Could not load project"}
+ 409: {"model": schemas.ErrorMessage, "description": "Could not load project"}
})
async def load_project(path: str = Body(..., embed=True)):
"""
@@ -346,7 +345,7 @@ async def import_project(project_id: UUID, request: Request, path: Optional[Path
response_model=schemas.Project,
responses={
**responses,
- 409: {"model": ErrorMessage, "description": "Could not duplicate project"}
+ 409: {"model": schemas.ErrorMessage, "description": "Could not duplicate project"}
})
async def duplicate(project_data: schemas.ProjectDuplicate, project: Project = Depends(dep_project)):
"""
diff --git a/gns3server/endpoints/controller/snapshots.py b/gns3server/endpoints/controller/snapshots.py
index c7c57725..19c08419 100644
--- a/gns3server/endpoints/controller/snapshots.py
+++ b/gns3server/endpoints/controller/snapshots.py
@@ -27,14 +27,13 @@ from typing import List
from uuid import UUID
from gns3server.controller.project import Project
-from gns3server.endpoints.schemas.common import ErrorMessage
-from gns3server.endpoints import schemas
+from gns3server import schemas
from gns3server.controller import Controller
router = APIRouter()
responses = {
- 404: {"model": ErrorMessage, "description": "Could not find project or snapshot"}
+ 404: {"model": schemas.ErrorMessage, "description": "Could not find project or snapshot"}
}
diff --git a/gns3server/endpoints/controller/symbols.py b/gns3server/endpoints/controller/symbols.py
index d6555143..c4d9c0d8 100644
--- a/gns3server/endpoints/controller/symbols.py
+++ b/gns3server/endpoints/controller/symbols.py
@@ -25,7 +25,7 @@ from fastapi import APIRouter, Request, status
from fastapi.responses import FileResponse
from gns3server.controller import Controller
-from gns3server.endpoints.schemas.common import ErrorMessage
+from gns3server import schemas
from gns3server.controller.controller_error import ControllerError, ControllerNotFoundError
import logging
@@ -43,7 +43,7 @@ def get_symbols():
@router.get("/{symbol_id:path}/raw",
- responses={404: {"model": ErrorMessage, "description": "Could not find symbol"}})
+ responses={404: {"model": schemas.ErrorMessage, "description": "Could not find symbol"}})
async def get_symbol(symbol_id: str):
"""
Download a symbol file.
diff --git a/gns3server/endpoints/controller/templates.py b/gns3server/endpoints/controller/templates.py
index 60f5e584..cf14f8cb 100644
--- a/gns3server/endpoints/controller/templates.py
+++ b/gns3server/endpoints/controller/templates.py
@@ -30,15 +30,14 @@ from fastapi.encoders import jsonable_encoder
from typing import List
from uuid import UUID
-from gns3server.endpoints.schemas.common import ErrorMessage
-from gns3server.endpoints import schemas
+from gns3server import schemas
from gns3server.controller import Controller
router = APIRouter()
responses = {
- 404: {"model": ErrorMessage, "description": "Could not find template"}
+ 404: {"model": schemas.ErrorMessage, "description": "Could not find template"}
}
@@ -134,7 +133,7 @@ async def duplicate_template(template_id: UUID):
@router.post("/projects/{project_id}/templates/{template_id}",
response_model=schemas.Node,
status_code=status.HTTP_201_CREATED,
- responses={404: {"model": ErrorMessage, "description": "Could not find project or template"}})
+ responses={404: {"model": schemas.ErrorMessage, "description": "Could not find project or template"}})
async def create_node_from_template(project_id: UUID, template_id: UUID, template_usage: schemas.TemplateUsage):
"""
Create a new node from a template.
diff --git a/gns3server/endpoints/schemas/__init__.py b/gns3server/endpoints/schemas/__init__.py
deleted file mode 100644
index f39cf031..00000000
--- a/gns3server/endpoints/schemas/__init__.py
+++ /dev/null
@@ -1,42 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2020 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 .
-
-
-from .version import Version
-from .iou_license import IOULicense
-from .links import Link
-from .common import ErrorMessage
-from .computes import ComputeCreate, ComputeUpdate, Compute, AutoIdlePC
-from .nodes import NodeUpdate, NodeDuplicate, NodeCapture, Node
-from .projects import ProjectCreate, ProjectUpdate, ProjectDuplicate, Project, ProjectFile
-from .snapshots import SnapshotCreate, Snapshot
-from .templates import TemplateCreate, TemplateUpdate, TemplateUsage, Template
-from .capabilities import Capabilities
-from .nios import UDPNIO, TAPNIO, EthernetNIO
-from .atm_switch_nodes import ATMSwitchCreate, ATMSwitchUpdate, ATMSwitch
-from .cloud_nodes import CloudCreate, CloudUpdate, Cloud
-from .docker_nodes import DockerCreate, DockerUpdate, Docker
-from .dynamips_nodes import DynamipsCreate, DynamipsUpdate, Dynamips
-from .ethernet_hub_nodes import EthernetHubCreate, EthernetHubUpdate, EthernetHub
-from .ethernet_switch_nodes import EthernetSwitchCreate, EthernetSwitchUpdate, EthernetSwitch
-from .frame_relay_switch_nodes import FrameRelaySwitchCreate, FrameRelaySwitchUpdate, FrameRelaySwitch
-from .iou_nodes import IOUCreate, IOUUpdate, IOUStart, IOU
-from .nat_nodes import NATCreate, NATUpdate, NAT
-from .qemu_nodes import QemuCreate, QemuUpdate, Qemu, QemuDiskResize, QemuImageCreate, QemuImageUpdate
-from .virtualbox_nodes import VirtualBoxCreate, VirtualBoxUpdate, VirtualBox
-from .vmware_nodes import VMwareCreate, VMwareUpdate, VMware
-from .vpcs_nodes import VPCSCreate, VPCSUpdate, VPCS
diff --git a/gns3server/endpoints/schemas/capabilities.py b/gns3server/endpoints/schemas/capabilities.py
deleted file mode 100644
index 6197d93e..00000000
--- a/gns3server/endpoints/schemas/capabilities.py
+++ /dev/null
@@ -1,35 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2020 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 .
-
-
-from pydantic import BaseModel, Field
-from typing import List
-
-from .nodes import NodeType
-
-
-class Capabilities(BaseModel):
- """
- Capabilities properties.
- """
-
- version: str = Field(..., description="Compute version number")
- node_types: List[NodeType] = Field(..., description="Node types supported by the compute")
- platform: str = Field(..., description="Platform where the compute is running")
- cpus: int = Field(..., description="Number of CPUs on this compute")
- memory: int = Field(..., description="Amount of memory on this compute")
- disk_size: int = Field(..., description="Disk size on this compute")
diff --git a/gns3server/endpoints/schemas/version.py b/gns3server/endpoints/schemas/version.py
deleted file mode 100644
index cb92d953..00000000
--- a/gns3server/endpoints/schemas/version.py
+++ /dev/null
@@ -1,25 +0,0 @@
-# -*- 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 .
-
-from pydantic import BaseModel, Field
-from typing import Optional
-
-
-class Version(BaseModel):
-
- version: str = Field(..., description="Version number")
- local: Optional[bool] = Field(None, description="Whether this is a local server or not")
diff --git a/gns3server/schemas/__init__.py b/gns3server/schemas/__init__.py
index e69de29b..875ed06c 100644
--- a/gns3server/schemas/__init__.py
+++ b/gns3server/schemas/__init__.py
@@ -0,0 +1,64 @@
+# -*- coding: utf-8 -*-
+#
+# Copyright (C) 2020 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 .
+
+
+from .iou_license import IOULicense
+from .links import Link
+from .common import ErrorMessage
+from .version import Version
+from .computes import ComputeCreate, ComputeUpdate, AutoIdlePC, Compute
+from .templates import TemplateCreate, TemplateUpdate, TemplateUsage, Template
+from .drawings import Drawing
+from .gns3vm import GNS3VM
+from .nodes import NodeUpdate, NodeDuplicate, NodeCapture, Node
+from .projects import ProjectCreate, ProjectUpdate, ProjectDuplicate, Project, ProjectFile
+from .snapshots import SnapshotCreate, Snapshot
+from .capabilities import Capabilities
+from .nios import UDPNIO, TAPNIO, EthernetNIO
+from .atm_switch_nodes import ATMSwitchCreate, ATMSwitchUpdate, ATMSwitch
+from .cloud_nodes import CloudCreate, CloudUpdate, Cloud
+from .docker_nodes import DockerCreate, DockerUpdate, Docker
+from .dynamips_nodes import DynamipsCreate, DynamipsUpdate, Dynamips
+from .ethernet_hub_nodes import EthernetHubCreate, EthernetHubUpdate, EthernetHub
+from .ethernet_switch_nodes import EthernetSwitchCreate, EthernetSwitchUpdate, EthernetSwitch
+from .frame_relay_switch_nodes import FrameRelaySwitchCreate, FrameRelaySwitchUpdate, FrameRelaySwitch
+from .qemu_nodes import QemuCreate, QemuUpdate, QemuImageCreate, QemuImageUpdate, QemuDiskResize, Qemu
+from .iou_nodes import IOUCreate, IOUUpdate, IOUStart, IOU
+from .nat_nodes import NATCreate, NATUpdate, NAT
+from .vpcs_nodes import VPCSCreate, VPCSUpdate, VPCS
+from .vmware_nodes import VMwareCreate, VMwareUpdate, VMware
+from .virtualbox_nodes import VirtualBoxCreate, VirtualBoxUpdate, VirtualBox
+
+from .vpcs_templates import VPCSTemplate
+from .cloud_templates import CloudTemplate
+from .iou_templates import IOUTemplate
+from .docker_templates import DockerTemplate
+from .ethernet_hub_templates import EthernetHubTemplate
+from .ethernet_switch_templates import EthernetSwitchTemplate
+from .virtualbox_templates import VirtualBoxTemplate
+from .vmware_templates import VMwareTemplate
+from .qemu_templates import QemuTemplate
+from .dynamips_templates import (
+ DynamipsTemplate,
+ C1700DynamipsTemplate,
+ C2600DynamipsTemplate,
+ C2691DynamipsTemplate,
+ C3600DynamipsTemplate,
+ C3725DynamipsTemplate,
+ C3745DynamipsTemplate,
+ C7200DynamipsTemplate
+)
diff --git a/gns3server/endpoints/schemas/atm_switch_nodes.py b/gns3server/schemas/atm_switch_nodes.py
similarity index 100%
rename from gns3server/endpoints/schemas/atm_switch_nodes.py
rename to gns3server/schemas/atm_switch_nodes.py
diff --git a/gns3server/schemas/capabilities.py b/gns3server/schemas/capabilities.py
index 61378299..6197d93e 100644
--- a/gns3server/schemas/capabilities.py
+++ b/gns3server/schemas/capabilities.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2015 GNS3 Technologies Inc.
+# Copyright (C) 2020 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
@@ -15,40 +15,21 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-from .node import NODE_TYPE_SCHEMA
+
+from pydantic import BaseModel, Field
+from typing import List
+
+from .nodes import NodeType
-CAPABILITIES_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Get what a server support",
- "type": "object",
- "required": ["version", "node_types"],
- "properties": {
- "version": {
- "description": "Version number",
- "type": ["string", "null"],
- },
- "node_types": {
- "type": "array",
- "items": NODE_TYPE_SCHEMA,
- "description": "Node type supported by the compute"
- },
- "platform": {
- "type": "string",
- "description": "Platform where the compute is running"
- },
- "cpus": {
- "description": "Number of CPUs on this compute. Read only",
- "type": ["integer", "null"],
- },
- "memory": {
- "description": "Amount of memory on this compute. Read only",
- "type": ["integer", "null"],
- },
- "disk_size": {
- "description": "Disk size on this compute. Read only",
- "type": ["integer", "null"],
- },
- },
- "additionalProperties": False
-}
+class Capabilities(BaseModel):
+ """
+ Capabilities properties.
+ """
+
+ version: str = Field(..., description="Compute version number")
+ node_types: List[NodeType] = Field(..., description="Node types supported by the compute")
+ platform: str = Field(..., description="Platform where the compute is running")
+ cpus: int = Field(..., description="Number of CPUs on this compute")
+ memory: int = Field(..., description="Amount of memory on this compute")
+ disk_size: int = Field(..., description="Disk size on this compute")
diff --git a/gns3server/endpoints/schemas/cloud_nodes.py b/gns3server/schemas/cloud_nodes.py
similarity index 100%
rename from gns3server/endpoints/schemas/cloud_nodes.py
rename to gns3server/schemas/cloud_nodes.py
diff --git a/gns3server/schemas/cloud_template.py b/gns3server/schemas/cloud_template.py
deleted file mode 100644
index b6840074..00000000
--- a/gns3server/schemas/cloud_template.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2016 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 .
-
-import copy
-from .template import BASE_TEMPLATE_PROPERTIES
-from .port import PORT_OBJECT_SCHEMA
-
-
-CLOUD_TEMPLATE_PROPERTIES = {
- "ports_mapping": {
- "type": "array",
- "items": [PORT_OBJECT_SCHEMA],
- "default": []
- },
- "remote_console_host": {
- "description": "Remote console host or IP",
- "type": ["string"],
- "minLength": 1,
- "default": "127.0.0.1"
- },
- "remote_console_port": {
- "description": "Console TCP port",
- "minimum": 1,
- "maximum": 65535,
- "type": "integer",
- "default": 23
- },
- "remote_console_type": {
- "description": "Console type",
- "enum": ["telnet", "vnc", "spice", "http", "https", "none"],
- "default": "none"
- },
- "remote_console_http_path": {
- "description": "Path of the remote web interface",
- "type": "string",
- "minLength": 1,
- "default": "/"
- },
-}
-
-CLOUD_TEMPLATE_PROPERTIES.update(copy.deepcopy(BASE_TEMPLATE_PROPERTIES))
-CLOUD_TEMPLATE_PROPERTIES["category"]["default"] = "guest"
-CLOUD_TEMPLATE_PROPERTIES["default_name_format"]["default"] = "Cloud{0}"
-CLOUD_TEMPLATE_PROPERTIES["symbol"]["default"] = ":/symbols/cloud.svg"
-
-CLOUD_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A cloud template object",
- "type": "object",
- "properties": CLOUD_TEMPLATE_PROPERTIES,
- "additionalProperties": False
-}
diff --git a/gns3server/controller/schemas/cloud_templates.py b/gns3server/schemas/cloud_templates.py
similarity index 89%
rename from gns3server/controller/schemas/cloud_templates.py
rename to gns3server/schemas/cloud_templates.py
index 04558942..99d12322 100644
--- a/gns3server/controller/schemas/cloud_templates.py
+++ b/gns3server/schemas/cloud_templates.py
@@ -16,8 +16,8 @@
# along with this program. If not, see .
-from gns3server.endpoints.schemas.templates import Category, TemplateBase
-from gns3server.endpoints.schemas.cloud_nodes import EthernetPort, TAPPort, UDPPort, CloudConsoleType
+from .templates import Category, TemplateBase
+from .cloud_nodes import EthernetPort, TAPPort, UDPPort, CloudConsoleType
from pydantic import Field
from typing import Optional, Union, List
diff --git a/gns3server/endpoints/schemas/common.py b/gns3server/schemas/common.py
similarity index 100%
rename from gns3server/endpoints/schemas/common.py
rename to gns3server/schemas/common.py
diff --git a/gns3server/schemas/compute.py b/gns3server/schemas/compute.py
deleted file mode 100644
index 3de0fb70..00000000
--- a/gns3server/schemas/compute.py
+++ /dev/null
@@ -1,188 +0,0 @@
-# -*- 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 .
-
-import copy
-from .capabilities import CAPABILITIES_SCHEMA
-
-COMPUTE_CREATE_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to register a GNS3 compute instance",
- "type": "object",
- "properties": {
- "compute_id": {
- "description": "Server identifier",
- "type": "string"
- },
- "name": {
- "description": "Server name",
- "type": "string"
- },
- "protocol": {
- "description": "Server protocol",
- "enum": ["http", "https"]
- },
- "host": {
- "description": "Server host",
- "type": "string"
- },
- "port": {
- "description": "Server port",
- "type": "integer"
- },
- "user": {
- "description": "User for authentication",
- "type": ["string", "null"]
- },
- "password": {
- "description": "Password for authentication",
- "type": ["string", "null"]
- }
- },
- "additionalProperties": False,
- "required": ["protocol", "host", "port"]
-}
-
-COMPUTE_UPDATE_SCHEMA = copy.deepcopy(COMPUTE_CREATE_SCHEMA)
-del COMPUTE_UPDATE_SCHEMA["required"]
-
-COMPUTE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to a GNS3 compute object instance",
- "type": "object",
- "properties": {
- "compute_id": {
- "description": "Server identifier",
- "type": "string"
- },
- "name": {
- "description": "Server name",
- "type": "string"
- },
- "protocol": {
- "description": "Server protocol",
- "enum": ["http", "https"]
- },
- "host": {
- "description": "Server host",
- "type": "string"
- },
- "port": {
- "description": "Server port",
- "type": "integer"
- },
- "user": {
- "description": "User for authentication",
- "type": ["string", "null"]
- },
- "connected": {
- "description": "Whether the controller is connected to the compute or not",
- "type": "boolean"
- },
- "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
- },
- "disk_usage_percent": {
- "description": "Disk usage of the compute. Read only",
- "type": ["number", "null"],
- "maximum": 100,
- "minimum": 0
- },
- "last_error": {
- "description": "Last error on the compute",
- "type": ["string", "null"]
- },
- "capabilities": CAPABILITIES_SCHEMA
- },
- "additionalProperties": False,
- "required": ["compute_id", "protocol", "host", "port", "name"]
-}
-
-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,
-}
-
-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,
-}
-
diff --git a/gns3server/endpoints/schemas/computes.py b/gns3server/schemas/computes.py
similarity index 100%
rename from gns3server/endpoints/schemas/computes.py
rename to gns3server/schemas/computes.py
diff --git a/gns3server/schemas/custom_adapters.py b/gns3server/schemas/custom_adapters.py
deleted file mode 100644
index f3472540..00000000
--- a/gns3server/schemas/custom_adapters.py
+++ /dev/null
@@ -1,49 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2016 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 .
-
-CUSTOM_ADAPTERS_ARRAY_SCHEMA = {
- "type": "array",
- "default": [],
- "items": {
- "type": "object",
- "description": "Custom properties",
- "properties": {
- "adapter_number": {
- "type": "integer",
- "description": "Adapter number"
- },
- "port_name": {
- "type": "string",
- "description": "Custom port name",
- "minLength": 1,
- },
- "adapter_type": {
- "type": "string",
- "description": "Custom adapter type",
- "minLength": 1,
- },
- "mac_address": {
- "description": "Custom MAC address",
- "type": "string",
- "minLength": 1,
- "pattern": "^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$"
- },
- },
- "additionalProperties": False,
- "required": ["adapter_number"]
- },
-}
diff --git a/gns3server/endpoints/schemas/docker_nodes.py b/gns3server/schemas/docker_nodes.py
similarity index 100%
rename from gns3server/endpoints/schemas/docker_nodes.py
rename to gns3server/schemas/docker_nodes.py
diff --git a/gns3server/schemas/docker_template.py b/gns3server/schemas/docker_template.py
deleted file mode 100644
index 5f25d17f..00000000
--- a/gns3server/schemas/docker_template.py
+++ /dev/null
@@ -1,115 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2016 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 .
-
-import copy
-from .template import BASE_TEMPLATE_PROPERTIES
-from .custom_adapters import CUSTOM_ADAPTERS_ARRAY_SCHEMA
-
-
-DOCKER_TEMPLATE_PROPERTIES = {
- "image": {
- "description": "Docker image name",
- "type": "string",
- "minLength": 1
- },
- "adapters": {
- "description": "Number of adapters",
- "type": "integer",
- "minimum": 0,
- "maximum": 99,
- "default": 1
- },
- "start_command": {
- "description": "Docker CMD entry",
- "type": "string",
- "default": ""
- },
- "environment": {
- "description": "Docker environment variables",
- "type": "string",
- "default": ""
- },
- "console_type": {
- "description": "Console type",
- "enum": ["telnet", "vnc", "http", "https", "none"],
- "default": "telnet"
- },
- "aux_type": {
- "description": "Auxiliary console type",
- "enum": ["telnet", "none"],
- "default": "none"
- },
- "console_auto_start": {
- "description": "Automatically start the console when the node has started",
- "type": "boolean",
- "default": False,
- },
- "console_http_port": {
- "description": "Internal port in the container for the HTTP server",
- "type": "integer",
- "minimum": 1,
- "maximum": 65535,
- "default": 80
- },
- "console_http_path": {
- "description": "Path of the web interface",
- "type": "string",
- "minLength": 1,
- "default": "/"
- },
- "console_resolution": {
- "description": "Console resolution for VNC",
- "type": "string",
- "pattern": "^[0-9]+x[0-9]+$",
- "default": "1024x768"
- },
- "extra_hosts": {
- "description": "Docker extra hosts (added to /etc/hosts)",
- "type": "string",
- "default": ""
- },
- "extra_volumes": {
- "description": "Additional directories to make persistent",
- "type": "array",
- "default": []
- },
- "memory": {
- "description": "Maximum amount of memory the container can use in MB",
- "type": "integer",
- "default": 0
- },
- "cpus": {
- "description": "Maximum amount of CPU resources the container can use",
- "type": "number",
- "default": 0
- },
- "custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA
-}
-
-DOCKER_TEMPLATE_PROPERTIES.update(copy.deepcopy(BASE_TEMPLATE_PROPERTIES))
-DOCKER_TEMPLATE_PROPERTIES["category"]["default"] = "guest"
-DOCKER_TEMPLATE_PROPERTIES["default_name_format"]["default"] = "{name}-{0}"
-DOCKER_TEMPLATE_PROPERTIES["symbol"]["default"] = ":/symbols/docker_guest.svg"
-
-DOCKER_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A Docker template object",
- "type": "object",
- "properties": DOCKER_TEMPLATE_PROPERTIES,
- "required": ["image"],
- "additionalProperties": False
-}
diff --git a/gns3server/controller/schemas/docker_templates.py b/gns3server/schemas/docker_templates.py
similarity index 92%
rename from gns3server/controller/schemas/docker_templates.py
rename to gns3server/schemas/docker_templates.py
index 3d243217..1a4784e4 100644
--- a/gns3server/controller/schemas/docker_templates.py
+++ b/gns3server/schemas/docker_templates.py
@@ -16,9 +16,9 @@
# along with this program. If not, see .
-from gns3server.endpoints.schemas.templates import Category, TemplateBase
-from gns3server.endpoints.schemas.nodes import CustomAdapter
-from gns3server.endpoints.schemas.docker_nodes import ConsoleType, AuxType
+from .templates import Category, TemplateBase
+from .nodes import CustomAdapter
+from .docker_nodes import ConsoleType, AuxType
from pydantic import Field
from typing import Optional, List
diff --git a/gns3server/schemas/drawing.py b/gns3server/schemas/drawing.py
deleted file mode 100644
index 37f8fd6c..00000000
--- a/gns3server/schemas/drawing.py
+++ /dev/null
@@ -1,66 +0,0 @@
-#!/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 .
-
-
-DRAWING_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "An drawing object",
- "type": "object",
- "properties": {
- "drawing_id": {
- "description": "Drawing 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}$"
- },
- "project_id": {
- "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}$"
- },
- "x": {
- "description": "X property",
- "type": "integer"
- },
- "y": {
- "description": "Y property",
- "type": "integer"
- },
- "z": {
- "description": "Z property",
- "type": "integer"
- },
- "locked": {
- "description": "Whether the element locked or not",
- "type": "boolean"
- },
- "rotation": {
- "description": "Rotation of the element",
- "type": "integer",
- "minimum": -359,
- "maximum": 360
- },
- "svg": {
- "description": "SVG content of the drawing",
- "type": "string"
- }
- },
- "additionalProperties": False
-}
diff --git a/gns3server/endpoints/schemas/drawings.py b/gns3server/schemas/drawings.py
similarity index 100%
rename from gns3server/endpoints/schemas/drawings.py
rename to gns3server/schemas/drawings.py
diff --git a/gns3server/endpoints/schemas/dynamips_nodes.py b/gns3server/schemas/dynamips_nodes.py
similarity index 100%
rename from gns3server/endpoints/schemas/dynamips_nodes.py
rename to gns3server/schemas/dynamips_nodes.py
diff --git a/gns3server/schemas/dynamips_template.py b/gns3server/schemas/dynamips_template.py
deleted file mode 100644
index 19f8dc19..00000000
--- a/gns3server/schemas/dynamips_template.py
+++ /dev/null
@@ -1,404 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2016 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 .
-
-import copy
-from .template import BASE_TEMPLATE_PROPERTIES
-from .dynamips_vm import DYNAMIPS_ADAPTERS, DYNAMIPS_WICS
-
-
-DYNAMIPS_TEMPLATE_PROPERTIES = {
- "platform": {
- "description": "Platform type",
- "enum": ["c7200", "c3745", "c3725", "c3600", "c2691", "c2600", "c1700"]
- },
- "image": {
- "description": "Path to the IOS image",
- "type": "string",
- "minLength": 1
- },
- "mmap": {
- "description": "MMAP feature",
- "type": "boolean",
- "default": True
- },
- "exec_area": {
- "description": "Exec area value",
- "type": "integer",
- "default": 64
- },
- "mac_addr": {
- "description": "Base MAC address",
- "type": "string",
- "anyOf": [
- {"pattern": "^([0-9a-fA-F]{4}\\.){2}[0-9a-fA-F]{4}$"},
- {"pattern": "^$"}
- ],
- "default": ""
- },
- "system_id": {
- "description": "System ID",
- "type": "string",
- "minLength": 1,
- "default": "FTX0945W0MY"
- },
- "startup_config": {
- "description": "IOS startup configuration file",
- "type": "string",
- "default": "ios_base_startup-config.txt"
- },
- "private_config": {
- "description": "IOS private configuration file",
- "type": "string",
- "default": ""
- },
- "idlepc": {
- "description": "Idle-PC value",
- "type": "string",
- "pattern": "^(0x[0-9a-fA-F]+)?$",
- "default": ""
- },
- "idlemax": {
- "description": "Idlemax value",
- "type": "integer",
- "default": 500
- },
- "idlesleep": {
- "description": "Idlesleep value",
- "type": "integer",
- "default": 30
- },
- "disk0": {
- "description": "Disk0 size in MB",
- "type": "integer",
- "default": 0
- },
- "disk1": {
- "description": "Disk1 size in MB",
- "type": "integer",
- "default": 0
- },
- "auto_delete_disks": {
- "description": "Automatically delete nvram and disk files",
- "type": "boolean",
- "default": False
- },
- "wic0": DYNAMIPS_WICS,
- "wic1": DYNAMIPS_WICS,
- "wic2": DYNAMIPS_WICS,
- "slot0": DYNAMIPS_ADAPTERS,
- "slot1": DYNAMIPS_ADAPTERS,
- "slot2": DYNAMIPS_ADAPTERS,
- "slot3": DYNAMIPS_ADAPTERS,
- "slot4": DYNAMIPS_ADAPTERS,
- "slot5": DYNAMIPS_ADAPTERS,
- "slot6": DYNAMIPS_ADAPTERS,
- "console_type": {
- "description": "Console type",
- "enum": ["telnet", "none"],
- "default": "telnet"
- },
- "console_auto_start": {
- "description": "Automatically start the console when the node has started",
- "type": "boolean",
- "default": False
- },
- "aux_type": {
- "description": "Auxiliary console type",
- "enum": ["telnet", "none"],
- "default": "none"
- }
-}
-
-DYNAMIPS_TEMPLATE_PROPERTIES.update(copy.deepcopy(BASE_TEMPLATE_PROPERTIES))
-DYNAMIPS_TEMPLATE_PROPERTIES["category"]["default"] = "router"
-DYNAMIPS_TEMPLATE_PROPERTIES["default_name_format"]["default"] = "R{0}"
-DYNAMIPS_TEMPLATE_PROPERTIES["symbol"]["default"] = ":/symbols/router.svg"
-
-DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A Dynamips template object",
- "type": "object",
- "properties": DYNAMIPS_TEMPLATE_PROPERTIES,
- "required": ["platform", "image"],
-}
-
-C7200_DYNAMIPS_TEMPLATE_PROPERTIES = {
- "ram": {
- "description": "Amount of RAM in MB",
- "type": "integer",
- "default": 512
- },
- "nvram": {
- "description": "Amount of NVRAM in KB",
- "type": "integer",
- "default": 512
- },
- "npe": {
- "description": "NPE model",
- "enum": ["npe-100", "npe-150", "npe-175", "npe-200", "npe-225", "npe-300", "npe-400", "npe-g2"],
- "default": "npe-400"
- },
- "midplane": {
- "description": "Midplane model",
- "enum": ["std", "vxr"],
- "default": "vxr"
- },
- "sparsemem": {
- "description": "Sparse memory feature",
- "type": "boolean",
- "default": True
- }
-}
-
-C7200_DYNAMIPS_TEMPLATE_PROPERTIES.update(DYNAMIPS_TEMPLATE_PROPERTIES)
-
-C7200_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A c7200 Dynamips template object",
- "type": "object",
- "properties": C7200_DYNAMIPS_TEMPLATE_PROPERTIES,
- "additionalProperties": False
-}
-
-C3745_DYNAMIPS_TEMPLATE_PROPERTIES = {
- "ram": {
- "description": "Amount of RAM in MB",
- "type": "integer",
- "default": 256
- },
- "nvram": {
- "description": "Amount of NVRAM in KB",
- "type": "integer",
- "default": 256
- },
- "iomem": {
- "description": "I/O memory percentage",
- "type": "integer",
- "minimum": 0,
- "maximum": 100,
- "default": 5
- },
- "sparsemem": {
- "description": "Sparse memory feature",
- "type": "boolean",
- "default": True
- }
-}
-
-C3745_DYNAMIPS_TEMPLATE_PROPERTIES.update(DYNAMIPS_TEMPLATE_PROPERTIES)
-
-C3745_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A c3745 Dynamips template object",
- "type": "object",
- "properties": C3745_DYNAMIPS_TEMPLATE_PROPERTIES,
- "additionalProperties": False
-}
-
-C3725_DYNAMIPS_TEMPLATE_PROPERTIES = {
- "ram": {
- "description": "Amount of RAM in MB",
- "type": "integer",
- "default": 128
- },
- "nvram": {
- "description": "Amount of NVRAM in KB",
- "type": "integer",
- "default": 256
- },
- "iomem": {
- "description": "I/O memory percentage",
- "type": "integer",
- "minimum": 0,
- "maximum": 100,
- "default": 5
- },
- "sparsemem": {
- "description": "Sparse memory feature",
- "type": "boolean",
- "default": True
- }
-}
-
-C3725_DYNAMIPS_TEMPLATE_PROPERTIES.update(DYNAMIPS_TEMPLATE_PROPERTIES)
-
-C3725_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A c3725 Dynamips template object",
- "type": "object",
- "properties": C3725_DYNAMIPS_TEMPLATE_PROPERTIES,
- "additionalProperties": False
-}
-
-C3600_DYNAMIPS_TEMPLATE_PROPERTIES = {
- "chassis": {
- "description": "Chassis type",
- "enum": ["3620", "3640", "3660"],
- "default": "3660"
- },
- "ram": {
- "description": "Amount of RAM in MB",
- "type": "integer",
- "default": 192
- },
- "nvram": {
- "description": "Amount of NVRAM in KB",
- "type": "integer",
- "default": 128
- },
-
- "iomem": {
- "description": "I/O memory percentage",
- "type": "integer",
- "minimum": 0,
- "maximum": 100,
- "default": 5
- },
- "sparsemem": {
- "description": "Sparse memory feature",
- "type": "boolean",
- "default": True
- }
-}
-
-C3600_DYNAMIPS_TEMPLATE_PROPERTIES.update(DYNAMIPS_TEMPLATE_PROPERTIES)
-
-C3600_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A c3600 Dynamips template object",
- "type": "object",
- "properties": C3600_DYNAMIPS_TEMPLATE_PROPERTIES,
- "required": ["chassis"],
- "additionalProperties": False
-}
-
-C2691_DYNAMIPS_TEMPLATE_PROPERTIES = {
- "ram": {
- "description": "Amount of RAM in MB",
- "type": "integer",
- "default": 192
- },
- "nvram": {
- "description": "Amount of NVRAM in KB",
- "type": "integer",
- "default": 256
- },
- "iomem": {
- "description": "I/O memory percentage",
- "type": "integer",
- "minimum": 0,
- "maximum": 100,
- "default": 5
- },
- "sparsemem": {
- "description": "Sparse memory feature",
- "type": "boolean",
- "default": True
- }
-}
-
-C2691_DYNAMIPS_TEMPLATE_PROPERTIES.update(DYNAMIPS_TEMPLATE_PROPERTIES)
-
-C2691_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A c2691 Dynamips template object",
- "type": "object",
- "properties": C2691_DYNAMIPS_TEMPLATE_PROPERTIES,
- "additionalProperties": False
-}
-
-C2600_DYNAMIPS_TEMPLATE_PROPERTIES = {
- "chassis": {
- "description": "Chassis type",
- "enum": ["2610", "2620", "2610XM", "2620XM", "2650XM", "2621", "2611XM", "2621XM", "2651XM"],
- "default": "2651XM"
- },
- "ram": {
- "description": "Amount of RAM in MB",
- "type": "integer",
- "default": 160
- },
- "nvram": {
- "description": "Amount of NVRAM in KB",
- "type": "integer",
- "default": 128
- },
- "iomem": {
- "description": "I/O memory percentage",
- "type": "integer",
- "minimum": 0,
- "maximum": 100,
- "default": 15
- },
- "sparsemem": {
- "description": "Sparse memory feature",
- "type": "boolean",
- "default": True
- }
-}
-
-C2600_DYNAMIPS_TEMPLATE_PROPERTIES.update(DYNAMIPS_TEMPLATE_PROPERTIES)
-
-C2600_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A c2600 Dynamips template object",
- "type": "object",
- "properties": C2600_DYNAMIPS_TEMPLATE_PROPERTIES,
- "required": ["chassis"],
- "additionalProperties": False
-}
-
-C1700_DYNAMIPS_TEMPLATE_PROPERTIES = {
- "chassis": {
- "description": "Chassis type",
- "enum": ["1720", "1721", "1750", "1751", "1760"],
- "default": "1760"
- },
- "ram": {
- "description": "Amount of RAM in MB",
- "type": "integer",
- "default": 160
- },
- "nvram": {
- "description": "Amount of NVRAM in KB",
- "type": "integer",
- "default": 128
- },
- "iomem": {
- "description": "I/O memory percentage",
- "type": "integer",
- "minimum": 0,
- "maximum": 100,
- "default": 15
- },
- "sparsemem": {
- "description": "Sparse memory feature",
- "type": "boolean",
- "default": False
- }
-}
-
-C1700_DYNAMIPS_TEMPLATE_PROPERTIES.update(DYNAMIPS_TEMPLATE_PROPERTIES)
-
-C1700_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A c1700 Dynamips template object",
- "type": "object",
- "properties": C1700_DYNAMIPS_TEMPLATE_PROPERTIES,
- "required": ["chassis"],
- "additionalProperties": False
-}
diff --git a/gns3server/controller/schemas/dynamips_templates.py b/gns3server/schemas/dynamips_templates.py
similarity index 98%
rename from gns3server/controller/schemas/dynamips_templates.py
rename to gns3server/schemas/dynamips_templates.py
index b1ca419d..3e09702b 100644
--- a/gns3server/controller/schemas/dynamips_templates.py
+++ b/gns3server/schemas/dynamips_templates.py
@@ -15,8 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-from gns3server.endpoints.schemas.templates import Category, TemplateBase
-from gns3server.endpoints.schemas.dynamips_nodes import (
+from .templates import Category, TemplateBase
+from .dynamips_nodes import (
DynamipsConsoleType,
DynamipsPlatform,
DynamipsAdapters,
diff --git a/gns3server/schemas/dynamips_vm.py b/gns3server/schemas/dynamips_vm.py
deleted file mode 100644
index 2e0b32f9..00000000
--- a/gns3server/schemas/dynamips_vm.py
+++ /dev/null
@@ -1,774 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2014 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 .
-
-
-DYNAMIPS_ADAPTERS = {
- "description": "Dynamips Network Module",
- "enum": ["C7200-IO-2FE",
- "C7200-IO-FE",
- "C7200-IO-GE-E",
- "NM-16ESW",
- "NM-1E",
- "NM-1FE-TX",
- "NM-4E",
- "NM-4T",
- "PA-2FE-TX",
- "PA-4E",
- "PA-4T+",
- "PA-8E",
- "PA-8T",
- "PA-A1",
- "PA-FE-TX",
- "PA-GE",
- "PA-POS-OC3",
- "C2600-MB-2FE",
- "C2600-MB-1E",
- "C1700-MB-1FE",
- "C2600-MB-2E",
- "C2600-MB-1FE",
- "C1700-MB-WIC1",
- "GT96100-FE",
- "Leopard-2FE",
- ""]
-}
-
-DYNAMIPS_WICS = {
- "description": "Dynamips WIC",
- "enum": ["WIC-1ENET",
- "WIC-1T",
- "WIC-2T",
- ""]
-}
-
-#TODO: improve schema for Dynamips (match platform specific options, e.g. NPE allowd only for c7200)
-VM_CREATE_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to create a new Dynamips VM instance",
- "type": "object",
- "properties": {
- "node_id": {
- "description": "Node UUID",
- "oneOf": [
- {"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}$"},
- {"type": "integer"} # for legacy projects
- ]
- },
- "dynamips_id": {
- "description": "Dynamips ID",
- "type": ["integer", "null"]
- },
- "name": {
- "description": "Dynamips VM instance name",
- "type": "string",
- "minLength": 1,
- },
- "usage": {
- "description": "How to use the Dynamips VM",
- "type": "string",
- },
- "platform": {
- "description": "Cisco router platform",
- "type": "string",
- "minLength": 1,
- "pattern": "^c[0-9]{4}$"
- },
- "chassis": {
- "description": "Cisco router chassis model",
- "type": "string",
- "minLength": 1,
- "pattern": "^[0-9]{4}(XM)?$"
- },
- "image": {
- "description": "Path to the IOS image",
- "type": "string",
- "minLength": 1,
- },
- "image_md5sum": {
- "description": "Checksum of the IOS image",
- "type": ["string", "null"],
- "minLength": 1,
- },
- "startup_config_content": {
- "description": "Content of IOS startup configuration file",
- "type": "string",
- },
- "private_config_content": {
- "description": "Content of IOS private configuration file",
- "type": "string",
- },
- "ram": {
- "description": "Amount of RAM in MB",
- "type": "integer"
- },
- "nvram": {
- "description": "Amount of NVRAM in KB",
- "type": "integer"
- },
- "mmap": {
- "description": "MMAP feature",
- "type": "boolean"
- },
- "sparsemem": {
- "description": "Sparse memory feature",
- "type": "boolean"
- },
- "clock_divisor": {
- "description": "Clock divisor",
- "type": "integer"
- },
- "idlepc": {
- "description": "Idle-PC value",
- "type": "string",
- "pattern": "^(0x[0-9a-fA-F]+)?$"
- },
- "idlemax": {
- "description": "Idlemax value",
- "type": "integer",
- },
- "idlesleep": {
- "description": "Idlesleep value",
- "type": "integer",
- },
- "exec_area": {
- "description": "Exec area value",
- "type": "integer",
- },
- "disk0": {
- "description": "Disk0 size in MB",
- "type": "integer"
- },
- "disk1": {
- "description": "Disk1 size in MB",
- "type": "integer"
- },
- "auto_delete_disks": {
- "description": "Automatically delete nvram and disk files",
- "type": "boolean"
- },
- "console": {
- "description": "Console TCP port",
- "type": ["integer", "null"],
- "minimum": 1,
- "maximum": 65535
- },
- "console_type": {
- "description": "Console type",
- "enum": ["telnet", "none"]
- },
- "aux": {
- "description": "Auxiliary console TCP port",
- "type": ["null", "integer"],
- "minimum": 1,
- "maximum": 65535
- },
- "aux_type": {
- "description": "Auxiliary console type",
- "enum": ["telnet", "none"]
- },
- "mac_addr": {
- "description": "Base MAC address",
- "type": ["null", "string"],
- "minLength": 1,
- "pattern": "^([0-9a-fA-F]{4}\\.){2}[0-9a-fA-F]{4}$"
- },
- "system_id": {
- "description": "System ID",
- "type": "string",
- "minLength": 1,
- },
- "slot0": {
- "description": "Network module slot 0",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot1": {
- "description": "Network module slot 1",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot2": {
- "description": "Network module slot 2",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot3": {
- "description": "Network module slot 3",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot4": {
- "description": "Network module slot 4",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot5": {
- "description": "Network module slot 5",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot6": {
- "description": "Network module slot 6",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "wic0": {
- "description": "Network module WIC slot 0",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "wic1": {
- "description": "Network module WIC slot 0",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "wic2": {
- "description": "Network module WIC slot 0",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- # C7200 properties
- "npe": {
- "description": "NPE model",
- "enum": ["npe-100",
- "npe-150",
- "npe-175",
- "npe-200",
- "npe-225",
- "npe-300",
- "npe-400",
- "npe-g2"]
- },
- "midplane": {
- "description": "Midplane model",
- "enum": ["std", "vxr"]
- },
- "sensors": {
- "description": "Temperature sensors",
- "type": "array"
- },
- "power_supplies": {
- "description": "Power supplies status",
- "type": "array"
- },
- # I/O memory property for all platforms but C7200
- "iomem": {
- "description": "I/O memory percentage",
- "type": "integer",
- "minimum": 0,
- "maximum": 100
- },
- },
- "additionalProperties": False,
- "required": ["name", "platform", "image", "ram"]
-}
-
-VM_UPDATE_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to update a Dynamips VM instance",
- "type": "object",
- "properties": {
- "name": {
- "description": "Dynamips VM instance name",
- "type": "string",
- "minLength": 1,
- },
- "usage": {
- "description": "How to use the Dynamips VM",
- "type": "string",
- },
- "platform": {
- "description": "Cisco router platform",
- "type": "string",
- "minLength": 1,
- "pattern": "^c[0-9]{4}$"
- },
- "chassis": {
- "description": "Cisco router chassis model",
- "type": "string",
- "minLength": 1,
- "pattern": "^[0-9]{4}(XM)?$"
- },
- "image": {
- "description": "Path to the IOS image",
- "type": "string",
- "minLength": 1,
- },
- "image_md5sum": {
- "description": "Checksum of the IOS image",
- "type": ["string", "null"],
- "minLength": 1,
- },
- "dynamips_id": {
- "description": "Dynamips ID",
- "type": "integer"
- },
- "ram": {
- "description": "Amount of RAM in MB",
- "type": "integer"
- },
- "nvram": {
- "description": "Amount of NVRAM in KB",
- "type": "integer"
- },
- "mmap": {
- "description": "MMAP feature",
- "type": "boolean"
- },
- "sparsemem": {
- "description": "Sparse memory feature",
- "type": "boolean"
- },
- "clock_divisor": {
- "description": "Clock divisor",
- "type": "integer"
- },
- "idlepc": {
- "description": "Idle-PC value",
- "type": "string",
- "pattern": "^(0x[0-9a-fA-F]+)?$"
- },
- "idlemax": {
- "description": "Idlemax value",
- "type": "integer",
- },
- "idlesleep": {
- "description": "Idlesleep value",
- "type": "integer",
- },
- "exec_area": {
- "description": "Exec area value",
- "type": "integer",
- },
- "disk0": {
- "description": "Disk0 size in MB",
- "type": "integer"
- },
- "disk1": {
- "description": "Disk1 size in MB",
- "type": "integer"
- },
- "auto_delete_disks": {
- "description": "Automatically delete nvram and disk files",
- "type": "boolean"
- },
- "console": {
- "description": "Console TCP port",
- "type": ["integer", "null"],
- "minimum": 1,
- "maximum": 65535
- },
- "console_type": {
- "description": "Console type",
- "enum": ["telnet", "none"]
- },
- "aux": {
- "description": "Auxiliary console TCP port",
- "type": "integer",
- "minimum": 1,
- "maximum": 65535
- },
- "aux_type": {
- "description": "Auxiliary console type",
- "enum": ["telnet", "none"]
- },
- "mac_addr": {
- "description": "Base MAC address",
- "type": ["null", "string"],
- "minLength": 1,
- "pattern": "^([0-9a-fA-F]{4}\\.){2}[0-9a-fA-F]{4}$"
- },
- "system_id": {
- "description": "System ID",
- "type": "string",
- "minLength": 1,
- },
- "slot0": {
- "description": "Network module slot 0",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot1": {
- "description": "Network module slot 1",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot2": {
- "description": "Network module slot 2",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot3": {
- "description": "Network module slot 3",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot4": {
- "description": "Network module slot 4",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot5": {
- "description": "Network module slot 5",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot6": {
- "description": "Network module slot 6",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "wic0": {
- "description": "Network module WIC slot 0",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "wic1": {
- "description": "Network module WIC slot 0",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "wic2": {
- "description": "Network module WIC slot 0",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- # C7200 properties
- "npe": {
- "description": "NPE model",
- "enum": ["npe-100",
- "npe-150",
- "npe-175",
- "npe-200",
- "npe-225",
- "npe-300",
- "npe-400",
- "npe-g2"]
- },
- "midplane": {
- "description": "Midplane model",
- "enum": ["std", "vxr"]
- },
- "sensors": {
- "description": "Temperature sensors",
- "type": "array"
- },
- "power_supplies": {
- "description": "Power supplies status",
- "type": "array"
- },
- # I/O memory property for all platforms but C7200
- "iomem": {
- "description": "I/O memory percentage",
- "type": "integer",
- "minimum": 0,
- "maximum": 100
- },
- },
- "additionalProperties": False,
-}
-
-
-VM_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Dynamips VM instance",
- "type": "object",
- "properties": {
- "dynamips_id": {
- "description": "ID to use with Dynamips",
- "type": "integer"
- },
- "node_id": {
- "description": "Node 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}$"
- },
- "node_directory": {
- "description": "Path to the vm working directory",
- "type": "string"
- },
- "project_id": {
- "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}$"
- },
- "name": {
- "description": "Dynamips VM instance name",
- "type": "string",
- "minLength": 1,
- },
- "usage": {
- "description": "How to use the Dynamips VM",
- "type": "string",
- },
- "status": {
- "description": "VM status",
- "enum": ["started", "stopped", "suspended"]
- },
- "platform": {
- "description": "Cisco router platform",
- "type": "string",
- "minLength": 1,
- "pattern": "^c[0-9]{4}$"
- },
- "chassis": {
- "description": "Cisco router chassis model",
- "type": "string",
- "minLength": 1,
- "pattern": "^[0-9]{4}(XM)?$"
- },
- "image": {
- "description": "Path to the IOS image",
- "type": "string",
- "minLength": 1,
- },
- "image_md5sum": {
- "description": "Checksum of the IOS image",
- "type": ["string", "null"],
- "minLength": 1,
- },
- "ram": {
- "description": "Amount of RAM in MB",
- "type": "integer"
- },
- "nvram": {
- "description": "Amount of NVRAM in KB",
- "type": "integer"
- },
- "mmap": {
- "description": "MMAP feature",
- "type": "boolean"
- },
- "sparsemem": {
- "description": "Sparse memory feature",
- "type": "boolean"
- },
- "clock_divisor": {
- "description": "Clock divisor",
- "type": "integer"
- },
- "idlepc": {
- "description": "Idle-PC value",
- "type": "string",
- "pattern": "^(0x[0-9a-fA-F]+)?$"
- },
- "idlemax": {
- "description": "Idlemax value",
- "type": "integer",
- },
- "idlesleep": {
- "description": "Idlesleep value",
- "type": "integer",
- },
- "exec_area": {
- "description": "Exec area value",
- "type": "integer",
- },
- "disk0": {
- "description": "Disk0 size in MB",
- "type": "integer"
- },
- "disk1": {
- "description": "Disk1 size in MB",
- "type": "integer"
- },
- "auto_delete_disks": {
- "description": "Automatically delete nvram and disk files",
- "type": "boolean"
- },
- "console": {
- "description": "Console TCP port",
- "type": ["integer", "null"],
- "minimum": 1,
- "maximum": 65535
- },
- "console_type": {
- "description": "Console type",
- "enum": ["telnet", "none"]
- },
- "aux": {
- "description": "Auxiliary console TCP port",
- "type": ["integer", "null"],
- "minimum": 1,
- "maximum": 65535
- },
- "aux_type": {
- "description": "Auxiliary console type",
- "enum": ["telnet", "none"]
- },
- "mac_addr": {
- "description": "Base MAC address",
- "type": ["null", "string"]
- #"minLength": 1,
- #"pattern": "^([0-9a-fA-F]{4}\\.){2}[0-9a-fA-F]{4}$"
- },
- "system_id": {
- "description": "System ID",
- "type": "string",
- "minLength": 1,
- },
- "slot0": {
- "description": "Network module slot 0",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot1": {
- "description": "Network module slot 1",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot2": {
- "description": "Network module slot 2",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot3": {
- "description": "Network module slot 3",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot4": {
- "description": "Network module slot 4",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot5": {
- "description": "Network module slot 5",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "slot6": {
- "description": "Network module slot 6",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "wic0": {
- "description": "Network module WIC slot 0",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "wic1": {
- "description": "Network module WIC slot 0",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- "wic2": {
- "description": "Network module WIC slot 0",
- "oneOf": [
- {"type": "string"},
- {"type": "null"}
- ]
- },
- # C7200 properties
- "npe": {
- "description": "NPE model",
- "enum": ["npe-100",
- "npe-150",
- "npe-175",
- "npe-200",
- "npe-225",
- "npe-300",
- "npe-400",
- "npe-g2"]
- },
- "midplane": {
- "description": "Midplane model",
- "enum": ["std", "vxr"]
- },
- "sensors": {
- "description": "Temperature sensors",
- "type": "array"
- },
- "power_supplies": {
- "description": "Power supplies status",
- "type": "array"
- },
- # I/O memory property for all platforms but C7200
- "iomem": {
- "description": "I/O memory percentage",
- "type": "integer",
- "minimum": 0,
- "maximum": 100
- },
- },
- "additionalProperties": False,
- "required": ["name", "node_id", "project_id", "dynamips_id", "console", "console_type"]
-}
diff --git a/gns3server/endpoints/schemas/ethernet_hub_nodes.py b/gns3server/schemas/ethernet_hub_nodes.py
similarity index 100%
rename from gns3server/endpoints/schemas/ethernet_hub_nodes.py
rename to gns3server/schemas/ethernet_hub_nodes.py
diff --git a/gns3server/controller/schemas/ethernet_hub_templates.py b/gns3server/schemas/ethernet_hub_templates.py
similarity index 90%
rename from gns3server/controller/schemas/ethernet_hub_templates.py
rename to gns3server/schemas/ethernet_hub_templates.py
index 2676a120..0ca7542c 100644
--- a/gns3server/controller/schemas/ethernet_hub_templates.py
+++ b/gns3server/schemas/ethernet_hub_templates.py
@@ -16,8 +16,8 @@
# along with this program. If not, see .
-from gns3server.endpoints.schemas.templates import Category, TemplateBase
-from gns3server.endpoints.schemas.ethernet_hub_nodes import EthernetHubPort
+from .templates import Category, TemplateBase
+from .ethernet_hub_nodes import EthernetHubPort
from pydantic import Field
from typing import Optional, List
diff --git a/gns3server/endpoints/schemas/ethernet_switch_nodes.py b/gns3server/schemas/ethernet_switch_nodes.py
similarity index 100%
rename from gns3server/endpoints/schemas/ethernet_switch_nodes.py
rename to gns3server/schemas/ethernet_switch_nodes.py
diff --git a/gns3server/schemas/ethernet_switch_template.py b/gns3server/schemas/ethernet_switch_template.py
deleted file mode 100644
index e2473220..00000000
--- a/gns3server/schemas/ethernet_switch_template.py
+++ /dev/null
@@ -1,127 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2016 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 .
-
-import copy
-from .template import BASE_TEMPLATE_PROPERTIES
-
-
-ETHERNET_SWITCH_TEMPLATE_PROPERTIES = {
- "ports_mapping": {
- "type": "array",
- "default": [{"ethertype": "",
- "name": "Ethernet0",
- "vlan": 1,
- "type": "access",
- "port_number": 0
- },
- {"ethertype": "",
- "name": "Ethernet1",
- "vlan": 1,
- "type": "access",
- "port_number": 1
- },
- {"ethertype": "",
- "name": "Ethernet2",
- "vlan": 1,
- "type": "access",
- "port_number": 2
- },
- {"ethertype": "",
- "name": "Ethernet3",
- "vlan": 1,
- "type": "access",
- "port_number": 3
- },
- {"ethertype": "",
- "name": "Ethernet4",
- "vlan": 1,
- "type": "access",
- "port_number": 4
- },
- {"ethertype": "",
- "name": "Ethernet5",
- "vlan": 1,
- "type": "access",
- "port_number": 5
- },
- {"ethertype": "",
- "name": "Ethernet6",
- "vlan": 1,
- "type": "access",
- "port_number": 6
- },
- {"ethertype": "",
- "name": "Ethernet7",
- "vlan": 1,
- "type": "access",
- "port_number": 7
- }
- ],
- "items": [
- {"type": "object",
- "oneOf": [
- {
- "description": "Ethernet port",
- "properties": {
- "name": {
- "description": "Port name",
- "type": "string",
- "minLength": 1
- },
- "port_number": {
- "description": "Port number",
- "type": "integer",
- "minimum": 0
- },
- "type": {
- "description": "Port type",
- "enum": ["access", "dot1q", "qinq"],
- },
- "vlan": {"description": "VLAN number",
- "type": "integer",
- "minimum": 1
- },
- "ethertype": {
- "description": "QinQ Ethertype",
- "enum": ["", "0x8100", "0x88A8", "0x9100", "0x9200"],
- },
- },
- "required": ["name", "port_number", "type"],
- "additionalProperties": False
- },
- ]},
- ]
- },
- "console_type": {
- "description": "Console type",
- "enum": ["telnet", "none"],
- "default": "none"
- },
-}
-
-ETHERNET_SWITCH_TEMPLATE_PROPERTIES.update(copy.deepcopy(BASE_TEMPLATE_PROPERTIES))
-ETHERNET_SWITCH_TEMPLATE_PROPERTIES["category"]["default"] = "switch"
-ETHERNET_SWITCH_TEMPLATE_PROPERTIES["default_name_format"]["default"] = "Switch{0}"
-ETHERNET_SWITCH_TEMPLATE_PROPERTIES["symbol"]["default"] = ":/symbols/ethernet_switch.svg"
-
-ETHERNET_SWITCH_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "An Ethernet switch template object",
- "type": "object",
- "properties": ETHERNET_SWITCH_TEMPLATE_PROPERTIES,
- "additionalProperties": False
-}
diff --git a/gns3server/controller/schemas/ethernet_switch_templates.py b/gns3server/schemas/ethernet_switch_templates.py
similarity index 92%
rename from gns3server/controller/schemas/ethernet_switch_templates.py
rename to gns3server/schemas/ethernet_switch_templates.py
index c82977ea..f605d4fe 100644
--- a/gns3server/controller/schemas/ethernet_switch_templates.py
+++ b/gns3server/schemas/ethernet_switch_templates.py
@@ -16,8 +16,8 @@
# along with this program. If not, see .
-from gns3server.endpoints.schemas.templates import Category, TemplateBase
-from gns3server.endpoints.schemas.ethernet_switch_nodes import EthernetSwitchPort
+from .templates import Category, TemplateBase
+from .ethernet_switch_nodes import EthernetSwitchPort
from pydantic import Field
from typing import Optional, List
diff --git a/gns3server/schemas/filter.py b/gns3server/schemas/filter.py
deleted file mode 100644
index d7f09972..00000000
--- a/gns3server/schemas/filter.py
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2017 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 .
-
-
-FILTER_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Packet filter. This allow to simulate latency and errors",
- "type": "object"
-}
diff --git a/gns3server/endpoints/schemas/filters.py b/gns3server/schemas/filters.py
similarity index 100%
rename from gns3server/endpoints/schemas/filters.py
rename to gns3server/schemas/filters.py
diff --git a/gns3server/endpoints/schemas/frame_relay_switch_nodes.py b/gns3server/schemas/frame_relay_switch_nodes.py
similarity index 100%
rename from gns3server/endpoints/schemas/frame_relay_switch_nodes.py
rename to gns3server/schemas/frame_relay_switch_nodes.py
diff --git a/gns3server/endpoints/schemas/gns3vm.py b/gns3server/schemas/gns3vm.py
similarity index 100%
rename from gns3server/endpoints/schemas/gns3vm.py
rename to gns3server/schemas/gns3vm.py
diff --git a/gns3server/endpoints/schemas/iou_license.py b/gns3server/schemas/iou_license.py
similarity index 100%
rename from gns3server/endpoints/schemas/iou_license.py
rename to gns3server/schemas/iou_license.py
diff --git a/gns3server/endpoints/schemas/iou_nodes.py b/gns3server/schemas/iou_nodes.py
similarity index 100%
rename from gns3server/endpoints/schemas/iou_nodes.py
rename to gns3server/schemas/iou_nodes.py
diff --git a/gns3server/schemas/iou_template.py b/gns3server/schemas/iou_template.py
deleted file mode 100644
index aadfaf97..00000000
--- a/gns3server/schemas/iou_template.py
+++ /dev/null
@@ -1,92 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2016 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 .
-
-import copy
-from .template import BASE_TEMPLATE_PROPERTIES
-
-
-IOU_TEMPLATE_PROPERTIES = {
- "path": {
- "description": "Path of IOU executable",
- "type": "string",
- "minLength": 1
- },
- "ethernet_adapters": {
- "description": "Number of ethernet adapters",
- "type": "integer",
- "default": 2
- },
- "serial_adapters": {
- "description": "Number of serial adapters",
- "type": "integer",
- "default": 2
- },
- "ram": {
- "description": "RAM in MB",
- "type": "integer",
- "default": 256
- },
- "nvram": {
- "description": "NVRAM in KB",
- "type": "integer",
- "default": 128
- },
- "use_default_iou_values": {
- "description": "Use default IOU values",
- "type": "boolean",
- "default": True
- },
- "startup_config": {
- "description": "Startup-config of IOU",
- "type": "string",
- "default": "iou_l3_base_startup-config.txt"
- },
- "private_config": {
- "description": "Private-config of IOU",
- "type": "string",
- "default": ""
- },
- "l1_keepalives": {
- "description": "Always keep up Ethernet interface (does not always work)",
- "type": "boolean",
- "default": False
- },
- "console_type": {
- "description": "Console type",
- "enum": ["telnet", "none"],
- "default": "telnet"
- },
- "console_auto_start": {
- "description": "Automatically start the console when the node has started",
- "type": "boolean",
- "default": False
- },
-}
-
-IOU_TEMPLATE_PROPERTIES.update(copy.deepcopy(BASE_TEMPLATE_PROPERTIES))
-IOU_TEMPLATE_PROPERTIES["category"]["default"] = "router"
-IOU_TEMPLATE_PROPERTIES["default_name_format"]["default"] = "IOU{0}"
-IOU_TEMPLATE_PROPERTIES["symbol"]["default"] = ":/symbols/multilayer_switch.svg"
-
-IOU_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A IOU template object",
- "type": "object",
- "properties": IOU_TEMPLATE_PROPERTIES,
- "required": ["path"],
- "additionalProperties": False
-}
diff --git a/gns3server/controller/schemas/iou_templates.py b/gns3server/schemas/iou_templates.py
similarity index 93%
rename from gns3server/controller/schemas/iou_templates.py
rename to gns3server/schemas/iou_templates.py
index cc7ca9ac..aef82181 100644
--- a/gns3server/controller/schemas/iou_templates.py
+++ b/gns3server/schemas/iou_templates.py
@@ -16,8 +16,8 @@
# along with this program. If not, see .
-from gns3server.endpoints.schemas.templates import Category, TemplateBase
-from gns3server.endpoints.schemas.iou_nodes import ConsoleType
+from .templates import Category, TemplateBase
+from .iou_nodes import ConsoleType
from pydantic import Field
from pathlib import Path
diff --git a/gns3server/schemas/label.py b/gns3server/schemas/label.py
deleted file mode 100644
index 503ea64b..00000000
--- a/gns3server/schemas/label.py
+++ /dev/null
@@ -1,45 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2016 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 .
-
-LABEL_OBJECT_SCHEMA = {
- "type": "object",
- "properties": {
- "text": {"type": "string"},
- "style": {
- "description": "SVG style attribute. Apply default style if null",
- "type": ["string", "null"]
- },
- "x": {
- "description": "Relative X position of the label. Center it if null",
- "type": ["integer", "null"]
- },
- "y": {
- "description": "Relative Y position of the label",
- "type": "integer"
- },
- "rotation": {
- "description": "Rotation of the label",
- "type": "integer",
- "minimum": -359,
- "maximum": 360
- },
- },
- "required": [
- "text"
- ],
- "additionalProperties": False
-}
diff --git a/gns3server/schemas/link.py b/gns3server/schemas/link.py
deleted file mode 100644
index 6dd5ffe4..00000000
--- a/gns3server/schemas/link.py
+++ /dev/null
@@ -1,112 +0,0 @@
-#!/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 .
-
-from .label import LABEL_OBJECT_SCHEMA
-from .filter import FILTER_OBJECT_SCHEMA
-
-LINK_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A link object",
- "type": "object",
- "properties": {
- "link_id": {
- "description": "Link 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}$"
- },
- "project_id": {
- "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}$"
- },
- "nodes": {
- "description": "List of the VMS",
- "type": "array",
- "items": {
- "type": "object",
- "properties": {
- "node_id": {
- "description": "Node 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}$"
- },
- "adapter_number": {
- "description": "Adapter number",
- "type": "integer"
- },
- "port_number": {
- "description": "Port number",
- "type": "integer"
- },
- "label": LABEL_OBJECT_SCHEMA
- },
- "required": ["node_id", "adapter_number", "port_number"],
- "additionalProperties": False
- }
- },
- "suspend": {
- "type": "boolean",
- "description": "Suspend the link"
- },
- "filters": FILTER_OBJECT_SCHEMA,
- "capturing": {
- "description": "Read only property. True if a capture running on the link",
- "type": "boolean"
- },
- "capture_file_name": {
- "description": "Read only property. The name of the capture file if a capture is running",
- "type": ["string", "null"]
- },
- "capture_file_path": {
- "description": "Read only property. The full path of the capture file if a capture is running",
- "type": ["string", "null"]
- },
- "capture_compute_id": {
- "description": "Read only property. The compute identifier where a capture is running",
- "type": ["string", "null"]
- },
- "link_type": {
- "description": "Type of link",
- "enum": ["ethernet", "serial"]
- }
- },
- "additionalProperties": False
-}
-
-
-LINK_CAPTURE_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to start a packet capture on a link",
- "type": "object",
- "properties": {
- "data_link_type": {
- "description": "PCAP data link type (http://www.tcpdump.org/linktypes.html)",
- "enum": ["DLT_ATM_RFC1483", "DLT_EN10MB", "DLT_FRELAY", "DLT_C_HDLC", "DLT_PPP_SERIAL"]
- },
- "capture_file_name": {
- "description": "Read only property. The name of the capture file if capture is running",
- "type": "string"
- }
- },
- "additionalProperties": False
-}
diff --git a/gns3server/endpoints/schemas/links.py b/gns3server/schemas/links.py
similarity index 100%
rename from gns3server/endpoints/schemas/links.py
rename to gns3server/schemas/links.py
diff --git a/gns3server/endpoints/schemas/nat_nodes.py b/gns3server/schemas/nat_nodes.py
similarity index 100%
rename from gns3server/endpoints/schemas/nat_nodes.py
rename to gns3server/schemas/nat_nodes.py
diff --git a/gns3server/schemas/nio.py b/gns3server/schemas/nio.py
deleted file mode 100644
index edee0eab..00000000
--- a/gns3server/schemas/nio.py
+++ /dev/null
@@ -1,192 +0,0 @@
-# -*- 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 .
-
-from .filter import FILTER_OBJECT_SCHEMA
-
-
-NIO_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to add a NIO for a VM instance",
- "type": "object",
- "definitions": {
- "UDP": {
- "description": "UDP Network Input/Output",
- "properties": {
- "type": {
- "enum": ["nio_udp"]
- },
- "lport": {
- "description": "Local port",
- "type": "integer",
- "minimum": 1,
- "maximum": 65535
- },
- "rhost": {
- "description": "Remote host",
- "type": "string",
- "minLength": 1
- },
- "rport": {
- "description": "Remote port",
- "type": "integer",
- "minimum": 1,
- "maximum": 65535
- },
- "suspend": {
- "type": "boolean",
- "description": "Suspend the link"
- },
- "filters": FILTER_OBJECT_SCHEMA
- },
- "required": ["type", "lport", "rhost", "rport"],
- "additionalProperties": False
- },
- "Ethernet": {
- "description": "Generic Ethernet Network Input/Output",
- "properties": {
- "type": {
- "enum": ["nio_generic_ethernet", "nio_ethernet"]
- },
- "ethernet_device": {
- "description": "Ethernet device name e.g. eth0",
- "type": "string",
- "minLength": 1
- },
- },
- "required": ["type", "ethernet_device"],
- "additionalProperties": False
- },
- "LinuxEthernet": {
- "description": "Linux Ethernet Network Input/Output",
- "properties": {
- "type": {
- "enum": ["nio_linux_ethernet"]
- },
- "ethernet_device": {
- "description": "Ethernet device name e.g. eth0",
- "type": "string",
- "minLength": 1
- },
- },
- "required": ["type", "ethernet_device"],
- "additionalProperties": False
- },
- "NAT": {
- "description": "NAT Network Input/Output",
- "properties": {
- "type": {
- "enum": ["nio_nat"]
- },
- },
- "required": ["type"],
- "additionalProperties": False
- },
- "TAP": {
- "description": "TAP Network Input/Output",
- "properties": {
- "type": {
- "enum": ["nio_tap"]
- },
- "tap_device": {
- "description": "TAP device name e.g. tap0",
- "type": "string",
- "minLength": 1
- },
- },
- "required": ["type", "tap_device"],
- "additionalProperties": False
- },
- "UNIX": {
- "description": "UNIX Network Input/Output",
- "properties": {
- "type": {
- "enum": ["nio_unix"]
- },
- "local_file": {
- "description": "path to the UNIX socket file (local)",
- "type": "string",
- "minLength": 1
- },
- "remote_file": {
- "description": "path to the UNIX socket file (remote)",
- "type": "string",
- "minLength": 1
- },
- },
- "required": ["type", "local_file", "remote_file"],
- "additionalProperties": False
- },
- "VDE": {
- "description": "VDE Network Input/Output",
- "properties": {
- "type": {
- "enum": ["nio_vde"]
- },
- "control_file": {
- "description": "path to the VDE control file",
- "type": "string",
- "minLength": 1
- },
- "local_file": {
- "description": "path to the VDE control file",
- "type": "string",
- "minLength": 1
- },
- },
- "required": ["type", "control_file", "local_file"],
- "additionalProperties": False
- },
- "VMNET": {
- "description": "VMNET Network Input/Output",
- "properties": {
- "type": {
- "enum": ["nio_vmnet"]
- },
- "vmnet": {
- "description": "VMnet interface name e.g. vmnet12",
- "type": "string",
- "minLength": 1
- },
- },
- "required": ["type", "vmnet"],
- "additionalProperties": False
- },
- "NULL": {
- "description": "NULL Network Input/Output",
- "properties": {
- "type": {
- "enum": ["nio_null"]
- },
- },
- "required": ["type"],
- "additionalProperties": False
- },
- },
- "oneOf": [
- {"$ref": "#/definitions/UDP"},
- {"$ref": "#/definitions/Ethernet"},
- {"$ref": "#/definitions/LinuxEthernet"},
- {"$ref": "#/definitions/NAT"},
- {"$ref": "#/definitions/TAP"},
- {"$ref": "#/definitions/UNIX"},
- {"$ref": "#/definitions/VDE"},
- {"$ref": "#/definitions/VMNET"},
- {"$ref": "#/definitions/NULL"},
- ],
- "additionalProperties": True,
- "required": ["type"]
-}
diff --git a/gns3server/endpoints/schemas/nios.py b/gns3server/schemas/nios.py
similarity index 100%
rename from gns3server/endpoints/schemas/nios.py
rename to gns3server/schemas/nios.py
diff --git a/gns3server/schemas/node.py b/gns3server/schemas/node.py
deleted file mode 100644
index d7d92583..00000000
--- a/gns3server/schemas/node.py
+++ /dev/null
@@ -1,301 +0,0 @@
-#!/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 .
-
-import copy
-from .label import LABEL_OBJECT_SCHEMA
-from .custom_adapters import CUSTOM_ADAPTERS_ARRAY_SCHEMA
-
-NODE_TYPE_SCHEMA = {
- "description": "Type of node",
- "enum": [
- "cloud",
- "nat",
- "ethernet_hub",
- "ethernet_switch",
- "frame_relay_switch",
- "atm_switch",
- "docker",
- "dynamips",
- "vpcs",
- "traceng",
- "virtualbox",
- "vmware",
- "iou",
- "qemu"
- ]
-}
-
-NODE_LIST_IMAGES_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "List of binary images",
- "type": "array",
- "items": [
- {
- "type": "object",
- "properties": {
- "filename": {
- "description": "Image filename",
- "type": "string",
- "minLength": 1
- },
- "path": {
- "description": "Image path",
- "type": "string",
- "minLength": 1
- },
- "md5sum": {
- "description": "md5sum of the image if available",
- "type": ["string", "null"],
- "minLength": 1
- },
- "filesize": {
- "description": "size of the image if available",
- "type": ["integer", "null"],
- "minimum": 0
- }
- },
- "required": ["filename", "path"],
- "additionalProperties": False
- }
- ],
- "additionalProperties": False,
-}
-
-
-NODE_CAPTURE_SCHEMA = {
- "$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": {
- "description": "PCAP data link type (http://www.tcpdump.org/linktypes.html)",
- "enum": ["DLT_ATM_RFC1483", "DLT_EN10MB", "DLT_FRELAY", "DLT_C_HDLC", "DLT_PPP_SERIAL"]
- }
- },
- "additionalProperties": False,
- "required": ["capture_file_name"]
-}
-
-
-NODE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A node object",
- "type": "object",
- "properties": {
- "compute_id": {
- "description": "Compute identifier",
- "type": "string"
- },
- "project_id": {
- "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}$"
- },
- "node_id": {
- "description": "Node 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}$"
- },
- "template_id": {
- "description": "Template UUID from which the node has been created. Read only",
- "type": ["null", "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}$"
- },
- "node_type": NODE_TYPE_SCHEMA,
- "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"]
- },
- "name": {
- "description": "Node name",
- "type": "string",
- "minLength": 1,
- },
- "console": {
- "description": "Console TCP port",
- "minimum": 1,
- "maximum": 65535,
- "type": ["integer", "null"]
- },
- "console_host": {
- "description": "Console host. Warning if the host is 0.0.0.0 or :: (listen on all interfaces) you need to use the same address you use to connect to the controller.",
- "type": "string",
- "minLength": 1,
- },
- "console_type": {
- "description": "Console type",
- "enum": ["vnc", "telnet", "http", "https", "spice", "spice+agent", "none", None]
- },
- "console_auto_start": {
- "description": "Automatically start the console when the node has started",
- "type": "boolean"
- },
- "aux": {
- "description": "Auxiliary console TCP port",
- "minimum": 1,
- "maximum": 65535,
- "type": ["integer", "null"]
- },
- "aux_type": {
- "description": "Auxiliary console type",
- "enum": ["vnc", "telnet", "http", "https", "spice", "spice+agent", "none", None]
- },
- "properties": {
- "description": "Properties specific to an emulator",
- "type": "object"
- },
- "status": {
- "description": "Status of the node",
- "enum": ["stopped", "started", "suspended"]
- },
- "label": LABEL_OBJECT_SCHEMA,
- "symbol": {
- "description": "Symbol of the node",
- "type": ["string", "null"],
- "minLength": 1
- },
- "width": {
- "description": "Width of the node (Read only)",
- "type": "integer"
- },
- "height": {
- "description": "Height of the node (Read only)",
- "type": "integer"
- },
- "x": {
- "description": "X position of the node",
- "type": "integer"
- },
- "y": {
- "description": "Y position of the node",
- "type": "integer"
- },
- "z": {
- "description": "Z position of the node",
- "type": "integer"
- },
- "locked": {
- "description": "Whether the element locked or not",
- "type": "boolean"
- },
- "port_name_format": {
- "description": "Formating for port name {0} will be replace by port number",
- "type": "string"
- },
- "port_segment_size": {
- "description": "Size of the port segment",
- "type": "integer",
- "minimum": 0
- },
- "first_port_name": {
- "description": "Name of the first port",
- "type": ["string", "null"],
- },
- "custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA,
- "ports": {
- "description": "List of node ports READ only",
- "type": "array",
- "items": {
- "type": "object",
- "description": "A node port",
- "properties": {
- "name": {
- "type": "string",
- "description": "Port name",
- },
- "short_name": {
- "type": "string",
- "description": "Short version of port name",
- },
- "adapter_number": {
- "type": "integer",
- "description": "Adapter slot"
- },
- "adapter_type": {
- "description": "Adapter type",
- "type": ["string", "null"],
- "minLength": 1,
- },
- "port_number": {
- "type": "integer",
- "description": "Port slot"
- },
- "link_type": {
- "description": "Type of link",
- "enum": ["ethernet", "serial"]
- },
- "data_link_types": {
- "type": "object",
- "description": "Available PCAP types for capture",
- "properties": {}
- },
- "mac_address": {
- "description": "MAC address (if available)",
- "type": ["string", "null"],
- "minLength": 1,
- "pattern": "^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$"
- },
- },
- "additionalProperties": False
- }
- }
- },
- "additionalProperties": False,
- "required": ["name", "node_type", "compute_id"]
-}
-
-NODE_CREATE_SCHEMA = NODE_OBJECT_SCHEMA
-NODE_UPDATE_SCHEMA = copy.deepcopy(NODE_OBJECT_SCHEMA)
-del NODE_UPDATE_SCHEMA["required"]
-
-
-NODE_DUPLICATE_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Duplicate a node",
- "type": "object",
- "properties": {
- "x": {
- "description": "X position of the node",
- "type": "integer"
- },
- "y": {
- "description": "Y position of the node",
- "type": "integer"
- },
- "z": {
- "description": "Z position of the node",
- "type": "integer"
- }
- },
- "additionalProperties": False,
- "required": ["x", "y"]
-}
diff --git a/gns3server/endpoints/schemas/nodes.py b/gns3server/schemas/nodes.py
similarity index 100%
rename from gns3server/endpoints/schemas/nodes.py
rename to gns3server/schemas/nodes.py
diff --git a/gns3server/schemas/port.py b/gns3server/schemas/port.py
deleted file mode 100644
index 26c00913..00000000
--- a/gns3server/schemas/port.py
+++ /dev/null
@@ -1,115 +0,0 @@
-#!/usr/bin/env python
-#
-# Copyright (C) 2016 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 .
-
-
-PORT_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A port use in the cloud",
- "type": "object",
- "oneOf": [
- {
- "description": "Ethernet interface port",
- "properties": {
- "name": {
- "description": "Port name",
- "type": "string",
- "minLength": 1,
- },
- "port_number": {
- "description": "Port number",
- "type": "integer",
- "minimum": 0
- },
- "type": {
- "description": "Port type",
- "enum": ["ethernet"]
- },
- "interface": {
- "description": "Ethernet interface name e.g. eth0",
- "type": "string",
- "minLength": 1
- },
- },
- "required": ["name", "port_number", "type", "interface"],
- "additionalProperties": False
- },
- {
- "description": "TAP interface port",
- "properties": {
- "name": {
- "description": "Port name",
- "type": "string",
- "minLength": 1,
- },
- "port_number": {
- "description": "Port number",
- "type": "integer",
- "minimum": 0
- },
- "type": {
- "description": "Port type",
- "enum": ["tap"]
- },
- "interface": {
- "description": "TAP interface name e.g. tap0",
- "type": "string",
- "minLength": 1
- },
- },
- "required": ["name", "port_number", "type", "interface"],
- "additionalProperties": False
- },
- {
- "description": "UDP tunnel port",
- "properties": {
- "name": {
- "description": "Port name",
- "type": "string",
- "minLength": 1,
- },
- "port_number": {
- "description": "Port number",
- "type": "integer",
- "minimum": 0
- },
- "type": {
- "description": "Port type",
- "enum": ["udp"]
- },
- "lport": {
- "description": "Local UDP tunnel port",
- "type": "integer",
- "minimum": 1,
- "maximum": 65535
- },
- "rhost": {
- "description": "Remote UDP tunnel host",
- "type": "string",
- "minLength": 1
- },
- "rport": {
- "description": "Remote UDP tunnel port",
- "type": "integer",
- "minimum": 1,
- "maximum": 65535
- }
- },
- "required": ["name", "port_number", "type", "lport", "rhost", "rport"],
- "additionalProperties": False
- }
- ]
-}
diff --git a/gns3server/schemas/project.py b/gns3server/schemas/project.py
deleted file mode 100644
index b65b745b..00000000
--- a/gns3server/schemas/project.py
+++ /dev/null
@@ -1,329 +0,0 @@
-# -*- 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 .
-
-import copy
-
-SUPPLIER_OBJECT_SCHEMA = {
- "type": ["object", "null"],
- "description": "Supplier of the project",
- "properties": {
- "logo": {
- "type": "string",
- "description": "Path to the project supplier logo"
- },
- "url": {
- "type": "string",
- "description": "URL to the project supplier site"
- }
- }
-}
-
-
-VARIABLES_OBJECT_SCHEMA = {
- "type": ["array", "null"],
- "description": "Variables required to run the project",
- "items": {
- "properties": {
- "name": {
- "type": "string",
- "description": "Variable name",
- "minLength": 1
- },
- "value": {
- "type": "string",
- "description": "Variable value"
- }
- },
- "required": ["name"]
- }
-}
-
-
-PROJECT_CREATE_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to create a new Project instance",
- "type": "object",
- "properties": {
- "name": {
- "description": "Project name",
- "type": ["string", "null"],
- "minLength": 1
- },
- "path": {
- "description": "Project directory",
- "type": ["string", "null"],
- "minLength": 1
- },
- "auto_close": {
- "description": "Project auto close",
- "type": "boolean"
- },
- "project_id": {
- "description": "Project UUID",
- "type": ["string", "null"],
- "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}$"
- },
- "scene_height": {
- "type": "integer",
- "description": "Height of the drawing area"
- },
- "scene_width": {
- "type": "integer",
- "description": "Width of the drawing area"
- },
- "zoom": {
- "type": "integer",
- "description": "Zoom of the drawing area"
- },
- "show_layers": {
- "type": "boolean",
- "description": "Show layers on the drawing area"
- },
- "snap_to_grid": {
- "type": "boolean",
- "description": "Snap to grid on the drawing area"
- },
- "show_grid": {
- "type": "boolean",
- "description": "Show the grid on the drawing area"
- },
- "grid_size": {
- "type": "integer",
- "description": "Grid size for the drawing area for nodes"
- },
- "drawing_grid_size": {
- "type": "integer",
- "description": "Grid size for the drawing area for drawings"
- },
- "show_interface_labels": {
- "type": "boolean",
- "description": "Show interface labels on the drawing area"
- },
- "supplier": SUPPLIER_OBJECT_SCHEMA,
- "variables": VARIABLES_OBJECT_SCHEMA
- },
- "additionalProperties": False,
- "required": ["name"]
-}
-
-# Create a project duplicate schema based on create schema and add "reset_mac_addresses" properties
-PROJECT_DUPLICATE_SCHEMA = copy.deepcopy(PROJECT_CREATE_SCHEMA)
-PROJECT_DUPLICATE_SCHEMA["description"] = "Request validation to duplicate a Project instance"
-PROJECT_DUPLICATE_SCHEMA["properties"].update({"reset_mac_addresses": {"type": "boolean",
- "description": "Reset MAC addresses for this project"
- }})
-
-PROJECT_UPDATE_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to update a Project instance",
- "type": "object",
- "properties": {
- "name": {
- "description": "Project name",
- "type": ["string", "null"],
- "minLength": 1
- },
- "path": {
- "description": "Path of the project on the server (work only with --local)",
- "type": ["string", "null"]
- },
- "auto_close": {
- "description": "Project auto close when client cut off the notifications feed",
- "type": "boolean"
- },
- "auto_open": {
- "description": "Project open when GNS3 start",
- "type": "boolean"
- },
- "auto_start": {
- "description": "Project start when opened",
- "type": "boolean"
- },
- "scene_height": {
- "type": "integer",
- "description": "Height of the drawing area"
- },
- "scene_width": {
- "type": "integer",
- "description": "Width of the drawing area"
- },
- "zoom": {
- "type": "integer",
- "description": "Zoom of the drawing area"
- },
- "show_layers": {
- "type": "boolean",
- "description": "Show layers on the drawing area"
- },
- "snap_to_grid": {
- "type": "boolean",
- "description": "Snap to grid on the drawing area"
- },
- "show_grid": {
- "type": "boolean",
- "description": "Show the grid on the drawing area"
- },
- "grid_size": {
- "type": "integer",
- "description": "Grid size for the drawing area for nodes"
- },
- "drawing_grid_size": {
- "type": "integer",
- "description": "Grid size for the drawing area for drawings"
- },
- "show_interface_labels": {
- "type": "boolean",
- "description": "Show interface labels on the drawing area"
- },
- "supplier": SUPPLIER_OBJECT_SCHEMA,
- "variables": VARIABLES_OBJECT_SCHEMA
- },
- "additionalProperties": False,
-}
-
-PROJECT_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Project instance",
- "type": "object",
- "properties": {
- "name": {
- "description": "Project name",
- "type": ["string", "null"],
- "minLength": 1
- },
- "project_id": {
- "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}$"
- },
- "path": {
- "description": "Project directory",
- "type": ["string", "null"],
- "minLength": 1
- },
- "filename": {
- "description": "Project filename",
- "type": ["string", "null"],
- "minLength": 1
- },
- "status": {
- "description": "Project status Read only",
- "enum": ["opened", "closed"]
- },
- "auto_close": {
- "description": "Project auto close when client cut off the notifications feed",
- "type": "boolean"
- },
- "auto_open": {
- "description": "Project open when GNS3 start",
- "type": "boolean"
- },
- "auto_start": {
- "description": "Project start when opened",
- "type": "boolean"
- },
- "scene_height": {
- "type": "integer",
- "description": "Height of the drawing area"
- },
- "scene_width": {
- "type": "integer",
- "description": "Width of the drawing area"
- },
- "zoom": {
- "type": "integer",
- "description": "Zoom of the drawing area"
- },
- "show_layers": {
- "type": "boolean",
- "description": "Show layers on the drawing area"
- },
- "snap_to_grid": {
- "type": "boolean",
- "description": "Snap to grid on the drawing area"
- },
- "show_grid": {
- "type": "boolean",
- "description": "Show the grid on the drawing area"
- },
- "grid_size": {
- "type": "integer",
- "description": "Grid size for the drawing area for nodes"
- },
- "drawing_grid_size": {
- "type": "integer",
- "description": "Grid size for the drawing area for drawings"
- },
- "show_interface_labels": {
- "type": "boolean",
- "description": "Show interface labels on the drawing area"
- },
- "supplier": SUPPLIER_OBJECT_SCHEMA,
- "variables": VARIABLES_OBJECT_SCHEMA
- },
- "additionalProperties": False,
- "required": ["project_id"]
-}
-
-PROJECT_LOAD_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Load a project",
- "type": "object",
- "properties": {
- "path": {
- "description": ".gns3 path",
- "type": "string",
- "minLength": 1
- }
- },
- "additionalProperties": False,
- "required": ["path"]
-}
-
-PROJECT_LIST_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "List of projects",
- "type": "array",
- "items": PROJECT_OBJECT_SCHEMA
-}
-
-PROJECT_FILE_LIST_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "List files in the project",
- "type": "array",
- "items": [
- {
- "type": "object",
- "properties": {
- "path": {
- "description": "File path",
- "type": ["string"]
- },
- "md5sum": {
- "description": "MD5 hash of the file",
- "type": ["string"]
- },
-
- },
- }
- ],
- "additionalProperties": False,
-}
diff --git a/gns3server/endpoints/schemas/projects.py b/gns3server/schemas/projects.py
similarity index 100%
rename from gns3server/endpoints/schemas/projects.py
rename to gns3server/schemas/projects.py
diff --git a/gns3server/schemas/qemu.py b/gns3server/schemas/qemu.py
deleted file mode 100644
index 41a79d50..00000000
--- a/gns3server/schemas/qemu.py
+++ /dev/null
@@ -1,886 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2014 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 .
-
-from .custom_adapters import CUSTOM_ADAPTERS_ARRAY_SCHEMA
-
-QEMU_PLATFORMS = ["aarch64", "alpha", "arm", "cris", "i386", "lm32", "m68k", "microblaze", "microblazeel", "mips", "mips64", "mips64el", "mipsel", "moxie", "or32", "ppc", "ppc64", "ppcemb", "s390x", "sh4", "sh4eb", "sparc", "sparc64", "tricore", "unicore32", "x86_64", "xtensa", "xtensaeb", ""]
-
-
-QEMU_CREATE_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to create a new QEMU VM instance",
- "type": "object",
- "properties": {
- "node_id": {
- "description": "Node UUID",
- "oneOf": [
- {"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}$"},
- {"type": "integer"} # for legacy projects
- ]
- },
- "name": {
- "description": "QEMU VM instance name",
- "type": "string",
- "minLength": 1,
- },
- "usage": {
- "description": "How to use the Qemu VM",
- "type": "string",
- },
- "linked_clone": {
- "description": "Whether the VM is a linked clone or not",
- "type": "boolean"
- },
- "qemu_path": {
- "description": "Path to QEMU",
- "type": ["string", "null"],
- "minLength": 1,
- },
- "platform": {
- "description": "Platform to emulate",
- "enum": QEMU_PLATFORMS + ["null"]
- },
- "console": {
- "description": "Console TCP port",
- "minimum": 1,
- "maximum": 65535,
- "type": ["integer", "null"]
- },
- "console_type": {
- "description": "Console type",
- "enum": ["telnet", "vnc", "spice", "spice+agent", "none"]
- },
- "aux": {
- "description": "Auxiliary TCP port",
- "minimum": 1,
- "maximum": 65535,
- "type": ["integer", "null"]
- },
- "aux_type": {
- "description": "Auxiliary console type",
- "enum": ["telnet", "vnc", "spice", "spice+agent", "none"]
- },
- "hda_disk_image": {
- "description": "QEMU hda disk image path",
- "type": "string",
- },
- "hda_disk_interface": {
- "description": "QEMU hda interface",
- "type": "string",
- },
- "hda_disk_image_md5sum": {
- "description": "QEMU hda disk image checksum",
- "type": ["string", "null"]
- },
- "hdb_disk_image": {
- "description": "QEMU hdb disk image path",
- "type": "string",
- },
- "hdb_disk_interface": {
- "description": "QEMU hdb interface",
- "type": "string",
- },
- "hdb_disk_image_md5sum": {
- "description": "QEMU hdb disk image checksum",
- "type": ["string", "null"],
- },
- "hdc_disk_image": {
- "description": "QEMU hdc disk image path",
- "type": "string",
- },
- "hdc_disk_interface": {
- "description": "QEMU hdc interface",
- "type": "string",
- },
- "hdc_disk_image_md5sum": {
- "description": "QEMU hdc disk image checksum",
- "type": ["string", "null"],
- },
- "hdd_disk_image": {
- "description": "QEMU hdd disk image path",
- "type": "string",
- },
- "hdd_disk_interface": {
- "description": "QEMU hdd interface",
- "type": "string",
- },
- "hdd_disk_image_md5sum": {
- "description": "QEMU hdd disk image checksum",
- "type": ["string", "null"],
- },
- "cdrom_image": {
- "description": "QEMU cdrom image path",
- "type": "string",
- },
- "cdrom_image_md5sum": {
- "description": "QEMU cdrom image checksum",
- "type": ["string", "null"],
- },
- "bios_image": {
- "description": "QEMU bios image path",
- "type": "string",
- },
- "bios_image_md5sum": {
- "description": "QEMU bios image checksum",
- "type": ["string", "null"],
- },
- "boot_priority": {
- "description": "QEMU boot priority",
- "enum": ["c", "d", "n", "cn", "cd", "dn", "dc", "nc", "nd"]
- },
- "ram": {
- "description": "Amount of RAM in MB",
- "type": ["integer", "null"]
- },
- "cpus": {
- "description": "Number of vCPUs",
- "type": ["integer", "null"],
- "minimum": 1,
- "maximum": 255,
- },
- "maxcpus": {
- "description": "Maximum number of hotpluggable vCPUs",
- "type": ["integer", "null"],
- "minimum": 1,
- "maximum": 255,
- },
- "adapters": {
- "description": "Number of adapters",
- "type": ["integer", "null"],
- "minimum": 0,
- "maximum": 275,
- },
- "adapter_type": {
- "description": "QEMU adapter type",
- "type": ["string", "null"],
- "minLength": 1,
- },
- "mac_address": {
- "description": "QEMU MAC address",
- "type": ["string", "null"],
- "minLength": 1,
- "pattern": "^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$"
- },
- "initrd": {
- "description": "QEMU initrd path",
- "type": "string",
- },
- "initrd_md5sum": {
- "description": "QEMU initrd path",
- "type": ["string", "null"],
- },
- "kernel_image": {
- "description": "QEMU kernel image path",
- "type": "string",
- },
- "kernel_image_md5sum": {
- "description": "QEMU kernel image checksum",
- "type": ["string", "null"],
- },
- "kernel_command_line": {
- "description": "QEMU kernel command line",
- "type": ["string", "null"],
- },
- "legacy_networking": {
- "description": "Use QEMU legagy networking commands (-net syntax)",
- "type": ["boolean", "null"],
- },
- "replicate_network_connection_state": {
- "description": "Replicate the network connection state for links in Qemu",
- "type": ["boolean", "null"],
- },
- "create_config_disk": {
- "description": "Automatically create a config disk on HDD disk interface (secondary slave)",
- "type": ["boolean", "null"],
- },
- "on_close": {
- "description": "Action to execute on the VM is closed",
- "enum": ["power_off", "shutdown_signal", "save_vm_state"],
- },
- "cpu_throttling": {
- "description": "Percentage of CPU allowed for QEMU",
- "minimum": 0,
- "maximum": 800,
- "type": ["integer", "null"],
- },
- "process_priority": {
- "description": "Process priority for QEMU",
- "enum": ["realtime",
- "very high",
- "high",
- "normal",
- "low",
- "very low",
- "null"]
- },
- "options": {
- "description": "Additional QEMU options",
- "type": ["string", "null"],
- },
- "custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA
- },
- "additionalProperties": False,
- "required": ["name"],
-}
-
-QEMU_UPDATE_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to update a QEMU VM instance",
- "type": "object",
- "properties": {
- "name": {
- "description": "QEMU VM instance name",
- "type": ["string", "null"],
- "minLength": 1,
- },
- "usage": {
- "description": "How to use the QEMU VM",
- "type": "string",
- },
- "qemu_path": {
- "description": "Path to QEMU",
- "type": ["string", "null"],
- "minLength": 1,
- },
- "platform": {
- "description": "Platform to emulate",
- "enum": QEMU_PLATFORMS + ["null"]
- },
- "console": {
- "description": "Console TCP port",
- "minimum": 1,
- "maximum": 65535,
- "type": ["integer", "null"]
- },
- "console_type": {
- "description": "Console type",
- "enum": ["telnet", "vnc", "spice", "spice+agent", "none"]
- },
- "aux": {
- "description": "Auxiliary TCP port",
- "minimum": 1,
- "maximum": 65535,
- "type": ["integer", "null"]
- },
- "aux_type": {
- "description": "Auxiliary console type",
- "enum": ["telnet", "vnc", "spice", "spice+agent", "none"]
- },
- "linked_clone": {
- "description": "Whether the VM is a linked clone or not",
- "type": "boolean"
- },
- "hda_disk_image": {
- "description": "QEMU hda disk image path",
- "type": "string",
- },
- "hda_disk_interface": {
- "description": "QEMU hda interface",
- "type": "string",
- },
- "hda_disk_image_md5sum": {
- "description": "QEMU hda disk image checksum",
- "type": ["string", "null"]
- },
- "hdb_disk_image": {
- "description": "QEMU hdb disk image path",
- "type": "string",
- },
- "hdb_disk_interface": {
- "description": "QEMU hdb interface",
- "type": "string",
- },
- "hdb_disk_image_md5sum": {
- "description": "QEMU hdb disk image checksum",
- "type": ["string", "null"],
- },
- "hdc_disk_image": {
- "description": "QEMU hdc disk image path",
- "type": "string",
- },
- "hdc_disk_interface": {
- "description": "QEMU hdc interface",
- "type": "string",
- },
- "hdc_disk_image_md5sum": {
- "description": "QEMU hdc disk image checksum",
- "type": ["string", "null"],
- },
- "hdd_disk_image": {
- "description": "QEMU hdd disk image path",
- "type": "string",
- },
- "hdd_disk_interface": {
- "description": "QEMU hdd interface",
- "type": "string",
- },
- "hdd_disk_image_md5sum": {
- "description": "QEMU hdd disk image checksum",
- "type": ["string", "null"],
- },
- "bios_image": {
- "description": "QEMU bios image path",
- "type": "string",
- },
- "bios_image_md5sum": {
- "description": "QEMU bios image checksum",
- "type": ["string", "null"],
- },
- "cdrom_image": {
- "description": "QEMU cdrom image path",
- "type": "string",
- },
- "cdrom_image_md5sum": {
- "description": "QEMU cdrom image checksum",
- "type": ["string", "null"],
- },
- "boot_priority": {
- "description": "QEMU boot priority",
- "enum": ["c", "d", "n", "cn", "cd", "dn", "dc", "nc", "nd"]
- },
- "ram": {
- "description": "Amount of RAM in MB",
- "type": ["integer", "null"]
- },
- "cpus": {
- "description": "Number of vCPUs",
- "type": ["integer", "null"],
- "minimum": 1,
- "maximum": 255,
- },
- "maxcpus": {
- "description": "Maximum number of hotpluggable vCPUs",
- "type": ["integer", "null"],
- "minimum": 1,
- "maximum": 255,
- },
- "adapters": {
- "description": "Number of adapters",
- "type": ["integer", "null"],
- "minimum": 0,
- "maximum": 275,
- },
- "adapter_type": {
- "description": "QEMU adapter type",
- "type": ["string", "null"],
- "minLength": 1,
- },
- "mac_address": {
- "description": "QEMU MAC address",
- "type": ["string", "null"],
- "minLength": 1,
- "pattern": "^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$"
- },
- "initrd": {
- "description": "QEMU initrd path",
- "type": "string",
- },
- "initrd_md5sum": {
- "description": "QEMU initrd path",
- "type": ["string", "null"],
- },
- "kernel_image": {
- "description": "QEMU kernel image path",
- "type": "string",
- },
- "kernel_image_md5sum": {
- "description": "QEMU kernel image checksum",
- "type": ["string", "null"],
- },
- "kernel_command_line": {
- "description": "QEMU kernel command line",
- "type": ["string", "null"],
- },
- "legacy_networking": {
- "description": "Use QEMU legagy networking commands (-net syntax)",
- "type": ["boolean", "null"],
- },
- "replicate_network_connection_state": {
- "description": "Replicate the network connection state for links in Qemu",
- "type": ["boolean", "null"],
- },
- "create_config_disk": {
- "description": "Automatically create a config disk on HDD disk interface (secondary slave)",
- "type": ["boolean", "null"],
- },
- "on_close": {
- "description": "Action to execute on the VM is closed",
- "enum": ["power_off", "shutdown_signal", "save_vm_state"],
- },
- "cpu_throttling": {
- "description": "Percentage of CPU allowed for QEMU",
- "minimum": 0,
- "maximum": 800,
- "type": ["integer", "null"],
- },
- "process_priority": {
- "description": "Process priority for QEMU",
- "enum": ["realtime",
- "very high",
- "high",
- "normal",
- "low",
- "very low",
- "null"]
- },
- "options": {
- "description": "Additional QEMU options",
- "type": ["string", "null"],
- },
- "custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA
- },
- "additionalProperties": False,
-}
-
-QEMU_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation for a QEMU VM instance",
- "type": "object",
- "properties": {
- "node_id": {
- "description": "Node UUID",
- "type": "string",
- "minLength": 1,
- },
- "project_id": {
- "description": "Project UUID",
- "type": "string",
- "minLength": 1,
- },
- "name": {
- "description": "QEMU VM instance name",
- "type": "string",
- "minLength": 1,
- },
- "status": {
- "description": "VM status",
- "enum": ["started", "stopped", "suspended"]
- },
- "usage": {
- "description": "How to use the QEMU VM",
- "type": "string",
- },
- "qemu_path": {
- "description": "Path to QEMU",
- "type": "string",
- "minLength": 1,
- },
- "platform": {
- "description": "Platform to emulate",
- "enum": QEMU_PLATFORMS
- },
- "hda_disk_image": {
- "description": "QEMU hda disk image path",
- "type": "string",
- },
- "hda_disk_interface": {
- "description": "QEMU hda interface",
- "type": "string",
- },
- "hda_disk_image_md5sum": {
- "description": "QEMU hda disk image checksum",
- "type": ["string", "null"]
- },
- "hdb_disk_image": {
- "description": "QEMU hdb disk image path",
- "type": "string",
- },
- "hdb_disk_interface": {
- "description": "QEMU hdb interface",
- "type": "string",
- },
- "hdb_disk_image_md5sum": {
- "description": "QEMU hdb disk image checksum",
- "type": ["string", "null"],
- },
- "hdc_disk_image": {
- "description": "QEMU hdc disk image path",
- "type": "string",
- },
- "hdc_disk_interface": {
- "description": "QEMU hdc interface",
- "type": "string",
- },
- "hdc_disk_image_md5sum": {
- "description": "QEMU hdc disk image checksum",
- "type": ["string", "null"],
- },
- "hdd_disk_image": {
- "description": "QEMU hdd disk image path",
- "type": "string",
- },
- "hdd_disk_interface": {
- "description": "QEMU hdd interface",
- "type": "string",
- },
- "hdd_disk_image_md5sum": {
- "description": "QEMU hdd disk image checksum",
- "type": ["string", "null"],
- },
- "bios_image": {
- "description": "QEMU bios image path",
- "type": "string",
- },
- "bios_image_md5sum": {
- "description": "QEMU bios image checksum",
- "type": ["string", "null"],
- },
- "cdrom_image": {
- "description": "QEMU cdrom image path",
- "type": "string",
- },
- "cdrom_image_md5sum": {
- "description": "QEMU cdrom image checksum",
- "type": ["string", "null"],
- },
- "boot_priority": {
- "description": "QEMU boot priority",
- "enum": ["c", "d", "n", "cn", "cd", "dn", "dc", "nc", "nd"]
- },
- "node_directory": {
- "description": "Path to the VM working directory",
- "type": "string"
- },
- "ram": {
- "description": "Amount of RAM in MB",
- "type": "integer"
- },
- "cpus": {
- "description": "Number of vCPUs",
- "type": ["integer", "null"],
- "minimum": 1,
- "maximum": 255,
- },
- "maxcpus": {
- "description": "Maximum number of hotpluggable vCPUs",
- "type": ["integer", "null"],
- "minimum": 1,
- "maximum": 255,
- },
- "adapters": {
- "description": "Number of adapters",
- "type": "integer",
- "minimum": 0,
- "maximum": 275,
- },
- "adapter_type": {
- "description": "QEMU adapter type",
- "type": "string",
- "minLength": 1,
- },
- "mac_address": {
- "description": "QEMU MAC address",
- "type": "string",
- "minLength": 1,
- "pattern": "^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$"
- },
- "console": {
- "description": "Console TCP port",
- "minimum": 1,
- "maximum": 65535,
- "type": ["integer", "null"]
- },
- "console_type": {
- "description": "Console type",
- "enum": ["telnet", "vnc", "spice","spice+agent", "none"]
- },
- "aux": {
- "description": "Auxiliary TCP port",
- "minimum": 1,
- "maximum": 65535,
- "type": ["integer", "null"]
- },
- "aux_type": {
- "description": "Auxiliary console type",
- "enum": ["telnet", "vnc", "spice", "spice+agent", "none"]
- },
- "initrd": {
- "description": "QEMU initrd path",
- "type": "string",
- },
- "initrd_md5sum": {
- "description": "QEMU initrd path",
- "type": ["string", "null"],
- },
- "kernel_image": {
- "description": "QEMU kernel image path",
- "type": "string",
- },
- "kernel_image_md5sum": {
- "description": "QEMU kernel image checksum",
- "type": ["string", "null"],
- },
- "kernel_command_line": {
- "description": "QEMU kernel command line",
- "type": "string",
- },
- "legacy_networking": {
- "description": "Use QEMU legagy networking commands (-net syntax)",
- "type": "boolean",
- },
- "replicate_network_connection_state": {
- "description": "Replicate the network connection state for links in Qemu",
- "type": "boolean",
- },
- "create_config_disk": {
- "description": "Automatically create a config disk on HDD disk interface (secondary slave)",
- "type": ["boolean", "null"],
- },
- "on_close": {
- "description": "Action to execute on the VM is closed",
- "enum": ["power_off", "shutdown_signal", "save_vm_state"],
- },
- "save_vm_state": {
- "description": "Save VM state support",
- "type": ["boolean", "null"],
- },
- "cpu_throttling": {
- "description": "Percentage of CPU allowed for QEMU",
- "minimum": 0,
- "maximum": 800,
- "type": "integer",
- },
- "process_priority": {
- "description": "Process priority for QEMU",
- "enum": ["realtime",
- "very high",
- "high",
- "normal",
- "low",
- "very low"]
- },
- "options": {
- "description": "Additional QEMU options",
- "type": "string",
- },
- "command_line": {
- "description": "Last command line used by GNS3 to start QEMU",
- "type": "string"
- }
- },
- "additionalProperties": False,
- "required": ["node_id",
- "project_id",
- "name",
- "usage",
- "qemu_path",
- "platform",
- "console_type",
- "aux_type",
- "hda_disk_image",
- "hdb_disk_image",
- "hdc_disk_image",
- "hdd_disk_image",
- "hda_disk_image_md5sum",
- "hdb_disk_image_md5sum",
- "hdc_disk_image_md5sum",
- "hdd_disk_image_md5sum",
- "hda_disk_interface",
- "hdb_disk_interface",
- "hdc_disk_interface",
- "hdd_disk_interface",
- "cdrom_image",
- "cdrom_image_md5sum",
- "bios_image",
- "bios_image_md5sum",
- "boot_priority",
- "ram",
- "cpus",
- "maxcpus",
- "adapters",
- "adapter_type",
- "mac_address",
- "console",
- "aux",
- "initrd",
- "kernel_image",
- "initrd_md5sum",
- "kernel_image_md5sum",
- "kernel_command_line",
- "legacy_networking",
- "replicate_network_connection_state",
- "create_config_disk",
- "on_close",
- "cpu_throttling",
- "process_priority",
- "options",
- "node_directory",
- "command_line",
- "status"]
-}
-
-QEMU_RESIZE_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Resize a disk in a QEMU VM",
- "type": "object",
- "properties": {
- "drive_name": {
- "description": "Absolute or relative path of the image",
- "enum": ["hda", "hdb", "hdc", "hdd"]
- },
- "extend": {
- "description": "Number of Megabytes to extend the image",
- "type": "integer"
- },
- # TODO: support shrink? (could be dangerous)
- },
- "required": ["drive_name", "extend"],
- "additionalProperties": False
-}
-
-QEMU_BINARY_FILTER_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation for a list of QEMU capabilities",
- "properties": {
- "archs": {
- "description": "Architectures to filter binaries with",
- "type": "array",
- "items": {
- "enum": QEMU_PLATFORMS
- }
- }
- },
- "additionalProperties": False,
-}
-
-QEMU_BINARY_LIST_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation for a list of QEMU binaries",
- "type": "array",
- "items": {
- "$ref": "#/definitions/QemuPath"
- },
- "definitions": {
- "QemuPath": {
- "description": "Qemu path object",
- "properties": {
- "path": {
- "description": "Qemu path",
- "type": "string",
- },
- "version": {
- "description": "Qemu version",
- "type": "string",
- },
- },
- }
- },
- "additionalProperties": False,
-}
-
-QEMU_CAPABILITY_LIST_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation for a list of QEMU capabilities",
- "properties": {
- "kvm": {
- "description": "Architectures that KVM is enabled for",
- "type": "array",
- "items": {
- "enum": QEMU_PLATFORMS
- }
- }
- },
- "additionalProperties": False,
-}
-
-QEMU_IMAGE_CREATE_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Create a new QEMU image. Options can be specific to a format. Read qemu-img manual for more information",
- "type": "object",
- "properties": {
- "qemu_img": {
- "description": "Path to the qemu-img binary",
- "type": "string"
- },
- "path": {
- "description": "Absolute or relative path of the image",
- "type": "string"
- },
- "format": {
- "description": "Image format type",
- "enum": ["qcow2", "qcow", "vpc", "vdi", "vmdk", "raw"]
- },
- "size": {
- "description": "Image size in Megabytes",
- "type": "integer"
- },
- "preallocation": {
- "enum": ["off", "metadata", "falloc", "full"]
- },
- "cluster_size": {
- "type": "integer"
- },
- "refcount_bits": {
- "type": "integer"
- },
- "lazy_refcounts": {
- "enum": ["on", "off"]
- },
- "subformat": {
- "enum": [
- "dynamic",
- "fixed",
- "streamOptimized",
- "twoGbMaxExtentSparse",
- "twoGbMaxExtentFlat",
- "monolithicSparse",
- "monolithicFlat",
- ]
- },
- "static": {
- "enum": ["on", "off"]
- },
- "zeroed_grain": {
- "enum": ["on", "off"]
- },
- "adapter_type": {
- "enum": [
- "ide",
- "lsilogic",
- "buslogic",
- "legacyESX"
- ]
- }
- },
- "required": ["qemu_img", "path", "format", "size"],
- "additionalProperties": False
-}
-
-QEMU_IMAGE_UPDATE_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Update an existing QEMU image",
- "type": "object",
- "properties": {
- "qemu_img": {
- "description": "Path to the qemu-img binary",
- "type": "string"
- },
- "path": {
- "description": "Absolute or relative path of the image",
- "type": "string"
- },
- "extend": {
- "description": "Number of Megabytes to extend the image",
- "type": "integer"
- },
- },
- "required": ["qemu_img", "path"],
- "additionalProperties": False
-}
diff --git a/gns3server/endpoints/schemas/qemu_nodes.py b/gns3server/schemas/qemu_nodes.py
similarity index 100%
rename from gns3server/endpoints/schemas/qemu_nodes.py
rename to gns3server/schemas/qemu_nodes.py
diff --git a/gns3server/schemas/qemu_template.py b/gns3server/schemas/qemu_template.py
deleted file mode 100644
index 213c6e9e..00000000
--- a/gns3server/schemas/qemu_template.py
+++ /dev/null
@@ -1,234 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2016 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 .
-
-import copy
-from .template import BASE_TEMPLATE_PROPERTIES
-from .custom_adapters import CUSTOM_ADAPTERS_ARRAY_SCHEMA
-from .qemu import QEMU_PLATFORMS
-
-
-QEMU_TEMPLATE_PROPERTIES = {
- "qemu_path": {
- "description": "Path to QEMU",
- "type": "string",
- "default": ""
- },
- "platform": {
- "description": "Platform to emulate",
- "enum": QEMU_PLATFORMS,
- "default": "i386"
- },
- "linked_clone": {
- "description": "Whether the VM is a linked clone or not",
- "type": "boolean",
- "default": True
- },
- "ram": {
- "description": "Amount of RAM in MB",
- "type": "integer",
- "default": 256
- },
- "cpus": {
- "description": "Number of vCPUs",
- "type": "integer",
- "minimum": 1,
- "maximum": 255,
- "default": 1
- },
- "maxcpus": {
- "description": "Maximum number of hotpluggable vCPUs",
- "type": "integer",
- "minimum": 1,
- "maximum": 255,
- "default": 1
- },
- "adapters": {
- "description": "Number of adapters",
- "type": "integer",
- "minimum": 0,
- "maximum": 275,
- "default": 1
- },
- "adapter_type": {
- "description": "QEMU adapter type",
- "type": "string",
- "enum": ["e1000", "e1000-82544gc", "e1000-82545em", "e1000e", "i82550", "i82551", "i82557a", "i82557b", "i82557c", "i82558a",
- "i82558b", "i82559a", "i82559b", "i82559c", "i82559er", "i82562", "i82801", "ne2k_pci", "pcnet", "rocker", "rtl8139",
- "virtio", "virtio-net-pci", "vmxnet3"],
- "default": "e1000"
- },
- "mac_address": {
- "description": "QEMU MAC address",
- "type": ["string", "null"],
- "anyOf": [
- {"pattern": "^([0-9a-fA-F]{2}[:]){5}([0-9a-fA-F]{2})$"},
- {"pattern": "^$"}
- ],
- "default": "",
- },
- "first_port_name": {
- "description": "Optional name of the first networking port example: eth0",
- "type": "string",
- "default": ""
- },
- "port_name_format": {
- "description": "Optional formatting of the networking port example: eth{0}",
- "type": "string",
- "default": "Ethernet{0}"
- },
- "port_segment_size": {
- "description": "Optional port segment size. A port segment is a block of port. For example Ethernet0/0 Ethernet0/1 is the module 0 with a port segment size of 2",
- "type": "integer",
- "default": 0
- },
- "console_type": {
- "description": "Console type",
- "enum": ["telnet", "vnc", "spice", "spice+agent", "none"],
- "default": "telnet"
- },
- "console_auto_start": {
- "description": "Automatically start the console when the node has started",
- "type": "boolean",
- "default": False
- },
- "aux_type": {
- "description": "Auxiliary console type",
- "enum": ["telnet", "vnc", "spice", "spice+agent", "none"],
- "default": "none"
- },
- "boot_priority": {
- "description": "QEMU boot priority",
- "enum": ["c", "d", "n", "cn", "cd", "dn", "dc", "nc", "nd"],
- "default": "c"
- },
- "hda_disk_image": {
- "description": "QEMU hda disk image path",
- "type": "string",
- "default": ""
- },
- "hda_disk_interface": {
- "description": "QEMU hda interface",
- "enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"],
- "default": "none"
- },
- "hdb_disk_image": {
- "description": "QEMU hdb disk image path",
- "type": "string",
- "default": ""
- },
- "hdb_disk_interface": {
- "description": "QEMU hdb interface",
- "enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"],
- "default": "none"
- },
- "hdc_disk_image": {
- "description": "QEMU hdc disk image path",
- "type": "string",
- "default": ""
- },
- "hdc_disk_interface": {
- "description": "QEMU hdc interface",
- "enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"],
- "default": "none"
- },
- "hdd_disk_image": {
- "description": "QEMU hdd disk image path",
- "type": "string",
- "default": ""
- },
- "hdd_disk_interface": {
- "description": "QEMU hdd interface",
- "enum": ["ide", "sata", "nvme", "scsi", "sd", "mtd", "floppy", "pflash", "virtio", "none"],
- "default": "none"
- },
- "cdrom_image": {
- "description": "QEMU cdrom image path",
- "type": "string",
- "default": ""
- },
- "initrd": {
- "description": "QEMU initrd path",
- "type": "string",
- "default": ""
- },
- "kernel_image": {
- "description": "QEMU kernel image path",
- "type": "string",
- "default": ""
- },
- "bios_image": {
- "description": "QEMU bios image path",
- "type": "string",
- "default": ""
- },
- "kernel_command_line": {
- "description": "QEMU kernel command line",
- "type": "string",
- "default": ""
- },
- "legacy_networking": {
- "description": "Use QEMU legagy networking commands (-net syntax)",
- "type": "boolean",
- "default": False
- },
- "replicate_network_connection_state": {
- "description": "Replicate the network connection state for links in Qemu",
- "type": "boolean",
- "default": True
- },
- "create_config_disk": {
- "description": "Automatically create a config disk on HDD disk interface (secondary slave)",
- "type": "boolean",
- "default": False
- },
- "on_close": {
- "description": "Action to execute on the VM is closed",
- "enum": ["power_off", "shutdown_signal", "save_vm_state"],
- "default": "power_off"
- },
- "cpu_throttling": {
- "description": "Percentage of CPU allowed for QEMU",
- "minimum": 0,
- "maximum": 800,
- "type": "integer",
- "default": 0
- },
- "process_priority": {
- "description": "Process priority for QEMU",
- "enum": ["realtime", "very high", "high", "normal", "low", "very low"],
- "default": "normal"
- },
- "options": {
- "description": "Additional QEMU options",
- "type": "string",
- "default": ""
- },
- "custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA
-}
-
-QEMU_TEMPLATE_PROPERTIES.update(copy.deepcopy(BASE_TEMPLATE_PROPERTIES))
-QEMU_TEMPLATE_PROPERTIES["category"]["default"] = "guest"
-QEMU_TEMPLATE_PROPERTIES["default_name_format"]["default"] = "{name}-{0}"
-QEMU_TEMPLATE_PROPERTIES["symbol"]["default"] = ":/symbols/qemu_guest.svg"
-
-QEMU_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A Qemu template object",
- "type": "object",
- "properties": QEMU_TEMPLATE_PROPERTIES,
- "additionalProperties": False
-}
diff --git a/gns3server/controller/schemas/qemu_templates.py b/gns3server/schemas/qemu_templates.py
similarity index 97%
rename from gns3server/controller/schemas/qemu_templates.py
rename to gns3server/schemas/qemu_templates.py
index a4f7a28f..636983bd 100644
--- a/gns3server/controller/schemas/qemu_templates.py
+++ b/gns3server/schemas/qemu_templates.py
@@ -16,8 +16,8 @@
# along with this program. If not, see .
-from gns3server.endpoints.schemas.templates import Category, TemplateBase
-from gns3server.endpoints.schemas.qemu_nodes import (
+from .templates import Category, TemplateBase
+from .qemu_nodes import (
QemuConsoleType,
QemuPlatform,
QemuAdapterType,
diff --git a/gns3server/schemas/server_statistics.py b/gns3server/schemas/server_statistics.py
deleted file mode 100644
index 048799b3..00000000
--- a/gns3server/schemas/server_statistics.py
+++ /dev/null
@@ -1,82 +0,0 @@
-# -*- 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 .
-
-SERVER_STATISTICS_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "type": "object",
- "required": ["memory_total",
- "memory_free",
- "memory_used",
- "swap_total",
- "swap_free",
- "swap_used",
- "cpu_usage_percent",
- "memory_usage_percent",
- "swap_usage_percent",
- "disk_usage_percent",
- "load_average_percent"],
- "additionalProperties": False,
- "properties": {
- "memory_total": {
- "description": "Total physical memory (exclusive swap) in bytes",
- "type": "integer",
- },
- "memory_free": {
- "description": "Free memory in bytes",
- "type": "integer",
- },
- "memory_used": {
- "description": "Memory used in bytes",
- "type": "integer",
- },
- "swap_total": {
- "description": "Total swap memory in bytes",
- "type": "integer",
- },
- "swap_free": {
- "description": "Free swap memory in bytes",
- "type": "integer",
- },
- "swap_used": {
- "description": "Swap memory used in bytes",
- "type": "integer",
- },
- "cpu_usage_percent": {
- "description": "CPU usage in percent",
- "type": "integer",
- },
- "memory_usage_percent": {
- "description": "Memory usage in percent",
- "type": "integer",
- },
- "swap_usage_percent": {
- "description": "Swap usage in percent",
- "type": "integer",
- },
- "disk_usage_percent": {
- "description": "Disk usage in percent",
- "type": "integer",
- },
- "load_average_percent": {
- "description": "Average system load over the last 1, 5 and 15 minutes",
- "type": "array",
- "items": [{"type": "integer"}],
- "minItems": 3,
- "maxItems": 3
- },
- }
-}
diff --git a/gns3server/schemas/snapshot.py b/gns3server/schemas/snapshot.py
deleted file mode 100644
index 1c306cd2..00000000
--- a/gns3server/schemas/snapshot.py
+++ /dev/null
@@ -1,64 +0,0 @@
-# -*- 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 .
-
-
-SNAPSHOT_CREATE_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to create a new snapshot",
- "type": "object",
- "properties": {
- "name": {
- "description": "Snapshot name",
- "minLength": 1
- },
- },
- "additionalProperties": False,
- "required": ["name"]
-}
-
-SNAPSHOT_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to update a Project instance",
- "type": "object",
- "properties": {
- "snapshot_id": {
- "description": "Snapshot 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}$"
- },
- "project_id": {
- "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}$"
- },
- "name": {
- "description": "Project name",
- "type": "string",
- "minLength": 1
- },
- "created_at": {
- "description": "Date of the snapshot (UTC timestamp)",
- "type": "integer"
- }
- },
- "additionalProperties": False,
- "required": ["snapshot_id", "name", "created_at", "project_id"]
-}
diff --git a/gns3server/endpoints/schemas/snapshots.py b/gns3server/schemas/snapshots.py
similarity index 100%
rename from gns3server/endpoints/schemas/snapshots.py
rename to gns3server/schemas/snapshots.py
diff --git a/gns3server/schemas/template.py b/gns3server/schemas/template.py
deleted file mode 100644
index 17d3c3d9..00000000
--- a/gns3server/schemas/template.py
+++ /dev/null
@@ -1,116 +0,0 @@
-# -*- 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 .
-
-import copy
-
-BASE_TEMPLATE_PROPERTIES = {
- "template_id": {
- "description": "Template 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}$"
- },
- "template_type": {
- "description": "Type of node",
- "enum": ["cloud", "ethernet_hub", "ethernet_switch", "docker", "dynamips", "vpcs", "traceng",
- "virtualbox", "vmware", "iou", "qemu"]
- },
- "name": {
- "description": "Template name",
- "type": "string",
- "minLength": 1,
- },
- "usage": {
- "description": "How to use this template",
- "type": "string",
- "default": ""
- },
- "compute_id": {
- "description": "Compute identifier",
- "type": ["null", "string"]
- },
- "default_name_format": {
- "description": "Default name format",
- "type": "string",
- "minLength": 1
- },
- "symbol": {
- "description": "Symbol of the template",
- "type": "string",
- "minLength": 1
- },
- "category": {
- "description": "Template category",
- "anyOf": [
- {"type": "integer"}, # old category support
- {"enum": ["router", "switch", "guest", "firewall"]}
- ]
- },
- "builtin": {
- "description": "Template is builtin",
- "type": "boolean"
- },
-}
-
-TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A template object",
- "type": "object",
- "properties": BASE_TEMPLATE_PROPERTIES,
- "required": ["name", "template_type", "template_id", "category", "compute_id", "default_name_format", "symbol", "builtin"]
-}
-
-TEMPLATE_CREATE_SCHEMA = copy.deepcopy(TEMPLATE_OBJECT_SCHEMA)
-
-# create schema
-# these properties are not required to create a template
-TEMPLATE_CREATE_SCHEMA["required"].remove("template_id")
-TEMPLATE_CREATE_SCHEMA["required"].remove("category")
-TEMPLATE_CREATE_SCHEMA["required"].remove("default_name_format")
-TEMPLATE_CREATE_SCHEMA["required"].remove("symbol")
-TEMPLATE_CREATE_SCHEMA["required"].remove("builtin")
-
-# update schema
-TEMPLATE_UPDATE_SCHEMA = copy.deepcopy(TEMPLATE_OBJECT_SCHEMA)
-del TEMPLATE_UPDATE_SCHEMA["required"]
-
-TEMPLATE_USAGE_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "Request validation to use a Template instance",
- "type": "object",
- "properties": {
- "x": {
- "description": "X position",
- "type": "integer"
- },
- "y": {
- "description": "Y position",
- "type": "integer"
- },
- "name": {
- "description": "Use this name to create a new node",
- "type": ["null", "string"]
- },
- "compute_id": {
- "description": "If the template don't have a default compute use this compute",
- "type": ["null", "string"]
- }
- },
- "additionalProperties": False,
- "required": ["x", "y"]
-}
diff --git a/gns3server/endpoints/schemas/templates.py b/gns3server/schemas/templates.py
similarity index 100%
rename from gns3server/endpoints/schemas/templates.py
rename to gns3server/schemas/templates.py
diff --git a/gns3server/schemas/topology.py b/gns3server/schemas/topology.py
index 21d5e6da..9cf882dc 100644
--- a/gns3server/schemas/topology.py
+++ b/gns3server/schemas/topology.py
@@ -19,136 +19,66 @@
# This file contains the validation for checking a .gns3 file
#
-from gns3server.schemas.compute import COMPUTE_OBJECT_SCHEMA
-from gns3server.schemas.drawing import DRAWING_OBJECT_SCHEMA
-from gns3server.schemas.link import LINK_OBJECT_SCHEMA
-from gns3server.schemas.node import NODE_OBJECT_SCHEMA
-from gns3server.schemas.project import VARIABLES_OBJECT_SCHEMA
-from gns3server.schemas.project import SUPPLIER_OBJECT_SCHEMA
+from .computes import Compute
+from .drawings import Drawing
+from .links import Link
+from .nodes import Node
+
+from .projects import (
+ Supplier,
+ Variable
+)
+
+from pydantic import BaseModel, Field
+from typing import Optional, List
+from enum import Enum
+from uuid import UUID
-TOPOLOGY_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "The topology",
- "type": "object",
- "properties": {
- "project_id": {
- "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}$"
- },
- "type": {
- "description": "Type of file. It's always topology",
- "enum": ["topology"]
- },
- "auto_start": {
- "description": "Start the topology when opened",
- "type": "boolean"
- },
- "auto_close": {
- "description": "Close the topology when no client is connected",
- "type": "boolean"
- },
- "auto_open": {
- "description": "Open the topology with GNS3",
- "type": "boolean"
- },
- "revision": {
- "description": "Version of the .gns3 specification.",
- "type": "integer"
- },
- "version": {
- "description": "Version of the GNS3 software which have update the file for the last time",
- "type": "string"
- },
- "name": {
- "type": "string",
- "description": "Name of the project"
- },
- "scene_height": {
- "type": "integer",
- "description": "Height of the drawing area"
- },
- "scene_width": {
- "type": "integer",
- "description": "Width of the drawing area"
- },
- "zoom": {
- "type": "integer",
- "description": "Zoom of the drawing area"
- },
- "show_layers": {
- "type": "boolean",
- "description": "Show layers on the drawing area"
- },
- "snap_to_grid": {
- "type": "boolean",
- "description": "Snap to grid on the drawing area"
- },
- "show_grid": {
- "type": "boolean",
- "description": "Show the grid on the drawing area"
- },
- "grid_size": {
- "type": "integer",
- "description": "Grid size for the drawing area for nodes"
- },
- "drawing_grid_size": {
- "type": "integer",
- "description": "Grid size for the drawing area for drawings"
- },
- "show_interface_labels": {
- "type": "boolean",
- "description": "Show interface labels on the drawing area"
- },
- "supplier": SUPPLIER_OBJECT_SCHEMA,
- "variables": VARIABLES_OBJECT_SCHEMA,
- "topology": {
- "description": "The topology content",
- "type": "object",
- "properties": {
- "computes": {
- "description": "Computes servers",
- "type": "array",
- "items": COMPUTE_OBJECT_SCHEMA
- },
- "drawings": {
- "description": "Drawings elements",
- "type": "array",
- "items": DRAWING_OBJECT_SCHEMA
- },
- "links": {
- "description": "Link elements",
- "type": "array",
- "items": LINK_OBJECT_SCHEMA
- },
- "nodes": {
- "description": "Nodes elements",
- "type": "array",
- "items": NODE_OBJECT_SCHEMA
- }
- },
- "required": ["nodes", "links", "drawings", "computes"],
- "additionalProperties": False
- }
- },
- "required": [
- "project_id", "type", "revision", "version", "name", "topology"
- ],
- "additionalProperties": False
-}
+class TopologyType(str, Enum):
+
+ topology = "topology"
+
+
+class TopologyContent(BaseModel):
+
+ computes: List[Compute] = Field(..., description="List of computes")
+ drawings: List[Drawing] = Field(..., description="List of drawings")
+ links: List[Link] = Field(..., description="List of links")
+ nodes: List[Node] = Field(..., description="List of nodes")
+
+
+class Topology(BaseModel):
+
+ project_id: UUID = Field(..., description="Project UUID")
+ type: TopologyType = Field(..., description="Type of file. It's always topology")
+ revision: int = Field(..., description="Version of the .gns3 specification")
+ version: str = Field(..., description="Version of the GNS3 software which have update the file for the last time")
+ name: str = Field(..., description="Name of the project")
+ topology: TopologyContent = Field(..., description="Topology content")
+ auto_start: Optional[bool] = Field(None, description="Start the topology when opened")
+ auto_close: Optional[bool] = Field(None, description="Close the topology when no client is connected")
+ scene_height: Optional[int] = Field(None, description="Height of the drawing area")
+ scene_width: Optional[int] = Field(None, description="Width of the drawing area")
+ zoom: Optional[int] = Field(None, description="Zoom of the drawing area")
+ show_layers: Optional[bool] = Field(None, description="Show layers on the drawing area")
+ snap_to_grid: Optional[bool] = Field(None, description="Snap to grid on the drawing area")
+ show_grid: Optional[bool] = Field(None, description="Show the grid on the drawing area")
+ grid_size: Optional[int] = Field(None, description="Grid size for the drawing area for nodes")
+ drawing_grid_size: Optional[int] = Field(None, description="Grid size for the drawing area for drawings")
+ show_interface_labels: Optional[bool] = Field(None, description="Show interface labels on the drawing area")
+ supplier: Optional[Supplier] = Field(None, description="Supplier of the project")
+ variables: Optional[List[Variable]] = Field(None, description="Variables required to run the project")
def main():
- import jsonschema
+
import json
import sys
with open(sys.argv[1]) as f:
data = json.load(f)
- jsonschema.validate(data, TOPOLOGY_SCHEMA)
+ Topology.parse_obj(data)
if __name__ == '__main__':
diff --git a/gns3server/schemas/traceng_template.py b/gns3server/schemas/traceng_template.py
deleted file mode 100644
index 5c574685..00000000
--- a/gns3server/schemas/traceng_template.py
+++ /dev/null
@@ -1,51 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2016 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 .
-
-import copy
-from .template import BASE_TEMPLATE_PROPERTIES
-
-
-TRACENG_TEMPLATE_PROPERTIES = {
- "ip_address": {
- "description": "Source IP address for tracing",
- "type": ["string"],
- "minLength": 1
- },
- "default_destination": {
- "description": "Default destination IP address or hostname for tracing",
- "type": ["string"],
- "minLength": 1
- },
- "console_type": {
- "description": "Console type",
- "enum": ["none"],
- "default": "none"
- },
-}
-
-TRACENG_TEMPLATE_PROPERTIES.update(copy.deepcopy(BASE_TEMPLATE_PROPERTIES))
-TRACENG_TEMPLATE_PROPERTIES["category"]["default"] = "guest"
-TRACENG_TEMPLATE_PROPERTIES["default_name_format"]["default"] = "TraceNG{0}"
-TRACENG_TEMPLATE_PROPERTIES["symbol"]["default"] = ":/symbols/traceng.svg"
-
-TRACENG_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A TraceNG template object",
- "type": "object",
- "properties": TRACENG_TEMPLATE_PROPERTIES,
- "additionalProperties": False
-}
diff --git a/gns3server/schemas/version.py b/gns3server/schemas/version.py
index ac739dd5..cb92d953 100644
--- a/gns3server/schemas/version.py
+++ b/gns3server/schemas/version.py
@@ -15,19 +15,11 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-VERSION_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "type": "object",
- 'required': ['version'],
- "additionalProperties": False,
- "properties": {
- "version": {
- "description": "Version number",
- "type": "string",
- },
- "local": {
- "description": "Whether this is a local server or not",
- "type": "boolean",
- }
- }
-}
+from pydantic import BaseModel, Field
+from typing import Optional
+
+
+class Version(BaseModel):
+
+ version: str = Field(..., description="Version number")
+ local: Optional[bool] = Field(None, description="Whether this is a local server or not")
diff --git a/gns3server/endpoints/schemas/virtualbox_nodes.py b/gns3server/schemas/virtualbox_nodes.py
similarity index 100%
rename from gns3server/endpoints/schemas/virtualbox_nodes.py
rename to gns3server/schemas/virtualbox_nodes.py
diff --git a/gns3server/schemas/virtualbox_template.py b/gns3server/schemas/virtualbox_template.py
deleted file mode 100644
index 36ff47c2..00000000
--- a/gns3server/schemas/virtualbox_template.py
+++ /dev/null
@@ -1,113 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2016 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 .
-
-import copy
-from .template import BASE_TEMPLATE_PROPERTIES
-from .custom_adapters import CUSTOM_ADAPTERS_ARRAY_SCHEMA
-
-
-VIRTUALBOX_TEMPLATE_PROPERTIES = {
- "vmname": {
- "description": "VirtualBox VM name (in VirtualBox itself)",
- "type": "string",
- "minLength": 1,
- },
- "ram": {
- "description": "Amount of RAM",
- "minimum": 0,
- "maximum": 65535,
- "type": "integer",
- "default": 256
- },
- "linked_clone": {
- "description": "Whether the VM is a linked clone or not",
- "type": "boolean",
- "default": False
- },
- "adapters": {
- "description": "Number of adapters",
- "type": "integer",
- "minimum": 0,
- "maximum": 36, # maximum given by the ICH9 chipset in VirtualBox
- "default": 1
- },
- "use_any_adapter": {
- "description": "Allow GNS3 to use any VirtualBox adapter",
- "type": "boolean",
- "default": False
- },
- "adapter_type": {
- "description": "VirtualBox adapter type",
- "enum": ["PCnet-PCI II (Am79C970A)",
- "PCNet-FAST III (Am79C973)",
- "Intel PRO/1000 MT Desktop (82540EM)",
- "Intel PRO/1000 T Server (82543GC)",
- "Intel PRO/1000 MT Server (82545EM)",
- "Paravirtualized Network (virtio-net)"],
- "default": "Intel PRO/1000 MT Desktop (82540EM)"
- },
- "first_port_name": {
- "description": "Optional name of the first networking port example: eth0",
- "type": "string",
- "default": ""
- },
- "port_name_format": {
- "description": "Optional formatting of the networking port example: eth{0}",
- "type": "string",
- "default": "Ethernet{0}"
- },
- "port_segment_size": {
- "description": "Optional port segment size. A port segment is a block of port. For example Ethernet0/0 Ethernet0/1 is the module 0 with a port segment size of 2",
- "type": "integer",
- "default": 0
- },
- "headless": {
- "description": "Headless mode",
- "type": "boolean",
- "default": False
- },
- "on_close": {
- "description": "Action to execute on the VM is closed",
- "enum": ["power_off", "shutdown_signal", "save_vm_state"],
- "default": "power_off"
- },
- "console_type": {
- "description": "Console type",
- "enum": ["telnet", "none"],
- "default": "none"
- },
- "console_auto_start": {
- "description": "Automatically start the console when the node has started",
- "type": "boolean",
- "default": False
- },
- "custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA
-}
-
-VIRTUALBOX_TEMPLATE_PROPERTIES.update(copy.deepcopy(BASE_TEMPLATE_PROPERTIES))
-VIRTUALBOX_TEMPLATE_PROPERTIES["category"]["default"] = "guest"
-VIRTUALBOX_TEMPLATE_PROPERTIES["default_name_format"]["default"] = "{name}-{0}"
-VIRTUALBOX_TEMPLATE_PROPERTIES["symbol"]["default"] = ":/symbols/vbox_guest.svg"
-
-VIRTUALBOX_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A VirtualBox template object",
- "type": "object",
- "properties": VIRTUALBOX_TEMPLATE_PROPERTIES,
- "required": ["vmname"],
- "additionalProperties": False
-}
diff --git a/gns3server/controller/schemas/virtualbox_templates.py b/gns3server/schemas/virtualbox_templates.py
similarity index 95%
rename from gns3server/controller/schemas/virtualbox_templates.py
rename to gns3server/schemas/virtualbox_templates.py
index 3dc911a5..1f0af97e 100644
--- a/gns3server/controller/schemas/virtualbox_templates.py
+++ b/gns3server/schemas/virtualbox_templates.py
@@ -15,8 +15,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-from gns3server.endpoints.schemas.templates import Category, TemplateBase
-from gns3server.endpoints.schemas.virtualbox_nodes import (
+from .templates import Category, TemplateBase
+from .virtualbox_nodes import (
VirtualBoxConsoleType,
VirtualBoxAdapterType,
VirtualBoxOnCloseAction,
diff --git a/gns3server/endpoints/schemas/vmware_nodes.py b/gns3server/schemas/vmware_nodes.py
similarity index 100%
rename from gns3server/endpoints/schemas/vmware_nodes.py
rename to gns3server/schemas/vmware_nodes.py
diff --git a/gns3server/schemas/vmware_template.py b/gns3server/schemas/vmware_template.py
deleted file mode 100644
index c4c6ac88..00000000
--- a/gns3server/schemas/vmware_template.py
+++ /dev/null
@@ -1,101 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2016 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 .
-
-import copy
-from .template import BASE_TEMPLATE_PROPERTIES
-from .custom_adapters import CUSTOM_ADAPTERS_ARRAY_SCHEMA
-
-
-VMWARE_TEMPLATE_PROPERTIES = {
- "vmx_path": {
- "description": "Path to the vmx file",
- "type": "string",
- "minLength": 1,
- },
- "linked_clone": {
- "description": "Whether the VM is a linked clone or not",
- "type": "boolean",
- "default": False
- },
- "first_port_name": {
- "description": "Optional name of the first networking port example: eth0",
- "type": "string",
- "default": ""
- },
- "port_name_format": {
- "description": "Optional formatting of the networking port example: eth{0}",
- "type": "string",
- "default": "Ethernet{0}"
- },
- "port_segment_size": {
- "description": "Optional port segment size. A port segment is a block of port. For example Ethernet0/0 Ethernet0/1 is the module 0 with a port segment size of 2",
- "type": "integer",
- "default": 0
- },
- "adapters": {
- "description": "Number of adapters",
- "type": "integer",
- "minimum": 0,
- "maximum": 10, # maximum adapters support by VMware VMs,
- "default": 1
- },
- "adapter_type": {
- "description": "VMware adapter type",
- "enum": ["default", "e1000", "e1000e", "flexible", "vlance", "vmxnet", "vmxnet2", "vmxnet3"],
- "default": "e1000"
- },
- "use_any_adapter": {
- "description": "Allow GNS3 to use any VMware adapter",
- "type": "boolean",
- "default": False
- },
- "headless": {
- "description": "Headless mode",
- "type": "boolean",
- "default": False
- },
- "on_close": {
- "description": "Action to execute on the VM is closed",
- "enum": ["power_off", "shutdown_signal", "save_vm_state"],
- "default": "power_off"
- },
- "console_type": {
- "description": "Console type",
- "enum": ["telnet", "none"],
- "default": "none"
- },
- "console_auto_start": {
- "description": "Automatically start the console when the node has started",
- "type": "boolean",
- "default": False
- },
- "custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA
-}
-
-VMWARE_TEMPLATE_PROPERTIES.update(copy.deepcopy(BASE_TEMPLATE_PROPERTIES))
-VMWARE_TEMPLATE_PROPERTIES["category"]["default"] = "guest"
-VMWARE_TEMPLATE_PROPERTIES["default_name_format"]["default"] = "{name}-{0}"
-VMWARE_TEMPLATE_PROPERTIES["symbol"]["default"] = ":/symbols/vmware_guest.svg"
-
-VMWARE_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A VMware template object",
- "type": "object",
- "properties": VMWARE_TEMPLATE_PROPERTIES,
- "required": ["vmx_path"],
- "additionalProperties": False
-}
diff --git a/gns3server/controller/schemas/vmware_templates.py b/gns3server/schemas/vmware_templates.py
similarity index 95%
rename from gns3server/controller/schemas/vmware_templates.py
rename to gns3server/schemas/vmware_templates.py
index 867be053..6b85000f 100644
--- a/gns3server/controller/schemas/vmware_templates.py
+++ b/gns3server/schemas/vmware_templates.py
@@ -16,8 +16,8 @@
# along with this program. If not, see .
-from gns3server.endpoints.schemas.templates import Category, TemplateBase
-from gns3server.endpoints.schemas.vmware_nodes import (
+from .templates import Category, TemplateBase
+from .vmware_nodes import (
VMwareConsoleType,
VMwareAdapterType,
VMwareOnCloseAction,
diff --git a/gns3server/endpoints/schemas/vpcs_nodes.py b/gns3server/schemas/vpcs_nodes.py
similarity index 100%
rename from gns3server/endpoints/schemas/vpcs_nodes.py
rename to gns3server/schemas/vpcs_nodes.py
diff --git a/gns3server/schemas/vpcs_template.py b/gns3server/schemas/vpcs_template.py
deleted file mode 100644
index e0726b24..00000000
--- a/gns3server/schemas/vpcs_template.py
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# Copyright (C) 2016 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 .
-
-import copy
-from .template import BASE_TEMPLATE_PROPERTIES
-
-
-VPCS_TEMPLATE_PROPERTIES = {
- "base_script_file": {
- "description": "Script file",
- "type": "string",
- "minLength": 1,
- "default": "vpcs_base_config.txt"
- },
- "console_type": {
- "description": "Console type",
- "enum": ["telnet", "none"],
- "default": "telnet"
- },
- "console_auto_start": {
- "description": "Automatically start the console when the node has started",
- "type": "boolean",
- "default": False
- },
-}
-
-VPCS_TEMPLATE_PROPERTIES.update(copy.deepcopy(BASE_TEMPLATE_PROPERTIES))
-VPCS_TEMPLATE_PROPERTIES["category"]["default"] = "guest"
-VPCS_TEMPLATE_PROPERTIES["default_name_format"]["default"] = "PC{0}"
-VPCS_TEMPLATE_PROPERTIES["symbol"]["default"] = ":/symbols/vpcs_guest.svg"
-
-VPCS_TEMPLATE_OBJECT_SCHEMA = {
- "$schema": "http://json-schema.org/draft-04/schema#",
- "description": "A VPCS template object",
- "type": "object",
- "properties": VPCS_TEMPLATE_PROPERTIES,
- "additionalProperties": False
-}
diff --git a/gns3server/controller/schemas/vpcs_templates.py b/gns3server/schemas/vpcs_templates.py
similarity index 90%
rename from gns3server/controller/schemas/vpcs_templates.py
rename to gns3server/schemas/vpcs_templates.py
index 1adcc69c..ba16f12d 100644
--- a/gns3server/controller/schemas/vpcs_templates.py
+++ b/gns3server/schemas/vpcs_templates.py
@@ -16,8 +16,8 @@
# along with this program. If not, see .
-from gns3server.endpoints.schemas.templates import Category, TemplateBase
-from gns3server.endpoints.schemas.vpcs_nodes import ConsoleType
+from .templates import Category, TemplateBase
+from .vpcs_nodes import ConsoleType
from pydantic import Field
from typing import Optional
diff --git a/requirements.txt b/requirements.txt
index c340cc58..e5be967f 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,7 +1,6 @@
uvicorn==0.11.8
fastapi==0.61.0
python-multipart==0.0.5
-jsonschema==3.2.0
aiohttp==3.6.2
aiofiles==0.5.0
Jinja2>=2.7.3