1
0
mirror of https://github.com/GNS3/gns3-server synced 2024-11-28 11:18:11 +00:00

Fix error when appliance template is broken (missing fields). Fixes #1287.

This commit is contained in:
grossmj 2018-02-06 16:07:23 +08:00
parent abbe3d3a31
commit fff593b358

View File

@ -82,7 +82,8 @@ class Controller:
if appliance.status != 'broken':
self._appliance_templates[appliance.id] = appliance
except (ValueError, OSError, KeyError) as e:
log.warning("Can't load %s: %s", path, str(e))
log.warning("Cannot load appliance template file '%s': %s", path, str(e))
continue
self._appliances = {}
vms = []
@ -125,10 +126,11 @@ class Controller:
vm.setdefault("appliance_id", str(uuid.uuid4()))
try:
appliance = Appliance(vm["appliance_id"], vm)
appliance.__json__() # Check if loaded without error
self._appliances[appliance.id] = appliance
except KeyError as e:
# appliance data is not complete (missing name or type)
log.warning("Could not load appliance template {} ('{}'): {}".format(vm["appliance_id"], vm.get("name", "unknown"), e))
log.warning("Cannot load appliance template {} ('{}'): missing key {}".format(vm["appliance_id"], vm.get("name", "unknown"), e))
continue
# Add builtins