mirror of
https://github.com/GNS3/gns3-server
synced 2024-11-28 03:08:14 +00:00
parent
2eead38cd8
commit
6996b7094f
@ -78,10 +78,11 @@ class Controller:
|
|||||||
try:
|
try:
|
||||||
with open(path, 'r', encoding='utf-8') as f:
|
with open(path, 'r', encoding='utf-8') as f:
|
||||||
appliance = ApplianceTemplate(appliance_id, json.load(f), builtin=builtin)
|
appliance = ApplianceTemplate(appliance_id, json.load(f), builtin=builtin)
|
||||||
except (ValueError, OSError) as e:
|
appliance.__json__() # Check if loaded without error
|
||||||
log.warning("Can't load %s: %s", path, str(e))
|
|
||||||
if appliance.status != 'broken':
|
if appliance.status != 'broken':
|
||||||
self._appliance_templates[appliance.id] = appliance
|
self._appliance_templates[appliance.id] = appliance
|
||||||
|
except (ValueError, OSError, KeyError) as e:
|
||||||
|
log.warning("Can't load %s: %s", path, str(e))
|
||||||
|
|
||||||
self._appliances = {}
|
self._appliances = {}
|
||||||
vms = []
|
vms = []
|
||||||
|
@ -481,6 +481,12 @@ def test_appliance_templates(controller, async_run, tmpdir):
|
|||||||
}
|
}
|
||||||
with open(str(tmpdir / "my_appliance.gns3a"), 'w+') as f:
|
with open(str(tmpdir / "my_appliance.gns3a"), 'w+') as f:
|
||||||
json.dump(my_appliance, f)
|
json.dump(my_appliance, f)
|
||||||
|
# A broken appliance
|
||||||
|
my_appliance = {
|
||||||
|
"name": "Broken"
|
||||||
|
}
|
||||||
|
with open(str(tmpdir / "my_appliance2.gns3a"), 'w+') as f:
|
||||||
|
json.dump(my_appliance, f)
|
||||||
|
|
||||||
with patch("gns3server.config.Config.get_section_config", return_value={"appliances_path": str(tmpdir)}):
|
with patch("gns3server.config.Config.get_section_config", return_value={"appliances_path": str(tmpdir)}):
|
||||||
controller.load_appliances()
|
controller.load_appliances()
|
||||||
|
Loading…
Reference in New Issue
Block a user