Support IOURC update

This commit is contained in:
Julien Duponchelle 2015-03-17 19:00:14 +01:00
parent 8ca9c2121a
commit 4a9f578784
4 changed files with 10 additions and 2 deletions

View File

@ -117,6 +117,7 @@ class IOUHandler:
vm.nvram = request.json.get("nvram", vm.nvram)
vm.l1_keepalives = request.json.get("l1_keepalives", vm.l1_keepalives)
vm.initial_config = request.json.get("initial_config_content", vm.initial_config)
vm.iourc_content = request.json.get("iourc_content", None)
response.json(vm)

View File

@ -393,7 +393,7 @@ class IOUVM(BaseVM):
# We can't test this because it's mean distributing a valid licence key
# in tests or generating one
if not sys._called_from_test:
if not hasattr(sys, "_called_from_test"):
try:
hostid = (yield from gns3server.utils.asyncio.subprocess_check_output("hostid")).strip()
except FileNotFoundError as e:

View File

@ -130,6 +130,10 @@ IOU_UPDATE_SCHEMA = {
"use_default_iou_values": {
"description": "Use default IOU values",
"type": ["boolean", "null"]
},
"iourc_content": {
"description": "Content of the iourc file, if a file exist on servers this variable is ignored. It's mostly for compatibility with < 1.3 releases",
"type": ["string", "null"]
}
},
"additionalProperties": False,

View File

@ -147,7 +147,8 @@ def test_iou_update(server, vm, tmpdir, free_console_port, project):
"serial_adapters": 0,
"l1_keepalives": True,
"initial_config_content": "hostname test",
"use_default_iou_values": True
"use_default_iou_values": True,
"iourc_content": "test"
}
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
@ -163,6 +164,8 @@ def test_iou_update(server, vm, tmpdir, free_console_port, project):
with open(initial_config_file(project, response.json)) as f:
assert f.read() == "hostname test"
assert "iourc" in response.json["iourc_path"]
def test_iou_nio_create_udp(server, vm):
response = server.post("/projects/{project_id}/iou/vms/{vm_id}/adapters/1/ports/0/nio".format(project_id=vm["project_id"], vm_id=vm["vm_id"]), {"type": "nio_udp",