From fff593b358286b9def00be779cd25f05123e2c65 Mon Sep 17 00:00:00 2001 From: grossmj Date: Tue, 6 Feb 2018 16:07:23 +0800 Subject: [PATCH] Fix error when appliance template is broken (missing fields). Fixes #1287. --- gns3server/controller/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gns3server/controller/__init__.py b/gns3server/controller/__init__.py index b49af36f..354d4a78 100644 --- a/gns3server/controller/__init__.py +++ b/gns3server/controller/__init__.py @@ -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