mirror of
https://github.com/GNS3/gns3-server.git
synced 2026-11-03 05:51:15 +02:00
Use "template" to name what we use to create new nodes.
This commit is contained in:
1 parent
21c0a35f77
commit
d7c2e16c21
262 files changed
+16588
-16863
No files matched your search
@@ -15,7 +15,7 @@
|
||||
"first_port_name": "Management",
|
||||
"port_name_format": "Port{port1}",
|
||||
"qemu": {
|
||||
"adapter_type": "e1000",
|
||||
"adapter_type": "rtl8139",
|
||||
"adapters": 13,
|
||||
"ram": 256,
|
||||
"hda_disk_interface": "ide",
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
"md5sum": "633d6444cad903c707983b54e04fc053",
|
||||
"filesize": 636065792,
|
||||
"download_url": "http://www.freenas.org/download/",
|
||||
"direct_download_url": "https://download.freenas.org/11/11.1-U4/x64/FreeNAS-11.1-U4.iso"
|
||||
"direct_download_url": "https://download.freenas.org/11/11.1-U6/x64/FreeNAS-11.1-U6.iso"
|
||||
},
|
||||
{
|
||||
"filename": "FreeNAS-11.1-U4.iso",
|
||||
|
||||
+104
-106
@@ -28,8 +28,8 @@ import copy
|
||||
|
||||
from ..config import Config
|
||||
from .project import Project
|
||||
from .template import Template
|
||||
from .appliance import Appliance
|
||||
from .appliance_template import ApplianceTemplate
|
||||
from .compute import Compute, ComputeError
|
||||
from .notification import Notification
|
||||
from .symbols import Symbols
|
||||
@@ -59,38 +59,38 @@ class Controller:
|
||||
self._iou_license_settings = {"iourc_content": "",
|
||||
"license_check": True}
|
||||
self._config_loaded = False
|
||||
self._templates = {}
|
||||
self._appliances = {}
|
||||
self._appliance_templates = {}
|
||||
self._appliance_templates_etag = None
|
||||
self._appliances_etag = None
|
||||
|
||||
self._config_file = os.path.join(Config.instance().config_dir, "gns3_controller.conf")
|
||||
log.info("Load controller configuration file {}".format(self._config_file))
|
||||
|
||||
@locking
|
||||
async def download_appliance_templates(self):
|
||||
async def download_appliances(self):
|
||||
|
||||
try:
|
||||
headers = {}
|
||||
if self._appliance_templates_etag:
|
||||
log.info("Checking if appliance templates are up-to-date (ETag {})".format(self._appliance_templates_etag))
|
||||
headers["If-None-Match"] = self._appliance_templates_etag
|
||||
if self._appliances_etag:
|
||||
log.info("Checking if appliances are up-to-date (ETag {})".format(self._appliances_etag))
|
||||
headers["If-None-Match"] = self._appliances_etag
|
||||
async with aiohttp.ClientSession() as session:
|
||||
async with session.get('https://api.github.com/repos/GNS3/gns3-registry/contents/appliances', headers=headers) as response:
|
||||
if response.status == 304:
|
||||
log.info("Appliance templates are already up-to-date (ETag {})".format(self._appliance_templates_etag))
|
||||
log.info("Appliances are already up-to-date (ETag {})".format(self._appliances_etag))
|
||||
return
|
||||
elif response.status != 200:
|
||||
raise aiohttp.web.HTTPConflict(text="Could not retrieve appliance templates on GitHub due to HTTP error code {}".format(response.status))
|
||||
raise aiohttp.web.HTTPConflict(text="Could not retrieve appliances on GitHub due to HTTP error code {}".format(response.status))
|
||||
etag = response.headers.get("ETag")
|
||||
if etag:
|
||||
self._appliance_templates_etag = etag
|
||||
self._appliances_etag = etag
|
||||
self.save()
|
||||
json_data = await response.json()
|
||||
appliances_dir = get_resource('appliances')
|
||||
for appliance in json_data:
|
||||
if appliance["type"] == "file":
|
||||
appliance_name = appliance["name"]
|
||||
log.info("Download appliance template file from '{}'".format(appliance["download_url"]))
|
||||
log.info("Download appliance file from '{}'".format(appliance["download_url"]))
|
||||
async with session.get(appliance["download_url"]) as response:
|
||||
if response.status != 200:
|
||||
log.warning("Could not download '{}' due to HTTP error code {}".format(appliance["download_url"], response.status))
|
||||
@@ -106,13 +106,13 @@ class Controller:
|
||||
with open(path, 'wb') as f:
|
||||
f.write(appliance_data)
|
||||
except OSError as e:
|
||||
raise aiohttp.web.HTTPConflict(text="Could not write appliance template file '{}': {}".format(path, e))
|
||||
raise aiohttp.web.HTTPConflict(text="Could not write appliance file '{}': {}".format(path, e))
|
||||
except ValueError as e:
|
||||
raise aiohttp.web.HTTPConflict(text="Could not read appliance templates information from GitHub: {}".format(e))
|
||||
raise aiohttp.web.HTTPConflict(text="Could not read appliances information from GitHub: {}".format(e))
|
||||
|
||||
def load_appliance_templates(self):
|
||||
def load_appliances(self):
|
||||
|
||||
self._appliance_templates = {}
|
||||
self._appliances = {}
|
||||
for directory, builtin in ((get_resource('appliances'), True,), (self.appliances_path(), False,)):
|
||||
if directory and os.path.isdir(directory):
|
||||
for file in os.listdir(directory):
|
||||
@@ -122,99 +122,97 @@ class Controller:
|
||||
appliance_id = uuid.uuid3(uuid.NAMESPACE_URL, path) # Generate UUID from path to avoid change between reboots
|
||||
try:
|
||||
with open(path, 'r', encoding='utf-8') as f:
|
||||
appliance = ApplianceTemplate(appliance_id, json.load(f), builtin=builtin)
|
||||
appliance = Appliance(appliance_id, json.load(f), builtin=builtin)
|
||||
appliance.__json__() # Check if loaded without error
|
||||
if appliance.status != 'broken':
|
||||
self._appliance_templates[appliance.id] = appliance
|
||||
self._appliances[appliance.id] = appliance
|
||||
except (ValueError, OSError, KeyError) as e:
|
||||
log.warning("Cannot load appliance template file '%s': %s", path, str(e))
|
||||
log.warning("Cannot load appliance file '%s': %s", path, str(e))
|
||||
continue
|
||||
|
||||
def add_appliance(self, settings):
|
||||
def add_template(self, settings):
|
||||
"""
|
||||
Adds a new appliance.
|
||||
Adds a new template.
|
||||
|
||||
:param settings: appliance settings
|
||||
:param settings: template settings
|
||||
|
||||
:returns: Appliance object
|
||||
:returns: Template object
|
||||
"""
|
||||
|
||||
appliance_id = settings.get("appliance_id", "")
|
||||
if appliance_id in self._appliances:
|
||||
raise aiohttp.web.HTTPConflict(text="Appliance ID '{}' already exists".format(appliance_id))
|
||||
template_id = settings.get("template_id", "")
|
||||
if template_id in self._templates:
|
||||
raise aiohttp.web.HTTPConflict(text="Template ID '{}' already exists".format(template_id))
|
||||
else:
|
||||
appliance_id = settings.setdefault("appliance_id", str(uuid.uuid4()))
|
||||
template_id = settings.setdefault("template_id", str(uuid.uuid4()))
|
||||
try:
|
||||
appliance = Appliance(appliance_id, settings)
|
||||
template = Template(template_id, settings)
|
||||
except jsonschema.ValidationError as e:
|
||||
message = "JSON schema error adding appliance with JSON data '{}': {}".format(settings, e.message)
|
||||
message = "JSON schema error adding template with JSON data '{}': {}".format(settings, e.message)
|
||||
raise aiohttp.web.HTTPBadRequest(text=message)
|
||||
self._appliances[appliance.id] = appliance
|
||||
self._templates[template.id] = template
|
||||
self.save()
|
||||
self.notification.controller_emit("appliance.created", appliance.__json__())
|
||||
return appliance
|
||||
self.notification.controller_emit("template.created", template.__json__())
|
||||
return template
|
||||
|
||||
def get_appliance(self, appliance_id):
|
||||
def get_template(self, template_id):
|
||||
"""
|
||||
Gets an appliance.
|
||||
Gets a template.
|
||||
|
||||
:param appliance_id: appliance identifier
|
||||
:param template_id: template identifier
|
||||
|
||||
:returns: Appliance object
|
||||
:returns: Template object
|
||||
"""
|
||||
|
||||
appliance = self._appliances.get(appliance_id)
|
||||
if not appliance:
|
||||
raise aiohttp.web.HTTPNotFound(text="Appliance ID {} doesn't exist".format(appliance_id))
|
||||
return appliance
|
||||
template = self._templates.get(template_id)
|
||||
if not template:
|
||||
raise aiohttp.web.HTTPNotFound(text="Template ID {} doesn't exist".format(template_id))
|
||||
return template
|
||||
|
||||
def delete_appliance(self, appliance_id):
|
||||
def delete_template(self, template_id):
|
||||
"""
|
||||
Deletes an appliance.
|
||||
Deletes a template.
|
||||
|
||||
:param appliance_id: appliance identifier
|
||||
:param template_id: template identifier
|
||||
"""
|
||||
|
||||
appliance = self.get_appliance(appliance_id)
|
||||
if appliance.builtin:
|
||||
raise aiohttp.web.HTTPConflict(text="Appliance ID {} cannot be deleted because it is a builtin".format(appliance_id))
|
||||
self._appliances.pop(appliance_id)
|
||||
template = self.get_template(template_id)
|
||||
if template.builtin:
|
||||
raise aiohttp.web.HTTPConflict(text="Template ID {} cannot be deleted because it is a builtin".format(template_id))
|
||||
self._templates.pop(template_id)
|
||||
self.save()
|
||||
self.notification.controller_emit("appliance.deleted", appliance.__json__())
|
||||
self.notification.controller_emit("template.deleted", template.__json__())
|
||||
|
||||
def duplicate_appliance(self, appliance_id):
|
||||
def duplicate_template(self, template_id):
|
||||
"""
|
||||
Duplicates an appliance.
|
||||
Duplicates a template.
|
||||
|
||||
:param appliance_id: appliance identifier
|
||||
:param template_id: template identifier
|
||||
"""
|
||||
|
||||
appliance = self.get_appliance(appliance_id)
|
||||
if appliance.builtin:
|
||||
raise aiohttp.web.HTTPConflict(text="Appliance ID {} cannot be duplicated because it is a builtin".format(appliance_id))
|
||||
appliance_settings = copy.deepcopy(appliance.settings)
|
||||
del appliance_settings["appliance_id"]
|
||||
return self.add_appliance(appliance_settings)
|
||||
template = self.get_template(template_id)
|
||||
if template.builtin:
|
||||
raise aiohttp.web.HTTPConflict(text="Template ID {} cannot be duplicated because it is a builtin".format(template_id))
|
||||
template_settings = copy.deepcopy(template.settings)
|
||||
del template_settings["template_id"]
|
||||
return self.add_template(template_settings)
|
||||
|
||||
def load_appliances(self):
|
||||
|
||||
#self._appliances = {}
|
||||
def load_templates(self):
|
||||
|
||||
# Add builtins
|
||||
builtins = []
|
||||
builtins.append(Appliance(uuid.uuid3(uuid.NAMESPACE_DNS, "cloud"), {"appliance_type": "cloud", "name": "Cloud", "category": 2, "symbol": ":/symbols/cloud.svg"}, builtin=True))
|
||||
builtins.append(Appliance(uuid.uuid3(uuid.NAMESPACE_DNS, "nat"), {"appliance_type": "nat", "name": "NAT", "category": 2, "symbol": ":/symbols/cloud.svg"}, builtin=True))
|
||||
builtins.append(Appliance(uuid.uuid3(uuid.NAMESPACE_DNS, "vpcs"), {"appliance_type": "vpcs", "name": "VPCS", "default_name_format": "PC-{0}", "category": 2, "symbol": ":/symbols/vpcs_guest.svg", "properties": {"base_script_file": "vpcs_base_config.txt"}}, builtin=True))
|
||||
builtins.append(Appliance(uuid.uuid3(uuid.NAMESPACE_DNS, "ethernet_switch"), {"appliance_type": "ethernet_switch", "console_type": "telnet", "name": "Ethernet switch", "category": 1, "symbol": ":/symbols/ethernet_switch.svg"}, builtin=True))
|
||||
builtins.append(Appliance(uuid.uuid3(uuid.NAMESPACE_DNS, "ethernet_hub"), {"appliance_type": "ethernet_hub", "name": "Ethernet hub", "category": 1, "symbol": ":/symbols/hub.svg"}, builtin=True))
|
||||
builtins.append(Appliance(uuid.uuid3(uuid.NAMESPACE_DNS, "frame_relay_switch"), {"appliance_type": "frame_relay_switch", "name": "Frame Relay switch", "category": 1, "symbol": ":/symbols/frame_relay_switch.svg"}, builtin=True))
|
||||
builtins.append(Appliance(uuid.uuid3(uuid.NAMESPACE_DNS, "atm_switch"), {"appliance_type": "atm_switch", "name": "ATM switch", "category": 1, "symbol": ":/symbols/atm_switch.svg"}, builtin=True))
|
||||
builtins.append(Template(uuid.uuid3(uuid.NAMESPACE_DNS, "cloud"), {"template_type": "cloud", "name": "Cloud", "category": 2, "symbol": ":/symbols/cloud.svg"}, builtin=True))
|
||||
builtins.append(Template(uuid.uuid3(uuid.NAMESPACE_DNS, "nat"), {"template_type": "nat", "name": "NAT", "category": 2, "symbol": ":/symbols/cloud.svg"}, builtin=True))
|
||||
builtins.append(Template(uuid.uuid3(uuid.NAMESPACE_DNS, "vpcs"), {"template_type": "vpcs", "name": "VPCS", "default_name_format": "PC-{0}", "category": 2, "symbol": ":/symbols/vpcs_guest.svg", "properties": {"base_script_file": "vpcs_base_config.txt"}}, builtin=True))
|
||||
builtins.append(Template(uuid.uuid3(uuid.NAMESPACE_DNS, "ethernet_switch"), {"template_type": "ethernet_switch", "console_type": "telnet", "name": "Ethernet switch", "category": 1, "symbol": ":/symbols/ethernet_switch.svg"}, builtin=True))
|
||||
builtins.append(Template(uuid.uuid3(uuid.NAMESPACE_DNS, "ethernet_hub"), {"template_type": "ethernet_hub", "name": "Ethernet hub", "category": 1, "symbol": ":/symbols/hub.svg"}, builtin=True))
|
||||
builtins.append(Template(uuid.uuid3(uuid.NAMESPACE_DNS, "frame_relay_switch"), {"template_type": "frame_relay_switch", "name": "Frame Relay switch", "category": 1, "symbol": ":/symbols/frame_relay_switch.svg"}, builtin=True))
|
||||
builtins.append(Template(uuid.uuid3(uuid.NAMESPACE_DNS, "atm_switch"), {"template_type": "atm_switch", "name": "ATM switch", "category": 1, "symbol": ":/symbols/atm_switch.svg"}, builtin=True))
|
||||
|
||||
#FIXME: disable TraceNG
|
||||
#if sys.platform.startswith("win"):
|
||||
# builtins.append(Appliance(uuid.uuid3(uuid.NAMESPACE_DNS, "traceng"), {"appliance_type": "traceng", "name": "TraceNG", "default_name_format": "TraceNG-{0}", "category": 2, "symbol": ":/symbols/traceng.svg", "properties": {}}, builtin=True))
|
||||
# builtins.append(Template(uuid.uuid3(uuid.NAMESPACE_DNS, "traceng"), {"template_type": "traceng", "name": "TraceNG", "default_name_format": "TraceNG-{0}", "category": 2, "symbol": ":/symbols/traceng.svg", "properties": {}}, builtin=True))
|
||||
for b in builtins:
|
||||
self._appliances[b.id] = b
|
||||
self._templates[b.id] = b
|
||||
|
||||
async def start(self):
|
||||
|
||||
@@ -295,15 +293,15 @@ class Controller:
|
||||
return
|
||||
|
||||
controller_settings = {"computes": [],
|
||||
"appliances": [],
|
||||
"templates": [],
|
||||
"gns3vm": self.gns3vm.__json__(),
|
||||
"iou_license": self._iou_license_settings,
|
||||
"appliance_templates_etag": self._appliance_templates_etag,
|
||||
"appliances_etag": self._appliances_etag,
|
||||
"version": __version__}
|
||||
|
||||
for appliance in self._appliances.values():
|
||||
if not appliance.builtin:
|
||||
controller_settings["appliances"].append(appliance.__json__())
|
||||
for template in self._templates.values():
|
||||
if not template.builtin:
|
||||
controller_settings["templates"].append(template.__json__())
|
||||
|
||||
for compute in self._computes.values():
|
||||
if compute.id != "local" and compute.id != "vm":
|
||||
@@ -337,14 +335,14 @@ class Controller:
|
||||
log.critical("Cannot load configuration file '{}': {}".format(self._config_file, e))
|
||||
return []
|
||||
|
||||
# load the appliances
|
||||
if "appliances" in controller_settings:
|
||||
for appliance_settings in controller_settings["appliances"]:
|
||||
# load the templates
|
||||
if "templates" in controller_settings:
|
||||
for template_settings in controller_settings["templates"]:
|
||||
try:
|
||||
appliance = Appliance(appliance_settings.get("appliance_id"), appliance_settings)
|
||||
self._appliances[appliance.id] = appliance
|
||||
template = Template(template_settings.get("template_id"), template_settings)
|
||||
self._templates[template.id] = template
|
||||
except jsonschema.ValidationError as e:
|
||||
message = "Cannot load appliance with JSON data '{}': {}".format(appliance_settings, e.message)
|
||||
message = "Cannot load template with JSON data '{}': {}".format(template_settings, e.message)
|
||||
log.warning(message)
|
||||
continue
|
||||
|
||||
@@ -356,9 +354,9 @@ class Controller:
|
||||
if "iou_license" in controller_settings:
|
||||
self._iou_license_settings = controller_settings["iou_license"]
|
||||
|
||||
self._appliance_templates_etag = controller_settings.get("appliance_templates_etag")
|
||||
self.load_appliance_templates()
|
||||
self._appliances_etag = controller_settings.get("appliances_etag")
|
||||
self.load_appliances()
|
||||
self.load_templates()
|
||||
self._config_loaded = True
|
||||
return controller_settings.get("computes", [])
|
||||
|
||||
@@ -479,37 +477,37 @@ class Controller:
|
||||
|
||||
vms = []
|
||||
for vm in settings.get("Qemu", {}).get("vms", []):
|
||||
vm["appliance_type"] = "qemu"
|
||||
vm["template_type"] = "qemu"
|
||||
vms.append(vm)
|
||||
for vm in settings.get("IOU", {}).get("devices", []):
|
||||
vm["appliance_type"] = "iou"
|
||||
vm["template_type"] = "iou"
|
||||
vms.append(vm)
|
||||
for vm in settings.get("Docker", {}).get("containers", []):
|
||||
vm["appliance_type"] = "docker"
|
||||
vm["template_type"] = "docker"
|
||||
vms.append(vm)
|
||||
for vm in settings.get("Builtin", {}).get("cloud_nodes", []):
|
||||
vm["appliance_type"] = "cloud"
|
||||
vm["template_type"] = "cloud"
|
||||
vms.append(vm)
|
||||
for vm in settings.get("Builtin", {}).get("ethernet_switches", []):
|
||||
vm["appliance_type"] = "ethernet_switch"
|
||||
vm["template_type"] = "ethernet_switch"
|
||||
vms.append(vm)
|
||||
for vm in settings.get("Builtin", {}).get("ethernet_hubs", []):
|
||||
vm["appliance_type"] = "ethernet_hub"
|
||||
vm["template_type"] = "ethernet_hub"
|
||||
vms.append(vm)
|
||||
for vm in settings.get("Dynamips", {}).get("routers", []):
|
||||
vm["appliance_type"] = "dynamips"
|
||||
vm["template_type"] = "dynamips"
|
||||
vms.append(vm)
|
||||
for vm in settings.get("VMware", {}).get("vms", []):
|
||||
vm["appliance_type"] = "vmware"
|
||||
vm["template_type"] = "vmware"
|
||||
vms.append(vm)
|
||||
for vm in settings.get("VirtualBox", {}).get("vms", []):
|
||||
vm["appliance_type"] = "virtualbox"
|
||||
vm["template_type"] = "virtualbox"
|
||||
vms.append(vm)
|
||||
for vm in settings.get("VPCS", {}).get("nodes", []):
|
||||
vm["appliance_type"] = "vpcs"
|
||||
vm["template_type"] = "vpcs"
|
||||
vms.append(vm)
|
||||
for vm in settings.get("TraceNG", {}).get("nodes", []):
|
||||
vm["appliance_type"] = "traceng"
|
||||
vm["template_type"] = "traceng"
|
||||
vms.append(vm)
|
||||
|
||||
for vm in vms:
|
||||
@@ -530,14 +528,14 @@ class Controller:
|
||||
if "symbol" not in vm.keys():
|
||||
vm["symbol"] = ":/symbols/computer.svg"
|
||||
|
||||
vm.setdefault("appliance_id", str(uuid.uuid4()))
|
||||
vm.setdefault("template_id", str(uuid.uuid4()))
|
||||
try:
|
||||
appliance = Appliance(vm["appliance_id"], vm)
|
||||
appliance.__json__() # Check if loaded without error
|
||||
self._appliances[appliance.id] = appliance
|
||||
template = Template(vm["template_id"], vm)
|
||||
template.__json__() # Check if loaded without error
|
||||
self._templates[template.id] = template
|
||||
except KeyError as e:
|
||||
# appliance data is not complete (missing name or type)
|
||||
log.warning("Cannot load appliance template {} ('{}'): missing key {}".format(vm["appliance_id"], vm.get("name", "unknown"), e))
|
||||
# template data is not complete (missing name or type)
|
||||
log.warning("Cannot load template {} ('{}'): missing key {}".format(vm["template_id"], vm.get("name", "unknown"), e))
|
||||
continue
|
||||
|
||||
async def add_compute(self, compute_id=None, name=None, force=False, connect=True, **kwargs):
|
||||
@@ -759,14 +757,6 @@ class Controller:
|
||||
|
||||
return self._projects
|
||||
|
||||
@property
|
||||
def appliance_templates(self):
|
||||
"""
|
||||
:returns: The dictionary of appliances templates managed by GNS3
|
||||
"""
|
||||
|
||||
return self._appliance_templates
|
||||
|
||||
@property
|
||||
def appliances(self):
|
||||
"""
|
||||
@@ -775,6 +765,14 @@ class Controller:
|
||||
|
||||
return self._appliances
|
||||
|
||||
@property
|
||||
def templates(self):
|
||||
"""
|
||||
:returns: The dictionary of templates managed by GNS3
|
||||
"""
|
||||
|
||||
return self._templates
|
||||
|
||||
@property
|
||||
def iou_license(self):
|
||||
"""
|
||||
|
||||
@@ -17,193 +17,34 @@
|
||||
|
||||
import copy
|
||||
import uuid
|
||||
import json
|
||||
import jsonschema
|
||||
|
||||
from gns3server.schemas.cloud_appliance import CLOUD_APPLIANCE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.ethernet_switch_appliance import ETHERNET_SWITCH_APPLIANCE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.ethernet_hub_appliance import ETHERNET_HUB_APPLIANCE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.docker_appliance import DOCKER_APPLIANCE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.vpcs_appliance import VPCS_APPLIANCE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.traceng_appliance import TRACENG_APPLIANCE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.virtualbox_appliance import VIRTUALBOX_APPLIANCE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.vmware_appliance import VMWARE_APPLIANCE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.iou_appliance import IOU_APPLIANCE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.qemu_appliance import QEMU_APPLIANCE_OBJECT_SCHEMA
|
||||
|
||||
from gns3server.schemas.dynamips_appliance import (
|
||||
DYNAMIPS_APPLIANCE_OBJECT_SCHEMA,
|
||||
C7200_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA,
|
||||
C3745_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA,
|
||||
C3725_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA,
|
||||
C3600_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA,
|
||||
C2691_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA,
|
||||
C2600_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA,
|
||||
C1700_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA
|
||||
)
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Add default values for missing entries in a request, largely taken from jsonschema documentation example
|
||||
# https://python-jsonschema.readthedocs.io/en/latest/faq/#why-doesn-t-my-schema-s-default-property-set-the-default-on-my-instance
|
||||
def extend_with_default(validator_class):
|
||||
|
||||
validate_properties = validator_class.VALIDATORS["properties"]
|
||||
def set_defaults(validator, properties, instance, schema):
|
||||
if jsonschema.Draft4Validator(schema).is_valid(instance):
|
||||
# only add default for the matching sub-schema (e.g. when using 'oneOf')
|
||||
for property, subschema in properties.items():
|
||||
if "default" in subschema:
|
||||
instance.setdefault(property, subschema["default"])
|
||||
|
||||
for error in validate_properties(validator, properties, instance, schema,):
|
||||
yield error
|
||||
|
||||
return jsonschema.validators.extend(
|
||||
validator_class, {"properties" : set_defaults},
|
||||
)
|
||||
|
||||
|
||||
ValidatorWithDefaults = extend_with_default(jsonschema.Draft4Validator)
|
||||
|
||||
ID_TO_CATEGORY = {
|
||||
3: "firewall",
|
||||
2: "guest",
|
||||
1: "switch",
|
||||
0: "router"
|
||||
}
|
||||
|
||||
APPLIANCE_TYPE_TO_SHEMA = {
|
||||
"cloud": CLOUD_APPLIANCE_OBJECT_SCHEMA,
|
||||
"ethernet_hub": ETHERNET_HUB_APPLIANCE_OBJECT_SCHEMA,
|
||||
"ethernet_switch": ETHERNET_SWITCH_APPLIANCE_OBJECT_SCHEMA,
|
||||
"docker": DOCKER_APPLIANCE_OBJECT_SCHEMA,
|
||||
"dynamips": DYNAMIPS_APPLIANCE_OBJECT_SCHEMA,
|
||||
"vpcs": VPCS_APPLIANCE_OBJECT_SCHEMA,
|
||||
"traceng": TRACENG_APPLIANCE_OBJECT_SCHEMA,
|
||||
"virtualbox": VIRTUALBOX_APPLIANCE_OBJECT_SCHEMA,
|
||||
"vmware": VMWARE_APPLIANCE_OBJECT_SCHEMA,
|
||||
"iou": IOU_APPLIANCE_OBJECT_SCHEMA,
|
||||
"qemu": QEMU_APPLIANCE_OBJECT_SCHEMA
|
||||
}
|
||||
|
||||
DYNAMIPS_PLATFORM_TO_SHEMA = {
|
||||
"c7200": C7200_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA,
|
||||
"c3745": C3745_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA,
|
||||
"c3725": C3725_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA,
|
||||
"c3600": C3600_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA,
|
||||
"c2691": C2691_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA,
|
||||
"c2600": C2600_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA,
|
||||
"c1700": C1700_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA
|
||||
}
|
||||
|
||||
|
||||
class Appliance:
|
||||
|
||||
def __init__(self, appliance_id, settings, builtin=False):
|
||||
|
||||
def __init__(self, appliance_id, data, builtin=True):
|
||||
if appliance_id is None:
|
||||
self._id = str(uuid.uuid4())
|
||||
elif isinstance(appliance_id, uuid.UUID):
|
||||
self._id = str(appliance_id)
|
||||
else:
|
||||
self._id = appliance_id
|
||||
|
||||
self._settings = copy.deepcopy(settings)
|
||||
|
||||
# Version of the gui before 2.1 use linked_base
|
||||
# and the server linked_clone
|
||||
if "linked_base" in self.settings:
|
||||
linked_base = self._settings.pop("linked_base")
|
||||
if "linked_clone" not in self._settings:
|
||||
self._settings["linked_clone"] = linked_base
|
||||
|
||||
# Convert old GUI category to text category
|
||||
try:
|
||||
self._settings["category"] = ID_TO_CATEGORY[self._settings["category"]]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
# The "server" setting has been replaced by "compute_id" setting in version 2.2
|
||||
if "server" in self._settings:
|
||||
self._settings["compute_id"] = self._settings.pop("server")
|
||||
|
||||
# The "node_type" setting has been replaced by "appliance_type" setting in version 2.2
|
||||
if "node_type" in self._settings:
|
||||
self._settings["appliance_type"] = self._settings.pop("node_type")
|
||||
|
||||
# Remove an old IOU setting
|
||||
if self._settings["appliance_type"] == "iou" and "image" in self._settings:
|
||||
del self._settings["image"]
|
||||
|
||||
self._data = data.copy()
|
||||
self._builtin = builtin
|
||||
|
||||
if builtin is False:
|
||||
self.validate_and_apply_defaults(APPLIANCE_TYPE_TO_SHEMA[self.appliance_type])
|
||||
|
||||
if self.appliance_type == "dynamips":
|
||||
# special case for Dynamips to cover all platform types that contain specific settings
|
||||
self.validate_and_apply_defaults(DYNAMIPS_PLATFORM_TO_SHEMA[self._settings["platform"]])
|
||||
if "appliance_id" in self._data:
|
||||
del self._data["appliance_id"]
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return self._id
|
||||
|
||||
@property
|
||||
def settings(self):
|
||||
return self._settings
|
||||
|
||||
@settings.setter
|
||||
def settings(self, settings):
|
||||
self._settings.update(settings)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._settings["name"]
|
||||
|
||||
@property
|
||||
def compute_id(self):
|
||||
return self._settings["compute_id"]
|
||||
|
||||
@property
|
||||
def appliance_type(self):
|
||||
return self._settings["appliance_type"]
|
||||
|
||||
@property
|
||||
def builtin(self):
|
||||
return self._builtin
|
||||
|
||||
def update(self, **kwargs):
|
||||
|
||||
self._settings.update(kwargs)
|
||||
from gns3server.controller import Controller
|
||||
controller = Controller.instance()
|
||||
controller.notification.controller_emit("appliance.updated", self.__json__())
|
||||
controller.save()
|
||||
|
||||
def validate_and_apply_defaults(self, schema):
|
||||
|
||||
validator = ValidatorWithDefaults(schema)
|
||||
try:
|
||||
validator.validate(self.__json__())
|
||||
except jsonschema.ValidationError as e:
|
||||
message = "JSON schema error {}".format(e.message)
|
||||
log.error(message)
|
||||
log.debug("Input schema: {}".format(json.dumps(schema)))
|
||||
raise
|
||||
def status(self):
|
||||
return self._data["status"]
|
||||
|
||||
def __json__(self):
|
||||
"""
|
||||
Appliance settings.
|
||||
Appliance data (a hash)
|
||||
"""
|
||||
|
||||
settings = self._settings
|
||||
settings.update({"appliance_id": self._id,
|
||||
"builtin": self.builtin})
|
||||
|
||||
if not self.builtin:
|
||||
settings["compute_id"] = self.compute_id
|
||||
|
||||
return settings
|
||||
data = copy.deepcopy(self._data)
|
||||
data["builtin"] = self._builtin
|
||||
return data
|
||||
@@ -1,50 +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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
import copy
|
||||
import uuid
|
||||
|
||||
|
||||
class ApplianceTemplate:
|
||||
|
||||
def __init__(self, appliance_id, data, builtin=True):
|
||||
if appliance_id is None:
|
||||
self._id = str(uuid.uuid4())
|
||||
elif isinstance(appliance_id, uuid.UUID):
|
||||
self._id = str(appliance_id)
|
||||
else:
|
||||
self._id = appliance_id
|
||||
self._data = data.copy()
|
||||
self._builtin = builtin
|
||||
if "appliance_id" in self._data:
|
||||
del self._data["appliance_id"]
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return self._id
|
||||
|
||||
@property
|
||||
def status(self):
|
||||
return self._data["status"]
|
||||
|
||||
def __json__(self):
|
||||
"""
|
||||
Appliance data (a hash)
|
||||
"""
|
||||
data = copy.deepcopy(self._data)
|
||||
data["builtin"] = self._builtin
|
||||
return data
|
||||
@@ -38,14 +38,14 @@ class Node:
|
||||
"port_name_format", "first_port_name", "port_segment_size", "ports",
|
||||
"category", "console_auto_start"]
|
||||
|
||||
def __init__(self, project, compute, name, node_id=None, node_type=None, appliance_id=None, **kwargs):
|
||||
def __init__(self, project, compute, name, node_id=None, node_type=None, template_id=None, **kwargs):
|
||||
"""
|
||||
:param project: Project of the node
|
||||
:param compute: Compute where the server will run
|
||||
:param name: Node name
|
||||
:param node_id: UUID of the node (integer)
|
||||
:param node_type: Type of emulator
|
||||
:param appliance_id: Appliance ID used to create this node
|
||||
:param template_id: Template ID used to create this node
|
||||
:param kwargs: Node properties
|
||||
"""
|
||||
|
||||
@@ -70,7 +70,7 @@ class Node:
|
||||
self._command_line = None
|
||||
self._node_directory = None
|
||||
self._status = "stopped"
|
||||
self._appliance_id = appliance_id
|
||||
self._template_id = template_id
|
||||
self._x = 0
|
||||
self._y = 0
|
||||
self._z = 1 # default z value is 1
|
||||
@@ -671,7 +671,7 @@ class Node:
|
||||
"compute_id": str(self._compute.id),
|
||||
"node_id": self._id,
|
||||
"node_type": self._node_type,
|
||||
"appliance_id": self._appliance_id,
|
||||
"template_id": self._template_id,
|
||||
"name": self._name,
|
||||
"console": self._console,
|
||||
"console_type": self._console_type,
|
||||
@@ -693,7 +693,7 @@ class Node:
|
||||
"compute_id": str(self._compute.id),
|
||||
"project_id": self._project.id,
|
||||
"node_id": self._id,
|
||||
"appliance_id": self._appliance_id,
|
||||
"template_id": self._template_id,
|
||||
"node_type": self._node_type,
|
||||
"node_directory": self._node_directory,
|
||||
"name": self._name,
|
||||
|
||||
@@ -476,19 +476,19 @@ class Project:
|
||||
return new_name
|
||||
|
||||
@open_required
|
||||
async def add_node_from_appliance(self, appliance_id, x=0, y=0, compute_id=None):
|
||||
async def add_node_from_template(self, template_id, x=0, y=0, compute_id=None):
|
||||
"""
|
||||
Create a node from an appliance
|
||||
Create a node from a template.
|
||||
"""
|
||||
try:
|
||||
template = copy.deepcopy(self.controller.appliances[appliance_id].settings)
|
||||
template = copy.deepcopy(self.controller.templates[template_id].settings)
|
||||
except KeyError:
|
||||
msg = "Appliance {} doesn't exist".format(appliance_id)
|
||||
msg = "Template {} doesn't exist".format(template_id)
|
||||
log.error(msg)
|
||||
raise aiohttp.web.HTTPNotFound(text=msg)
|
||||
template["x"] = x
|
||||
template["y"] = y
|
||||
node_type = template.pop("appliance_type")
|
||||
node_type = template.pop("template_type")
|
||||
compute = self.controller.get_compute(template.pop("compute_id", compute_id))
|
||||
name = template.pop("name")
|
||||
default_name_format = template.pop("default_name_format", "{name}-{0}")
|
||||
|
||||
@@ -0,0 +1,209 @@
|
||||
#!/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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
import copy
|
||||
import uuid
|
||||
import json
|
||||
import jsonschema
|
||||
|
||||
from gns3server.schemas.cloud_template import CLOUD_TEMPLATE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.ethernet_switch_template import ETHERNET_SWITCH_TEMPLATE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.ethernet_hub_template import ETHERNET_HUB_TEMPLATE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.docker_template import DOCKER_TEMPLATE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.vpcs_template import VPCS_TEMPLATE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.traceng_template import TRACENG_TEMPLATE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.virtualbox_template import VIRTUALBOX_TEMPLATE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.vmware_template import VMWARE_TEMPLATE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.iou_template import IOU_TEMPLATE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.qemu_template import QEMU_TEMPLATE_OBJECT_SCHEMA
|
||||
|
||||
from gns3server.schemas.dynamips_template import (
|
||||
DYNAMIPS_TEMPLATE_OBJECT_SCHEMA,
|
||||
C7200_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA,
|
||||
C3745_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA,
|
||||
C3725_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA,
|
||||
C3600_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA,
|
||||
C2691_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA,
|
||||
C2600_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA,
|
||||
C1700_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA
|
||||
)
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
# Add default values for missing entries in a request, largely taken from jsonschema documentation example
|
||||
# https://python-jsonschema.readthedocs.io/en/latest/faq/#why-doesn-t-my-schema-s-default-property-set-the-default-on-my-instance
|
||||
def extend_with_default(validator_class):
|
||||
|
||||
validate_properties = validator_class.VALIDATORS["properties"]
|
||||
def set_defaults(validator, properties, instance, schema):
|
||||
if jsonschema.Draft4Validator(schema).is_valid(instance):
|
||||
# only add default for the matching sub-schema (e.g. when using 'oneOf')
|
||||
for property, subschema in properties.items():
|
||||
if "default" in subschema:
|
||||
instance.setdefault(property, subschema["default"])
|
||||
|
||||
for error in validate_properties(validator, properties, instance, schema,):
|
||||
yield error
|
||||
|
||||
return jsonschema.validators.extend(
|
||||
validator_class, {"properties" : set_defaults},
|
||||
)
|
||||
|
||||
|
||||
ValidatorWithDefaults = extend_with_default(jsonschema.Draft4Validator)
|
||||
|
||||
ID_TO_CATEGORY = {
|
||||
3: "firewall",
|
||||
2: "guest",
|
||||
1: "switch",
|
||||
0: "router"
|
||||
}
|
||||
|
||||
TEMPLATE_TYPE_TO_SHEMA = {
|
||||
"cloud": CLOUD_TEMPLATE_OBJECT_SCHEMA,
|
||||
"ethernet_hub": ETHERNET_HUB_TEMPLATE_OBJECT_SCHEMA,
|
||||
"ethernet_switch": ETHERNET_SWITCH_TEMPLATE_OBJECT_SCHEMA,
|
||||
"docker": DOCKER_TEMPLATE_OBJECT_SCHEMA,
|
||||
"dynamips": DYNAMIPS_TEMPLATE_OBJECT_SCHEMA,
|
||||
"vpcs": VPCS_TEMPLATE_OBJECT_SCHEMA,
|
||||
"traceng": TRACENG_TEMPLATE_OBJECT_SCHEMA,
|
||||
"virtualbox": VIRTUALBOX_TEMPLATE_OBJECT_SCHEMA,
|
||||
"vmware": VMWARE_TEMPLATE_OBJECT_SCHEMA,
|
||||
"iou": IOU_TEMPLATE_OBJECT_SCHEMA,
|
||||
"qemu": QEMU_TEMPLATE_OBJECT_SCHEMA
|
||||
}
|
||||
|
||||
DYNAMIPS_PLATFORM_TO_SHEMA = {
|
||||
"c7200": C7200_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA,
|
||||
"c3745": C3745_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA,
|
||||
"c3725": C3725_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA,
|
||||
"c3600": C3600_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA,
|
||||
"c2691": C2691_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA,
|
||||
"c2600": C2600_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA,
|
||||
"c1700": C1700_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA
|
||||
}
|
||||
|
||||
|
||||
class Template:
|
||||
|
||||
def __init__(self, template_id, settings, builtin=False):
|
||||
|
||||
if template_id is None:
|
||||
self._id = str(uuid.uuid4())
|
||||
elif isinstance(template_id, uuid.UUID):
|
||||
self._id = str(template_id)
|
||||
else:
|
||||
self._id = template_id
|
||||
|
||||
self._settings = copy.deepcopy(settings)
|
||||
|
||||
# Version of the gui before 2.1 use linked_base
|
||||
# and the server linked_clone
|
||||
if "linked_base" in self.settings:
|
||||
linked_base = self._settings.pop("linked_base")
|
||||
if "linked_clone" not in self._settings:
|
||||
self._settings["linked_clone"] = linked_base
|
||||
|
||||
# Convert old GUI category to text category
|
||||
try:
|
||||
self._settings["category"] = ID_TO_CATEGORY[self._settings["category"]]
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
# The "server" setting has been replaced by "compute_id" setting in version 2.2
|
||||
if "server" in self._settings:
|
||||
self._settings["compute_id"] = self._settings.pop("server")
|
||||
|
||||
# The "node_type" setting has been replaced by "template_type" setting in version 2.2
|
||||
if "node_type" in self._settings:
|
||||
self._settings["template_type"] = self._settings.pop("node_type")
|
||||
|
||||
# Remove an old IOU setting
|
||||
if self._settings["template_type"] == "iou" and "image" in self._settings:
|
||||
del self._settings["image"]
|
||||
|
||||
self._builtin = builtin
|
||||
|
||||
if builtin is False:
|
||||
self.validate_and_apply_defaults(TEMPLATE_TYPE_TO_SHEMA[self.template_type])
|
||||
|
||||
if self.template_type == "dynamips":
|
||||
# special case for Dynamips to cover all platform types that contain specific settings
|
||||
self.validate_and_apply_defaults(DYNAMIPS_PLATFORM_TO_SHEMA[self._settings["platform"]])
|
||||
|
||||
@property
|
||||
def id(self):
|
||||
return self._id
|
||||
|
||||
@property
|
||||
def settings(self):
|
||||
return self._settings
|
||||
|
||||
@settings.setter
|
||||
def settings(self, settings):
|
||||
self._settings.update(settings)
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
return self._settings["name"]
|
||||
|
||||
@property
|
||||
def compute_id(self):
|
||||
return self._settings["compute_id"]
|
||||
|
||||
@property
|
||||
def template_type(self):
|
||||
return self._settings["template_type"]
|
||||
|
||||
@property
|
||||
def builtin(self):
|
||||
return self._builtin
|
||||
|
||||
def update(self, **kwargs):
|
||||
|
||||
self._settings.update(kwargs)
|
||||
from gns3server.controller import Controller
|
||||
controller = Controller.instance()
|
||||
controller.notification.controller_emit("template.updated", self.__json__())
|
||||
controller.save()
|
||||
|
||||
def validate_and_apply_defaults(self, schema):
|
||||
|
||||
validator = ValidatorWithDefaults(schema)
|
||||
try:
|
||||
validator.validate(self.__json__())
|
||||
except jsonschema.ValidationError as e:
|
||||
message = "JSON schema error {}".format(e.message)
|
||||
log.error(message)
|
||||
log.debug("Input schema: {}".format(json.dumps(schema)))
|
||||
raise
|
||||
|
||||
def __json__(self):
|
||||
"""
|
||||
Template settings.
|
||||
"""
|
||||
|
||||
settings = self._settings
|
||||
settings.update({"template_id": self._id,
|
||||
"builtin": self.builtin})
|
||||
|
||||
if not self.builtin:
|
||||
settings["compute_id"] = self.compute_id
|
||||
|
||||
return settings
|
||||
@@ -159,6 +159,14 @@ def load_topology(path):
|
||||
if topo["revision"] < 9:
|
||||
topo = _convert_2_1_0(topo, path)
|
||||
|
||||
# Version GNS3 2.2 dev (for project created with 2.2dev).
|
||||
# Appliance ID has been repleace by Template ID
|
||||
if topo["revision"] == 9:
|
||||
for node in topo.get("topology", {}).get("nodes", []):
|
||||
if "appliance_id" in node:
|
||||
node["template_id"] = node["appliance_id"]
|
||||
del node["appliance_id"]
|
||||
|
||||
try:
|
||||
_check_topology_schema(topo)
|
||||
except aiohttp.web.HTTPConflict as e:
|
||||
|
||||
@@ -24,5 +24,6 @@ from .drawing_handler import DrawingHandler
|
||||
from .symbol_handler import SymbolHandler
|
||||
from .snapshot_handler import SnapshotHandler
|
||||
from .appliance_handler import ApplianceHandler
|
||||
from .template_handler import TemplateHandler
|
||||
from .gns3_vm_handler import GNS3VMHandler
|
||||
from .notification_handler import NotificationHandler
|
||||
@@ -17,167 +17,26 @@
|
||||
|
||||
from gns3server.web.route import Route
|
||||
from gns3server.controller import Controller
|
||||
from gns3server.schemas.node import NODE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.appliance import APPLIANCE_USAGE_SCHEMA
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
|
||||
from gns3server.schemas.appliance import (
|
||||
APPLIANCE_OBJECT_SCHEMA,
|
||||
APPLIANCE_UPDATE_SCHEMA,
|
||||
APPLIANCE_CREATE_SCHEMA
|
||||
)
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class ApplianceHandler:
|
||||
"""API entry points for appliance management."""
|
||||
|
||||
@Route.get(
|
||||
r"/appliances/templates",
|
||||
description="List of appliance templates",
|
||||
status_codes={
|
||||
200: "Appliance template list returned"
|
||||
})
|
||||
async def list_templates(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
if request.query.get("update", "no") == "yes":
|
||||
await controller.download_appliance_templates()
|
||||
controller.load_appliance_templates()
|
||||
response.json([c for c in controller.appliance_templates.values()])
|
||||
|
||||
@Route.post(
|
||||
r"/appliances",
|
||||
description="Create a new appliance",
|
||||
status_codes={
|
||||
201: "Appliance created",
|
||||
400: "Invalid request"
|
||||
},
|
||||
input=APPLIANCE_CREATE_SCHEMA,
|
||||
output=APPLIANCE_OBJECT_SCHEMA)
|
||||
def create(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
appliance = controller.add_appliance(request.json)
|
||||
response.set_status(201)
|
||||
response.json(appliance)
|
||||
|
||||
@Route.get(
|
||||
r"/appliances/{appliance_id}",
|
||||
status_codes={
|
||||
200: "Appliance found",
|
||||
400: "Invalid request",
|
||||
404: "Appliance doesn't exist"
|
||||
},
|
||||
description="Get an appliance",
|
||||
output=APPLIANCE_OBJECT_SCHEMA)
|
||||
def get(request, response):
|
||||
|
||||
request_etag = request.headers.get("If-None-Match", "")
|
||||
controller = Controller.instance()
|
||||
appliance = controller.get_appliance(request.match_info["appliance_id"])
|
||||
data = json.dumps(appliance.__json__())
|
||||
appliance_etag = '"' + hashlib.md5(data.encode()).hexdigest() + '"'
|
||||
if appliance_etag == request_etag:
|
||||
response.set_status(304)
|
||||
else:
|
||||
response.headers["ETag"] = appliance_etag
|
||||
response.set_status(200)
|
||||
response.json(appliance)
|
||||
|
||||
@Route.put(
|
||||
r"/appliances/{appliance_id}",
|
||||
status_codes={
|
||||
200: "Appliance updated",
|
||||
400: "Invalid request",
|
||||
404: "Appliance doesn't exist"
|
||||
},
|
||||
description="Update an appliance",
|
||||
input=APPLIANCE_UPDATE_SCHEMA,
|
||||
output=APPLIANCE_OBJECT_SCHEMA)
|
||||
def update(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
appliance = controller.get_appliance(request.match_info["appliance_id"])
|
||||
# Ignore these because we only use them when creating a appliance
|
||||
request.json.pop("appliance_id", None)
|
||||
request.json.pop("appliance_type", None)
|
||||
request.json.pop("compute_id", None)
|
||||
request.json.pop("builtin", None)
|
||||
appliance.update(**request.json)
|
||||
response.set_status(200)
|
||||
response.json(appliance)
|
||||
|
||||
@Route.delete(
|
||||
r"/appliances/{appliance_id}",
|
||||
parameters={
|
||||
"appliance_id": "appliance UUID"
|
||||
},
|
||||
status_codes={
|
||||
204: "Appliance deleted",
|
||||
400: "Invalid request",
|
||||
404: "Appliance doesn't exist"
|
||||
},
|
||||
description="Delete an appliance")
|
||||
def delete(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
controller.delete_appliance(request.match_info["appliance_id"])
|
||||
response.set_status(204)
|
||||
"""
|
||||
API entry points for appliance management.
|
||||
"""
|
||||
|
||||
@Route.get(
|
||||
r"/appliances",
|
||||
description="List of appliance",
|
||||
description="List of appliances",
|
||||
status_codes={
|
||||
200: "Appliance list returned"
|
||||
})
|
||||
def list(request, response):
|
||||
async def list_appliances(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
if request.query.get("update", "no") == "yes":
|
||||
await controller.download_appliances()
|
||||
controller.load_appliances()
|
||||
response.json([c for c in controller.appliances.values()])
|
||||
|
||||
@Route.post(
|
||||
r"/appliances/{appliance_id}/duplicate",
|
||||
parameters={
|
||||
"appliance_id": "Appliance UUID"
|
||||
},
|
||||
status_codes={
|
||||
201: "Appliance duplicated",
|
||||
400: "Invalid request",
|
||||
404: "Appliance doesn't exist"
|
||||
},
|
||||
description="Duplicate an appliance",
|
||||
output=APPLIANCE_OBJECT_SCHEMA)
|
||||
async def duplicate(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
appliance = controller.duplicate_appliance(request.match_info["appliance_id"])
|
||||
response.set_status(201)
|
||||
response.json(appliance)
|
||||
|
||||
@Route.post(
|
||||
r"/projects/{project_id}/appliances/{appliance_id}",
|
||||
description="Create a node from an appliance",
|
||||
parameters={
|
||||
"project_id": "Project UUID",
|
||||
"appliance_id": "Appliance UUID"
|
||||
},
|
||||
status_codes={
|
||||
201: "Node created",
|
||||
404: "The project or appliance doesn't exist"
|
||||
},
|
||||
input=APPLIANCE_USAGE_SCHEMA,
|
||||
output=NODE_OBJECT_SCHEMA)
|
||||
async def create_node_from_appliance(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
project = controller.get_project(request.match_info["project_id"])
|
||||
await project.add_node_from_appliance(request.match_info["appliance_id"],
|
||||
x=request.json["x"],
|
||||
y=request.json["y"],
|
||||
compute_id=request.json.get("compute_id"))
|
||||
response.set_status(201)
|
||||
@@ -0,0 +1,171 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# Copyright (C) 2015 GNS3 Technologies Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
from gns3server.web.route import Route
|
||||
from gns3server.controller import Controller
|
||||
from gns3server.schemas.node import NODE_OBJECT_SCHEMA
|
||||
from gns3server.schemas.template import TEMPLATE_USAGE_SCHEMA
|
||||
|
||||
import hashlib
|
||||
import json
|
||||
|
||||
from gns3server.schemas.template import (
|
||||
TEMPLATE_OBJECT_SCHEMA,
|
||||
TEMPLATE_UPDATE_SCHEMA,
|
||||
TEMPLATE_CREATE_SCHEMA
|
||||
)
|
||||
|
||||
import logging
|
||||
log = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TemplateHandler:
|
||||
"""
|
||||
API entry points for template management.
|
||||
"""
|
||||
|
||||
@Route.post(
|
||||
r"/templates",
|
||||
description="Create a new template",
|
||||
status_codes={
|
||||
201: "Template created",
|
||||
400: "Invalid request"
|
||||
},
|
||||
input=TEMPLATE_CREATE_SCHEMA,
|
||||
output=TEMPLATE_OBJECT_SCHEMA)
|
||||
def create(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
template = controller.add_template(request.json)
|
||||
response.set_status(201)
|
||||
response.json(template)
|
||||
|
||||
@Route.get(
|
||||
r"/templates/{template_id}",
|
||||
status_codes={
|
||||
200: "Template found",
|
||||
400: "Invalid request",
|
||||
404: "Template doesn't exist"
|
||||
},
|
||||
description="Get an template",
|
||||
output=TEMPLATE_OBJECT_SCHEMA)
|
||||
def get(request, response):
|
||||
|
||||
request_etag = request.headers.get("If-None-Match", "")
|
||||
controller = Controller.instance()
|
||||
template = controller.get_template(request.match_info["template_id"])
|
||||
data = json.dumps(template.__json__())
|
||||
template_etag = '"' + hashlib.md5(data.encode()).hexdigest() + '"'
|
||||
if template_etag == request_etag:
|
||||
response.set_status(304)
|
||||
else:
|
||||
response.headers["ETag"] = template_etag
|
||||
response.set_status(200)
|
||||
response.json(template)
|
||||
|
||||
@Route.put(
|
||||
r"/templates/{template_id}",
|
||||
status_codes={
|
||||
200: "Template updated",
|
||||
400: "Invalid request",
|
||||
404: "Template doesn't exist"
|
||||
},
|
||||
description="Update an template",
|
||||
input=TEMPLATE_UPDATE_SCHEMA,
|
||||
output=TEMPLATE_OBJECT_SCHEMA)
|
||||
def update(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
template = controller.get_template(request.match_info["template_id"])
|
||||
# Ignore these because we only use them when creating a template
|
||||
request.json.pop("template_id", None)
|
||||
request.json.pop("template_type", None)
|
||||
request.json.pop("compute_id", None)
|
||||
request.json.pop("builtin", None)
|
||||
template.update(**request.json)
|
||||
response.set_status(200)
|
||||
response.json(template)
|
||||
|
||||
@Route.delete(
|
||||
r"/templates/{template_id}",
|
||||
parameters={
|
||||
"template_id": "template UUID"
|
||||
},
|
||||
status_codes={
|
||||
204: "Template deleted",
|
||||
400: "Invalid request",
|
||||
404: "Template doesn't exist"
|
||||
},
|
||||
description="Delete an template")
|
||||
def delete(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
controller.delete_template(request.match_info["template_id"])
|
||||
response.set_status(204)
|
||||
|
||||
@Route.get(
|
||||
r"/templates",
|
||||
description="List of template",
|
||||
status_codes={
|
||||
200: "Template list returned"
|
||||
})
|
||||
def list(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
response.json([c for c in controller.templates.values()])
|
||||
|
||||
@Route.post(
|
||||
r"/templates/{template_id}/duplicate",
|
||||
parameters={
|
||||
"template_id": "Template UUID"
|
||||
},
|
||||
status_codes={
|
||||
201: "Template duplicated",
|
||||
400: "Invalid request",
|
||||
404: "Template doesn't exist"
|
||||
},
|
||||
description="Duplicate an template",
|
||||
output=TEMPLATE_OBJECT_SCHEMA)
|
||||
async def duplicate(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
template = controller.duplicate_template(request.match_info["template_id"])
|
||||
response.set_status(201)
|
||||
response.json(template)
|
||||
|
||||
@Route.post(
|
||||
r"/projects/{project_id}/templates/{template_id}",
|
||||
description="Create a node from a template",
|
||||
parameters={
|
||||
"project_id": "Project UUID",
|
||||
"template_id": "Template UUID"
|
||||
},
|
||||
status_codes={
|
||||
201: "Node created",
|
||||
404: "The project or template doesn't exist"
|
||||
},
|
||||
input=TEMPLATE_USAGE_SCHEMA,
|
||||
output=NODE_OBJECT_SCHEMA)
|
||||
async def create_node_from_template(request, response):
|
||||
|
||||
controller = Controller.instance()
|
||||
project = controller.get_project(request.match_info["project_id"])
|
||||
await project.add_node_from_template(request.match_info["template_id"],
|
||||
x=request.json["x"],
|
||||
y=request.json["y"],
|
||||
compute_id=request.json.get("compute_id"))
|
||||
response.set_status(201)
|
||||
@@ -16,11 +16,11 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import copy
|
||||
from .appliance import BASE_APPLIANCE_PROPERTIES
|
||||
from .template import BASE_TEMPLATE_PROPERTIES
|
||||
from .port import PORT_OBJECT_SCHEMA
|
||||
|
||||
|
||||
CLOUD_APPLIANCE_PROPERTIES = {
|
||||
CLOUD_TEMPLATE_PROPERTIES = {
|
||||
"ports_mapping": {
|
||||
"type": "array",
|
||||
"items": [PORT_OBJECT_SCHEMA]
|
||||
@@ -47,15 +47,15 @@ CLOUD_APPLIANCE_PROPERTIES = {
|
||||
},
|
||||
}
|
||||
|
||||
CLOUD_APPLIANCE_PROPERTIES.update(copy.deepcopy(BASE_APPLIANCE_PROPERTIES))
|
||||
CLOUD_APPLIANCE_PROPERTIES["category"]["default"] = "guest"
|
||||
CLOUD_APPLIANCE_PROPERTIES["default_name_format"]["default"] = "Cloud{0}"
|
||||
CLOUD_APPLIANCE_PROPERTIES["symbol"]["default"] = ":/symbols/cloud.svg"
|
||||
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_APPLIANCE_OBJECT_SCHEMA = {
|
||||
CLOUD_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A cloud template object",
|
||||
"type": "object",
|
||||
"properties": CLOUD_APPLIANCE_PROPERTIES,
|
||||
"properties": CLOUD_TEMPLATE_PROPERTIES,
|
||||
"additionalProperties": False
|
||||
}
|
||||
@@ -16,11 +16,11 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import copy
|
||||
from .appliance import BASE_APPLIANCE_PROPERTIES
|
||||
from .template import BASE_TEMPLATE_PROPERTIES
|
||||
from .custom_adapters import CUSTOM_ADAPTERS_ARRAY_SCHEMA
|
||||
|
||||
|
||||
DOCKER_APPLIANCE_PROPERTIES = {
|
||||
DOCKER_TEMPLATE_PROPERTIES = {
|
||||
"image": {
|
||||
"description": "Docker image name",
|
||||
"type": "string",
|
||||
@@ -85,16 +85,16 @@ DOCKER_APPLIANCE_PROPERTIES = {
|
||||
"custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA
|
||||
}
|
||||
|
||||
DOCKER_APPLIANCE_PROPERTIES.update(copy.deepcopy(BASE_APPLIANCE_PROPERTIES))
|
||||
DOCKER_APPLIANCE_PROPERTIES["category"]["default"] = "guest"
|
||||
DOCKER_APPLIANCE_PROPERTIES["default_name_format"]["default"] = "{name}-{0}"
|
||||
DOCKER_APPLIANCE_PROPERTIES["symbol"]["default"] = ":/symbols/docker_guest.svg"
|
||||
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_APPLIANCE_OBJECT_SCHEMA = {
|
||||
DOCKER_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A Docker template object",
|
||||
"type": "object",
|
||||
"properties": DOCKER_APPLIANCE_PROPERTIES,
|
||||
"properties": DOCKER_TEMPLATE_PROPERTIES,
|
||||
"required": ["image"],
|
||||
"additionalProperties": False
|
||||
}
|
||||
+36
-36
@@ -16,11 +16,11 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import copy
|
||||
from .appliance import BASE_APPLIANCE_PROPERTIES
|
||||
from .template import BASE_TEMPLATE_PROPERTIES
|
||||
from .dynamips_vm import DYNAMIPS_ADAPTERS, DYNAMIPS_WICS
|
||||
|
||||
|
||||
DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
DYNAMIPS_TEMPLATE_PROPERTIES = {
|
||||
"platform": {
|
||||
"description": "Platform type",
|
||||
"enum": ["c7200", "c3745", "c3725", "c3600", "c2691", "c2600", "c1700"]
|
||||
@@ -118,20 +118,20 @@ DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
}
|
||||
}
|
||||
|
||||
DYNAMIPS_APPLIANCE_PROPERTIES.update(copy.deepcopy(BASE_APPLIANCE_PROPERTIES))
|
||||
DYNAMIPS_APPLIANCE_PROPERTIES["category"]["default"] = "router"
|
||||
DYNAMIPS_APPLIANCE_PROPERTIES["default_name_format"]["default"] = "R{0}"
|
||||
DYNAMIPS_APPLIANCE_PROPERTIES["symbol"]["default"] = ":/symbols/router.svg"
|
||||
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_APPLIANCE_OBJECT_SCHEMA = {
|
||||
DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A Dynamips template object",
|
||||
"type": "object",
|
||||
"properties": DYNAMIPS_APPLIANCE_PROPERTIES,
|
||||
"properties": DYNAMIPS_TEMPLATE_PROPERTIES,
|
||||
"required": ["platform", "image"],
|
||||
}
|
||||
|
||||
C7200_DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
C7200_DYNAMIPS_TEMPLATE_PROPERTIES = {
|
||||
"ram": {
|
||||
"description": "Amount of RAM in MB",
|
||||
"type": "integer",
|
||||
@@ -159,17 +159,17 @@ C7200_DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
}
|
||||
}
|
||||
|
||||
C7200_DYNAMIPS_APPLIANCE_PROPERTIES.update(DYNAMIPS_APPLIANCE_PROPERTIES)
|
||||
C7200_DYNAMIPS_TEMPLATE_PROPERTIES.update(DYNAMIPS_TEMPLATE_PROPERTIES)
|
||||
|
||||
C7200_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA = {
|
||||
C7200_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A c7200 Dynamips template object",
|
||||
"type": "object",
|
||||
"properties": C7200_DYNAMIPS_APPLIANCE_PROPERTIES,
|
||||
"properties": C7200_DYNAMIPS_TEMPLATE_PROPERTIES,
|
||||
"additionalProperties": False
|
||||
}
|
||||
|
||||
C3745_DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
C3745_DYNAMIPS_TEMPLATE_PROPERTIES = {
|
||||
"ram": {
|
||||
"description": "Amount of RAM in MB",
|
||||
"type": "integer",
|
||||
@@ -194,17 +194,17 @@ C3745_DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
}
|
||||
}
|
||||
|
||||
C3745_DYNAMIPS_APPLIANCE_PROPERTIES.update(DYNAMIPS_APPLIANCE_PROPERTIES)
|
||||
C3745_DYNAMIPS_TEMPLATE_PROPERTIES.update(DYNAMIPS_TEMPLATE_PROPERTIES)
|
||||
|
||||
C3745_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA = {
|
||||
C3745_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A c3745 Dynamips template object",
|
||||
"type": "object",
|
||||
"properties": C3745_DYNAMIPS_APPLIANCE_PROPERTIES,
|
||||
"properties": C3745_DYNAMIPS_TEMPLATE_PROPERTIES,
|
||||
"additionalProperties": False
|
||||
}
|
||||
|
||||
C3725_DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
C3725_DYNAMIPS_TEMPLATE_PROPERTIES = {
|
||||
"ram": {
|
||||
"description": "Amount of RAM in MB",
|
||||
"type": "integer",
|
||||
@@ -229,17 +229,17 @@ C3725_DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
}
|
||||
}
|
||||
|
||||
C3725_DYNAMIPS_APPLIANCE_PROPERTIES.update(DYNAMIPS_APPLIANCE_PROPERTIES)
|
||||
C3725_DYNAMIPS_TEMPLATE_PROPERTIES.update(DYNAMIPS_TEMPLATE_PROPERTIES)
|
||||
|
||||
C3725_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA = {
|
||||
C3725_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A c3725 Dynamips template object",
|
||||
"type": "object",
|
||||
"properties": C3725_DYNAMIPS_APPLIANCE_PROPERTIES,
|
||||
"properties": C3725_DYNAMIPS_TEMPLATE_PROPERTIES,
|
||||
"additionalProperties": False
|
||||
}
|
||||
|
||||
C3600_DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
C3600_DYNAMIPS_TEMPLATE_PROPERTIES = {
|
||||
"chassis": {
|
||||
"description": "Chassis type",
|
||||
"enum": ["3620", "3640", "3660"],
|
||||
@@ -270,18 +270,18 @@ C3600_DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
}
|
||||
}
|
||||
|
||||
C3600_DYNAMIPS_APPLIANCE_PROPERTIES.update(DYNAMIPS_APPLIANCE_PROPERTIES)
|
||||
C3600_DYNAMIPS_TEMPLATE_PROPERTIES.update(DYNAMIPS_TEMPLATE_PROPERTIES)
|
||||
|
||||
C3600_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA = {
|
||||
C3600_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A c3600 Dynamips template object",
|
||||
"type": "object",
|
||||
"properties": C3600_DYNAMIPS_APPLIANCE_PROPERTIES,
|
||||
"properties": C3600_DYNAMIPS_TEMPLATE_PROPERTIES,
|
||||
"required": ["chassis"],
|
||||
"additionalProperties": False
|
||||
}
|
||||
|
||||
C2691_DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
C2691_DYNAMIPS_TEMPLATE_PROPERTIES = {
|
||||
"ram": {
|
||||
"description": "Amount of RAM in MB",
|
||||
"type": "integer",
|
||||
@@ -306,17 +306,17 @@ C2691_DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
}
|
||||
}
|
||||
|
||||
C2691_DYNAMIPS_APPLIANCE_PROPERTIES.update(DYNAMIPS_APPLIANCE_PROPERTIES)
|
||||
C2691_DYNAMIPS_TEMPLATE_PROPERTIES.update(DYNAMIPS_TEMPLATE_PROPERTIES)
|
||||
|
||||
C2691_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA = {
|
||||
C2691_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A c2691 Dynamips template object",
|
||||
"type": "object",
|
||||
"properties": C2691_DYNAMIPS_APPLIANCE_PROPERTIES,
|
||||
"properties": C2691_DYNAMIPS_TEMPLATE_PROPERTIES,
|
||||
"additionalProperties": False
|
||||
}
|
||||
|
||||
C2600_DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
C2600_DYNAMIPS_TEMPLATE_PROPERTIES = {
|
||||
"chassis": {
|
||||
"description": "Chassis type",
|
||||
"enum": ["2610", "2620", "2610XM", "2620XM", "2650XM", "2621", "2611XM", "2621XM", "2651XM"],
|
||||
@@ -346,18 +346,18 @@ C2600_DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
}
|
||||
}
|
||||
|
||||
C2600_DYNAMIPS_APPLIANCE_PROPERTIES.update(DYNAMIPS_APPLIANCE_PROPERTIES)
|
||||
C2600_DYNAMIPS_TEMPLATE_PROPERTIES.update(DYNAMIPS_TEMPLATE_PROPERTIES)
|
||||
|
||||
C2600_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA = {
|
||||
C2600_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A c2600 Dynamips template object",
|
||||
"type": "object",
|
||||
"properties": C2600_DYNAMIPS_APPLIANCE_PROPERTIES,
|
||||
"properties": C2600_DYNAMIPS_TEMPLATE_PROPERTIES,
|
||||
"required": ["chassis"],
|
||||
"additionalProperties": False
|
||||
}
|
||||
|
||||
C1700_DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
C1700_DYNAMIPS_TEMPLATE_PROPERTIES = {
|
||||
"chassis": {
|
||||
"description": "Chassis type",
|
||||
"enum": ["1720", "1721", "1750", "1751", "1760"],
|
||||
@@ -387,13 +387,13 @@ C1700_DYNAMIPS_APPLIANCE_PROPERTIES = {
|
||||
}
|
||||
}
|
||||
|
||||
C1700_DYNAMIPS_APPLIANCE_PROPERTIES.update(DYNAMIPS_APPLIANCE_PROPERTIES)
|
||||
C1700_DYNAMIPS_TEMPLATE_PROPERTIES.update(DYNAMIPS_TEMPLATE_PROPERTIES)
|
||||
|
||||
C1700_DYNAMIPS_APPLIANCE_OBJECT_SCHEMA = {
|
||||
C1700_DYNAMIPS_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A c1700 Dynamips template object",
|
||||
"type": "object",
|
||||
"properties": C1700_DYNAMIPS_APPLIANCE_PROPERTIES,
|
||||
"properties": C1700_DYNAMIPS_TEMPLATE_PROPERTIES,
|
||||
"required": ["chassis"],
|
||||
"additionalProperties": False
|
||||
}
|
||||
+8
-8
@@ -16,10 +16,10 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import copy
|
||||
from .appliance import BASE_APPLIANCE_PROPERTIES
|
||||
from .template import BASE_TEMPLATE_PROPERTIES
|
||||
|
||||
|
||||
ETHERNET_HUB_APPLIANCE_PROPERTIES = {
|
||||
ETHERNET_HUB_TEMPLATE_PROPERTIES = {
|
||||
"ports_mapping": {
|
||||
"type": "array",
|
||||
"default": [{"port_number": 0,
|
||||
@@ -66,15 +66,15 @@ ETHERNET_HUB_APPLIANCE_PROPERTIES = {
|
||||
}
|
||||
}
|
||||
|
||||
ETHERNET_HUB_APPLIANCE_PROPERTIES.update(copy.deepcopy(BASE_APPLIANCE_PROPERTIES))
|
||||
ETHERNET_HUB_APPLIANCE_PROPERTIES["category"]["default"] = "switch"
|
||||
ETHERNET_HUB_APPLIANCE_PROPERTIES["default_name_format"]["default"] = "Hub{0}"
|
||||
ETHERNET_HUB_APPLIANCE_PROPERTIES["symbol"]["default"] = ":/symbols/hub.svg"
|
||||
ETHERNET_HUB_TEMPLATE_PROPERTIES.update(copy.deepcopy(BASE_TEMPLATE_PROPERTIES))
|
||||
ETHERNET_HUB_TEMPLATE_PROPERTIES["category"]["default"] = "switch"
|
||||
ETHERNET_HUB_TEMPLATE_PROPERTIES["default_name_format"]["default"] = "Hub{0}"
|
||||
ETHERNET_HUB_TEMPLATE_PROPERTIES["symbol"]["default"] = ":/symbols/hub.svg"
|
||||
|
||||
ETHERNET_HUB_APPLIANCE_OBJECT_SCHEMA = {
|
||||
ETHERNET_HUB_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "An Ethernet hub template object",
|
||||
"type": "object",
|
||||
"properties": ETHERNET_HUB_APPLIANCE_PROPERTIES,
|
||||
"properties": ETHERNET_HUB_TEMPLATE_PROPERTIES,
|
||||
"additionalProperties": False
|
||||
}
|
||||
+8
-8
@@ -16,10 +16,10 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import copy
|
||||
from .appliance import BASE_APPLIANCE_PROPERTIES
|
||||
from .template import BASE_TEMPLATE_PROPERTIES
|
||||
|
||||
|
||||
ETHERNET_SWITCH_APPLIANCE_PROPERTIES = {
|
||||
ETHERNET_SWITCH_TEMPLATE_PROPERTIES = {
|
||||
"ports_mapping": {
|
||||
"type": "array",
|
||||
"default": [{"ethertype": "",
|
||||
@@ -113,15 +113,15 @@ ETHERNET_SWITCH_APPLIANCE_PROPERTIES = {
|
||||
},
|
||||
}
|
||||
|
||||
ETHERNET_SWITCH_APPLIANCE_PROPERTIES.update(copy.deepcopy(BASE_APPLIANCE_PROPERTIES))
|
||||
ETHERNET_SWITCH_APPLIANCE_PROPERTIES["category"]["default"] = "switch"
|
||||
ETHERNET_SWITCH_APPLIANCE_PROPERTIES["default_name_format"]["default"] = "Switch{0}"
|
||||
ETHERNET_SWITCH_APPLIANCE_PROPERTIES["symbol"]["default"] = ":/symbols/ethernet_switch.svg"
|
||||
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_APPLIANCE_OBJECT_SCHEMA = {
|
||||
ETHERNET_SWITCH_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "An Ethernet switch template object",
|
||||
"type": "object",
|
||||
"properties": ETHERNET_SWITCH_APPLIANCE_PROPERTIES,
|
||||
"properties": ETHERNET_SWITCH_TEMPLATE_PROPERTIES,
|
||||
"additionalProperties": False
|
||||
}
|
||||
@@ -16,10 +16,10 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import copy
|
||||
from .appliance import BASE_APPLIANCE_PROPERTIES
|
||||
from .template import BASE_TEMPLATE_PROPERTIES
|
||||
|
||||
|
||||
IOU_APPLIANCE_PROPERTIES = {
|
||||
IOU_TEMPLATE_PROPERTIES = {
|
||||
"path": {
|
||||
"description": "Path of IOU executable",
|
||||
"type": "string",
|
||||
@@ -77,16 +77,16 @@ IOU_APPLIANCE_PROPERTIES = {
|
||||
},
|
||||
}
|
||||
|
||||
IOU_APPLIANCE_PROPERTIES.update(copy.deepcopy(BASE_APPLIANCE_PROPERTIES))
|
||||
IOU_APPLIANCE_PROPERTIES["category"]["default"] = "router"
|
||||
IOU_APPLIANCE_PROPERTIES["default_name_format"]["default"] = "IOU{0}"
|
||||
IOU_APPLIANCE_PROPERTIES["symbol"]["default"] = ":/symbols/multilayer_switch.svg"
|
||||
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_APPLIANCE_OBJECT_SCHEMA = {
|
||||
IOU_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A IOU template object",
|
||||
"type": "object",
|
||||
"properties": IOU_APPLIANCE_PROPERTIES,
|
||||
"properties": IOU_TEMPLATE_PROPERTIES,
|
||||
"required": ["path"],
|
||||
"additionalProperties": False
|
||||
}
|
||||
@@ -119,8 +119,8 @@ NODE_OBJECT_SCHEMA = {
|
||||
"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}$"
|
||||
},
|
||||
"appliance_id": {
|
||||
"description": "Appliance UUID from which the node has been created. Read only",
|
||||
"template_id": {
|
||||
"description": "Template UUID from which the node has been created. Read only",
|
||||
"type": ["null", "string"],
|
||||
"minLength": 36,
|
||||
"maxLength": 36,
|
||||
|
||||
@@ -16,12 +16,12 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import copy
|
||||
from .appliance import BASE_APPLIANCE_PROPERTIES
|
||||
from .template import BASE_TEMPLATE_PROPERTIES
|
||||
from .custom_adapters import CUSTOM_ADAPTERS_ARRAY_SCHEMA
|
||||
from .qemu import QEMU_PLATFORMS
|
||||
|
||||
|
||||
QEMU_APPLIANCE_PROPERTIES = {
|
||||
QEMU_TEMPLATE_PROPERTIES = {
|
||||
"usage": {
|
||||
"description": "How to use the Qemu VM",
|
||||
"type": "string",
|
||||
@@ -203,15 +203,15 @@ QEMU_APPLIANCE_PROPERTIES = {
|
||||
"custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA
|
||||
}
|
||||
|
||||
QEMU_APPLIANCE_PROPERTIES.update(copy.deepcopy(BASE_APPLIANCE_PROPERTIES))
|
||||
QEMU_APPLIANCE_PROPERTIES["category"]["default"] = "guest"
|
||||
QEMU_APPLIANCE_PROPERTIES["default_name_format"]["default"] = "{name}-{0}"
|
||||
QEMU_APPLIANCE_PROPERTIES["symbol"]["default"] = ":/symbols/qemu_guest.svg"
|
||||
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_APPLIANCE_OBJECT_SCHEMA = {
|
||||
QEMU_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A Qemu template object",
|
||||
"type": "object",
|
||||
"properties": QEMU_APPLIANCE_PROPERTIES,
|
||||
"properties": QEMU_TEMPLATE_PROPERTIES,
|
||||
"additionalProperties": False
|
||||
}
|
||||
@@ -17,21 +17,21 @@
|
||||
|
||||
import copy
|
||||
|
||||
BASE_APPLIANCE_PROPERTIES = {
|
||||
"appliance_id": {
|
||||
"description": "Appliance UUID from which the node has been created. Read only",
|
||||
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}$"
|
||||
},
|
||||
"appliance_type": {
|
||||
"template_type": {
|
||||
"description": "Type of node",
|
||||
"enum": ["cloud", "ethernet_hub", "ethernet_switch", "docker", "dynamips", "vpcs", "traceng",
|
||||
"virtualbox", "vmware", "iou", "qemu"]
|
||||
},
|
||||
"name": {
|
||||
"description": "Appliance name",
|
||||
"description": "Template name",
|
||||
"type": "string",
|
||||
"minLength": 1,
|
||||
},
|
||||
@@ -45,48 +45,48 @@ BASE_APPLIANCE_PROPERTIES = {
|
||||
"minLength": 1
|
||||
},
|
||||
"symbol": {
|
||||
"description": "Symbol of the appliance",
|
||||
"description": "Symbol of the template",
|
||||
"type": "string",
|
||||
"minLength": 1
|
||||
},
|
||||
"category": {
|
||||
"description": "Appliance category",
|
||||
"description": "Template category",
|
||||
"anyOf": [
|
||||
{"type": "integer"}, # old category support
|
||||
{"enum": ["router", "switch", "guest", "firewall"]}
|
||||
]
|
||||
},
|
||||
"builtin": {
|
||||
"description": "Appliance is builtin",
|
||||
"description": "Template is builtin",
|
||||
"type": "boolean"
|
||||
},
|
||||
}
|
||||
|
||||
APPLIANCE_OBJECT_SCHEMA = {
|
||||
TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A template object",
|
||||
"type": "object",
|
||||
"properties": BASE_APPLIANCE_PROPERTIES,
|
||||
"required": ["name", "appliance_type", "appliance_id", "category", "compute_id", "default_name_format", "symbol", "builtin"]
|
||||
"properties": BASE_TEMPLATE_PROPERTIES,
|
||||
"required": ["name", "template_type", "template_id", "category", "compute_id", "default_name_format", "symbol", "builtin"]
|
||||
}
|
||||
|
||||
APPLIANCE_CREATE_SCHEMA = copy.deepcopy(APPLIANCE_OBJECT_SCHEMA)
|
||||
TEMPLATE_CREATE_SCHEMA = copy.deepcopy(TEMPLATE_OBJECT_SCHEMA)
|
||||
|
||||
# create schema
|
||||
# these properties are not required to create an appliance
|
||||
APPLIANCE_CREATE_SCHEMA["required"].remove("appliance_id")
|
||||
APPLIANCE_CREATE_SCHEMA["required"].remove("category")
|
||||
APPLIANCE_CREATE_SCHEMA["required"].remove("default_name_format")
|
||||
APPLIANCE_CREATE_SCHEMA["required"].remove("symbol")
|
||||
APPLIANCE_CREATE_SCHEMA["required"].remove("builtin")
|
||||
# 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
|
||||
APPLIANCE_UPDATE_SCHEMA = copy.deepcopy(APPLIANCE_OBJECT_SCHEMA)
|
||||
del APPLIANCE_UPDATE_SCHEMA["required"]
|
||||
TEMPLATE_UPDATE_SCHEMA = copy.deepcopy(TEMPLATE_OBJECT_SCHEMA)
|
||||
del TEMPLATE_UPDATE_SCHEMA["required"]
|
||||
|
||||
APPLIANCE_USAGE_SCHEMA = {
|
||||
TEMPLATE_USAGE_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "Request validation to use an Appliance instance",
|
||||
"description": "Request validation to use a Template instance",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"x": {
|
||||
@@ -98,7 +98,7 @@ APPLIANCE_USAGE_SCHEMA = {
|
||||
"type": "integer"
|
||||
},
|
||||
"compute_id": {
|
||||
"description": "If the appliance don't have a default compute use this compute",
|
||||
"description": "If the template don't have a default compute use this compute",
|
||||
"type": ["null", "string"]
|
||||
}
|
||||
},
|
||||
@@ -16,10 +16,10 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import copy
|
||||
from .appliance import BASE_APPLIANCE_PROPERTIES
|
||||
from .template import BASE_TEMPLATE_PROPERTIES
|
||||
|
||||
|
||||
TRACENG_APPLIANCE_PROPERTIES = {
|
||||
TRACENG_TEMPLATE_PROPERTIES = {
|
||||
"ip_address": {
|
||||
"description": "Source IP address for tracing",
|
||||
"type": ["string"],
|
||||
@@ -37,15 +37,15 @@ TRACENG_APPLIANCE_PROPERTIES = {
|
||||
},
|
||||
}
|
||||
|
||||
TRACENG_APPLIANCE_PROPERTIES.update(copy.deepcopy(BASE_APPLIANCE_PROPERTIES))
|
||||
TRACENG_APPLIANCE_PROPERTIES["category"]["default"] = "guest"
|
||||
TRACENG_APPLIANCE_PROPERTIES["default_name_format"]["default"] = "TraceNG{0}"
|
||||
TRACENG_APPLIANCE_PROPERTIES["symbol"]["default"] = ":/symbols/traceng.svg"
|
||||
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_APPLIANCE_OBJECT_SCHEMA = {
|
||||
TRACENG_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A TraceNG template object",
|
||||
"type": "object",
|
||||
"properties": TRACENG_APPLIANCE_PROPERTIES,
|
||||
"properties": TRACENG_TEMPLATE_PROPERTIES,
|
||||
"additionalProperties": False
|
||||
}
|
||||
+8
-8
@@ -16,11 +16,11 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import copy
|
||||
from .appliance import BASE_APPLIANCE_PROPERTIES
|
||||
from .template import BASE_TEMPLATE_PROPERTIES
|
||||
from .custom_adapters import CUSTOM_ADAPTERS_ARRAY_SCHEMA
|
||||
|
||||
|
||||
VIRTUALBOX_APPLIANCE_PROPERTIES = {
|
||||
VIRTUALBOX_TEMPLATE_PROPERTIES = {
|
||||
"vmname": {
|
||||
"description": "VirtualBox VM name (in VirtualBox itself)",
|
||||
"type": "string",
|
||||
@@ -98,16 +98,16 @@ VIRTUALBOX_APPLIANCE_PROPERTIES = {
|
||||
"custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA
|
||||
}
|
||||
|
||||
VIRTUALBOX_APPLIANCE_PROPERTIES.update(copy.deepcopy(BASE_APPLIANCE_PROPERTIES))
|
||||
VIRTUALBOX_APPLIANCE_PROPERTIES["category"]["default"] = "guest"
|
||||
VIRTUALBOX_APPLIANCE_PROPERTIES["default_name_format"]["default"] = "{name}-{0}"
|
||||
VIRTUALBOX_APPLIANCE_PROPERTIES["symbol"]["default"] = ":/symbols/vbox_guest.svg"
|
||||
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_APPLIANCE_OBJECT_SCHEMA = {
|
||||
VIRTUALBOX_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A VirtualBox template object",
|
||||
"type": "object",
|
||||
"properties": VIRTUALBOX_APPLIANCE_PROPERTIES,
|
||||
"properties": VIRTUALBOX_TEMPLATE_PROPERTIES,
|
||||
"required": ["vmname"],
|
||||
"additionalProperties": False
|
||||
}
|
||||
@@ -16,11 +16,11 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import copy
|
||||
from .appliance import BASE_APPLIANCE_PROPERTIES
|
||||
from .template import BASE_TEMPLATE_PROPERTIES
|
||||
from .custom_adapters import CUSTOM_ADAPTERS_ARRAY_SCHEMA
|
||||
|
||||
|
||||
VMWARE_APPLIANCE_PROPERTIES = {
|
||||
VMWARE_TEMPLATE_PROPERTIES = {
|
||||
"vmx_path": {
|
||||
"description": "Path to the vmx file",
|
||||
"type": "string",
|
||||
@@ -86,16 +86,16 @@ VMWARE_APPLIANCE_PROPERTIES = {
|
||||
"custom_adapters": CUSTOM_ADAPTERS_ARRAY_SCHEMA
|
||||
}
|
||||
|
||||
VMWARE_APPLIANCE_PROPERTIES.update(copy.deepcopy(BASE_APPLIANCE_PROPERTIES))
|
||||
VMWARE_APPLIANCE_PROPERTIES["category"]["default"] = "guest"
|
||||
VMWARE_APPLIANCE_PROPERTIES["default_name_format"]["default"] = "{name}-{0}"
|
||||
VMWARE_APPLIANCE_PROPERTIES["symbol"]["default"] = ":/symbols/vmware_guest.svg"
|
||||
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_APPLIANCE_OBJECT_SCHEMA = {
|
||||
VMWARE_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A VMware template object",
|
||||
"type": "object",
|
||||
"properties": VMWARE_APPLIANCE_PROPERTIES,
|
||||
"properties": VMWARE_TEMPLATE_PROPERTIES,
|
||||
"required": ["vmx_path"],
|
||||
"additionalProperties": False
|
||||
}
|
||||
@@ -16,10 +16,10 @@
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
import copy
|
||||
from .appliance import BASE_APPLIANCE_PROPERTIES
|
||||
from .template import BASE_TEMPLATE_PROPERTIES
|
||||
|
||||
|
||||
VPCS_APPLIANCE_PROPERTIES = {
|
||||
VPCS_TEMPLATE_PROPERTIES = {
|
||||
"base_script_file": {
|
||||
"description": "Script file",
|
||||
"type": "string",
|
||||
@@ -38,15 +38,15 @@ VPCS_APPLIANCE_PROPERTIES = {
|
||||
},
|
||||
}
|
||||
|
||||
VPCS_APPLIANCE_PROPERTIES.update(copy.deepcopy(BASE_APPLIANCE_PROPERTIES))
|
||||
VPCS_APPLIANCE_PROPERTIES["category"]["default"] = "guest"
|
||||
VPCS_APPLIANCE_PROPERTIES["default_name_format"]["default"] = "PC{0}"
|
||||
VPCS_APPLIANCE_PROPERTIES["symbol"]["default"] = ":/symbols/vpcs_guest.svg"
|
||||
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_APPLIANCE_OBJECT_SCHEMA = {
|
||||
VPCS_TEMPLATE_OBJECT_SCHEMA = {
|
||||
"$schema": "http://json-schema.org/draft-04/schema#",
|
||||
"description": "A VPCS template object",
|
||||
"type": "object",
|
||||
"properties": VPCS_APPLIANCE_PROPERTIES,
|
||||
"properties": VPCS_TEMPLATE_PROPERTIES,
|
||||
"additionalProperties": False
|
||||
}
|
||||
Reference in new issue
Block a user