1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-15 12:59:06 +00:00

Fix bad execption name in IOU

This commit is contained in:
Julien Duponchelle 2015-02-16 10:05:17 +01:00
parent 78ffe313fd
commit 605afa1d33
3 changed files with 13 additions and 10 deletions

View File

@ -848,7 +848,7 @@ class IOUVM(BaseVM):
with open(config_file) as f:
return f.read()
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
def initial_config(self, initial_config):
@ -867,7 +867,7 @@ class IOUVM(BaseVM):
initial_config = initial_config.replace("%h", self._name)
f.write(initial_config)
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
def initial_config_file(self):

View File

@ -49,6 +49,7 @@ def vm(server, project, base_params):
def initial_config_file(project, vm):
return os.path.join(project.path, "project-files", "iou", vm["vm_id"], "initial-config.cfg")
def test_iou_create(server, project, base_params):
response = server.post("/projects/{project_id}/iou/vms".format(project_id=project.id), base_params)
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["ram"] == 256
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):
@ -80,7 +81,7 @@ def test_iou_create_with_params(server, project, base_params):
assert response.json["ethernet_adapters"] == 0
assert response.json["ram"] == 1024
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:
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["ram"] == 256
assert response.json["nvram"] == 128
assert response.json["l1_keepalives"] == False
assert response.json["l1_keepalives"] is False
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["ram"] == 512
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:
assert f.read() == "hostname test"
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",
"lport": 4242,

View File

@ -70,10 +70,11 @@ def test_vm(project, manager):
def test_vm_initial_config(project, manager):
vm = IOUVM("test", "00010203-0405-0607-0808-0a0b0c0d0e0f", project, manager, initial_config="hostname %h")
assert vm.name == "test"
assert vm.initial_config == "hostname test"
assert vm.id == "00010203-0405-0607-0808-0a0b0c0d0e0f"
vm = IOUVM("test", "00010203-0405-0607-0808-0a0b0c0d0e0f", project, manager, initial_config="hostname %h")
assert vm.name == "test"
assert vm.initial_config == "hostname test"
assert vm.id == "00010203-0405-0607-0808-0a0b0c0d0e0f"
@patch("gns3server.config.Config.get_section_config", return_value={"iouyap_path": "/bin/test_fake"})
def test_vm_invalid_iouyap_path(project, manager, loop):