1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 03:08:14 +00:00

Support the options use_default_iou_values

Fix #92
This commit is contained in:
Julien Duponchelle 2015-03-07 14:27:09 +01:00
parent d126db1fe9
commit ed2e4e43f2
4 changed files with 23 additions and 4 deletions

View File

@ -205,7 +205,8 @@ class IOUVM(BaseVM):
"ram": self._ram, "ram": self._ram,
"nvram": self._nvram, "nvram": self._nvram,
"l1_keepalives": self._l1_keepalives, "l1_keepalives": self._l1_keepalives,
"initial_config": self.relative_initial_config_file "initial_config": self.relative_initial_config_file,
"use_default_iou_values": self._use_default_iou_values
} }
@property @property

View File

@ -66,6 +66,10 @@ IOU_CREATE_SCHEMA = {
"description": "Always up ethernet interface", "description": "Always up ethernet interface",
"type": ["boolean", "null"] "type": ["boolean", "null"]
}, },
"use_default_iou_values": {
"description": "Use default IOU values",
"type": ["boolean", "null"]
},
"initial_config_content": { "initial_config_content": {
"description": "Initial configuration of the IOU", "description": "Initial configuration of the IOU",
"type": ["string", "null"] "type": ["string", "null"]
@ -118,6 +122,10 @@ IOU_UPDATE_SCHEMA = {
"initial_config_content": { "initial_config_content": {
"description": "Initial configuration of the IOU", "description": "Initial configuration of the IOU",
"type": ["string", "null"] "type": ["string", "null"]
},
"use_default_iou_values": {
"description": "Use default IOU values",
"type": ["boolean", "null"]
} }
}, },
"additionalProperties": False, "additionalProperties": False,
@ -180,10 +188,14 @@ IOU_OBJECT_SCHEMA = {
"initial_config": { "initial_config": {
"description": "Path of the initial config content relative to project directory", "description": "Path of the initial config content relative to project directory",
"type": ["string", "null"] "type": ["string", "null"]
},
"use_default_iou_values": {
"description": "Use default IOU values",
"type": ["boolean", "null"]
} }
}, },
"additionalProperties": False, "additionalProperties": False,
"required": ["name", "vm_id", "console", "project_id", "path", "serial_adapters", "ethernet_adapters", "ram", "nvram", "l1_keepalives", "initial_config"] "required": ["name", "vm_id", "console", "project_id", "path", "serial_adapters", "ethernet_adapters", "ram", "nvram", "l1_keepalives", "initial_config", "use_default_iou_values"]
} }
IOU_NIO_SCHEMA = { IOU_NIO_SCHEMA = {

View File

@ -74,6 +74,7 @@ def test_iou_create_with_params(server, project, base_params):
params["ethernet_adapters"] = 0 params["ethernet_adapters"] = 0
params["l1_keepalives"] = True params["l1_keepalives"] = True
params["initial_config_content"] = "hostname test" params["initial_config_content"] = "hostname test"
params["use_default_iou_values"] = True
response = server.post("/projects/{project_id}/iou/vms".format(project_id=project.id), params, example=True) response = server.post("/projects/{project_id}/iou/vms".format(project_id=project.id), params, example=True)
assert response.status == 201 assert response.status == 201
@ -85,6 +86,8 @@ def test_iou_create_with_params(server, project, base_params):
assert response.json["ram"] == 1024 assert response.json["ram"] == 1024
assert response.json["nvram"] == 512 assert response.json["nvram"] == 512
assert response.json["l1_keepalives"] is True assert response.json["l1_keepalives"] is True
assert response.json["use_default_iou_values"] is True
assert "initial-config.cfg" in response.json["initial_config"] assert "initial-config.cfg" in response.json["initial_config"]
with open(initial_config_file(project, response.json)) as f: with open(initial_config_file(project, response.json)) as f:
assert f.read() == params["initial_config_content"] assert f.read() == params["initial_config_content"]
@ -140,7 +143,8 @@ def test_iou_update(server, vm, tmpdir, free_console_port, project):
"ethernet_adapters": 4, "ethernet_adapters": 4,
"serial_adapters": 0, "serial_adapters": 0,
"l1_keepalives": True, "l1_keepalives": True,
"initial_config_content": "hostname test" "initial_config_content": "hostname test",
"use_default_iou_values": True
} }
response = server.put("/projects/{project_id}/iou/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), params, example=True) response = server.put("/projects/{project_id}/iou/vms/{vm_id}".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), params, example=True)
assert response.status == 200 assert response.status == 200
@ -151,6 +155,7 @@ def test_iou_update(server, vm, tmpdir, free_console_port, project):
assert response.json["ram"] == 512 assert response.json["ram"] == 512
assert response.json["nvram"] == 2048 assert response.json["nvram"] == 2048
assert response.json["l1_keepalives"] is True assert response.json["l1_keepalives"] is True
assert response.json["use_default_iou_values"] is True
assert "initial-config.cfg" in response.json["initial_config"] assert "initial-config.cfg" in response.json["initial_config"]
with open(initial_config_file(project, response.json)) as f: with open(initial_config_file(project, response.json)) as f:
assert f.read() == "hostname test" assert f.read() == "hostname test"

View File

@ -36,12 +36,13 @@ def test_upload(server, tmpdir):
with open(str(tmpdir / "test"), "w+") as f: with open(str(tmpdir / "test"), "w+") as f:
f.write("TEST") f.write("TEST")
body = aiohttp.FormData() body = aiohttp.FormData()
body.add_field("type", "QEMU")
body.add_field("file", open(str(tmpdir / "test"), "rb"), content_type="application/iou", filename="test2") body.add_field("file", open(str(tmpdir / "test"), "rb"), content_type="application/iou", filename="test2")
with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}): with patch("gns3server.config.Config.get_section_config", return_value={"images_path": str(tmpdir)}):
response = server.post('/upload', api_version=None, body=body, raw=True) response = server.post('/upload', api_version=None, body=body, raw=True)
with open(str(tmpdir / "test2")) as f: with open(str(tmpdir / "QEMU" / "test2")) as f:
assert f.read() == "TEST" assert f.read() == "TEST"
assert "test2" in response.body.decode("utf-8") assert "test2" in response.body.decode("utf-8")