diff --git a/gns3server/handlers/api/iou_handler.py b/gns3server/handlers/api/iou_handler.py index 5e076c4e..edebae1b 100644 --- a/gns3server/handlers/api/iou_handler.py +++ b/gns3server/handlers/api/iou_handler.py @@ -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) diff --git a/gns3server/modules/iou/iou_vm.py b/gns3server/modules/iou/iou_vm.py index 7323b9d7..68a880f6 100644 --- a/gns3server/modules/iou/iou_vm.py +++ b/gns3server/modules/iou/iou_vm.py @@ -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: diff --git a/gns3server/schemas/iou.py b/gns3server/schemas/iou.py index 83f8fd7f..5793488a 100644 --- a/gns3server/schemas/iou.py +++ b/gns3server/schemas/iou.py @@ -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, diff --git a/tests/handlers/api/test_iou.py b/tests/handlers/api/test_iou.py index bae3076d..bc0f8da9 100644 --- a/tests/handlers/api/test_iou.py +++ b/tests/handlers/api/test_iou.py @@ -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",