mirror of
https://github.com/GNS3/gns3-server
synced 2024-12-25 00:08:11 +00:00
Fix bad execption name in IOU
This commit is contained in:
parent
78ffe313fd
commit
605afa1d33
@ -848,7 +848,7 @@ class IOUVM(BaseVM):
|
|||||||
with open(config_file) as f:
|
with open(config_file) as f:
|
||||||
return f.read()
|
return f.read()
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise VPCSError("Can't read configuration file '{}'".format(config_file))
|
raise IOUError("Can't read configuration file '{}'".format(config_file))
|
||||||
|
|
||||||
@initial_config.setter
|
@initial_config.setter
|
||||||
def initial_config(self, initial_config):
|
def initial_config(self, initial_config):
|
||||||
@ -867,7 +867,7 @@ class IOUVM(BaseVM):
|
|||||||
initial_config = initial_config.replace("%h", self._name)
|
initial_config = initial_config.replace("%h", self._name)
|
||||||
f.write(initial_config)
|
f.write(initial_config)
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
raise VPCSError("Can't write initial configuration file '{}'".format(self.script_file))
|
raise IOUError("Can't write initial configuration file '{}'".format(self.script_file))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def initial_config_file(self):
|
def initial_config_file(self):
|
||||||
|
@ -49,6 +49,7 @@ def vm(server, project, base_params):
|
|||||||
def initial_config_file(project, vm):
|
def initial_config_file(project, vm):
|
||||||
return os.path.join(project.path, "project-files", "iou", vm["vm_id"], "initial-config.cfg")
|
return os.path.join(project.path, "project-files", "iou", vm["vm_id"], "initial-config.cfg")
|
||||||
|
|
||||||
|
|
||||||
def test_iou_create(server, project, base_params):
|
def test_iou_create(server, project, base_params):
|
||||||
response = server.post("/projects/{project_id}/iou/vms".format(project_id=project.id), base_params)
|
response = server.post("/projects/{project_id}/iou/vms".format(project_id=project.id), base_params)
|
||||||
assert response.status == 201
|
assert response.status == 201
|
||||||
@ -59,7 +60,7 @@ def test_iou_create(server, project, base_params):
|
|||||||
assert response.json["ethernet_adapters"] == 2
|
assert response.json["ethernet_adapters"] == 2
|
||||||
assert response.json["ram"] == 256
|
assert response.json["ram"] == 256
|
||||||
assert response.json["nvram"] == 128
|
assert response.json["nvram"] == 128
|
||||||
assert response.json["l1_keepalives"] == False
|
assert response.json["l1_keepalives"] is False
|
||||||
|
|
||||||
|
|
||||||
def test_iou_create_with_params(server, project, base_params):
|
def test_iou_create_with_params(server, project, base_params):
|
||||||
@ -80,7 +81,7 @@ def test_iou_create_with_params(server, project, base_params):
|
|||||||
assert response.json["ethernet_adapters"] == 0
|
assert response.json["ethernet_adapters"] == 0
|
||||||
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"] == True
|
assert response.json["l1_keepalives"] is True
|
||||||
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"]
|
assert f.read() == params["initial_config"]
|
||||||
|
|
||||||
@ -95,7 +96,7 @@ def test_iou_get(server, project, vm):
|
|||||||
assert response.json["ethernet_adapters"] == 2
|
assert response.json["ethernet_adapters"] == 2
|
||||||
assert response.json["ram"] == 256
|
assert response.json["ram"] == 256
|
||||||
assert response.json["nvram"] == 128
|
assert response.json["nvram"] == 128
|
||||||
assert response.json["l1_keepalives"] == False
|
assert response.json["l1_keepalives"] is False
|
||||||
|
|
||||||
|
|
||||||
def test_iou_start(server, vm):
|
def test_iou_start(server, vm):
|
||||||
@ -145,10 +146,11 @@ def test_iou_update(server, vm, tmpdir, free_console_port, project):
|
|||||||
assert response.json["serial_adapters"] == 0
|
assert response.json["serial_adapters"] == 0
|
||||||
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"] == True
|
assert response.json["l1_keepalives"] is True
|
||||||
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"
|
||||||
|
|
||||||
|
|
||||||
def test_iou_nio_create_udp(server, vm):
|
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",
|
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",
|
||||||
"lport": 4242,
|
"lport": 4242,
|
||||||
|
@ -75,6 +75,7 @@ def test_vm_initial_config(project, manager):
|
|||||||
assert vm.initial_config == "hostname test"
|
assert vm.initial_config == "hostname test"
|
||||||
assert vm.id == "00010203-0405-0607-0808-0a0b0c0d0e0f"
|
assert vm.id == "00010203-0405-0607-0808-0a0b0c0d0e0f"
|
||||||
|
|
||||||
|
|
||||||
@patch("gns3server.config.Config.get_section_config", return_value={"iouyap_path": "/bin/test_fake"})
|
@patch("gns3server.config.Config.get_section_config", return_value={"iouyap_path": "/bin/test_fake"})
|
||||||
def test_vm_invalid_iouyap_path(project, manager, loop):
|
def test_vm_invalid_iouyap_path(project, manager, loop):
|
||||||
with pytest.raises(IOUError):
|
with pytest.raises(IOUError):
|
||||||
|
Loading…
Reference in New Issue
Block a user