mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 11:18:11 +00:00
Validation schema for qemu-img
This commit is contained in:
parent
1eecae2027
commit
78ef6e3032
@ -27,6 +27,7 @@ from ...schemas.qemu import QEMU_UPDATE_SCHEMA
|
||||
from ...schemas.qemu import QEMU_OBJECT_SCHEMA
|
||||
from ...schemas.qemu import QEMU_BINARY_LIST_SCHEMA
|
||||
from ...schemas.qemu import QEMU_LIST_IMAGES_SCHEMA
|
||||
from ...schemas.qemu import QEMU_IMAGE_CREATE_SCHEMA
|
||||
from ...modules.qemu import Qemu
|
||||
from ...config import Config
|
||||
|
||||
@ -325,7 +326,8 @@ class QEMUHandler:
|
||||
status_codes={
|
||||
201: "Image created",
|
||||
},
|
||||
description="Create a Qemu image"
|
||||
description="Create a Qemu image",
|
||||
input=QEMU_IMAGE_CREATE_SCHEMA
|
||||
)
|
||||
def create_img(request, response):
|
||||
|
||||
|
@ -484,10 +484,74 @@ QEMU_LIST_IMAGES_SCHEMA = {
|
||||
"properties": {
|
||||
"filename": {
|
||||
"description": "Image filename",
|
||||
"type": ["string"]
|
||||
"type": "string"
|
||||
},
|
||||
},
|
||||
"additionalProperties": False
|
||||
}
|
||||
],
|
||||
"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 informations.",
|
||||
"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 M",
|
||||
"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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user