From 3fd86f5807ccffba4bef6f614cf4685eedc63b45 Mon Sep 17 00:00:00 2001
From: ziajka <dominik.ziajka@gmail.com>
Date: Tue, 8 Aug 2017 13:58:43 +0200
Subject: [PATCH] Return platform value on appliances list (Fixes #2211)

---
 gns3server/controller/appliance.py |  4 +++-
 tests/controller/test_appliance.py | 35 ++++++++++++++++++++++++++----
 2 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/gns3server/controller/appliance.py b/gns3server/controller/appliance.py
index 2d9986ef..6b0b97f3 100644
--- a/gns3server/controller/appliance.py
+++ b/gns3server/controller/appliance.py
@@ -77,6 +77,7 @@ class Appliance:
             category = ID_TO_CATEGORY[self._data["category"]]
         except KeyError:
             category = self._data["category"]
+
         return {
             "appliance_id": self._id,
             "node_type": self._data["node_type"],
@@ -85,5 +86,6 @@ class Appliance:
             "category": category,
             "symbol": self._data.get("symbol", ":/symbols/computer.svg"),
             "compute_id": self.compute_id,
-            "builtin": self._builtin
+            "builtin": self._builtin,
+            "platform": self._data.get("platform", None)
         }
diff --git a/tests/controller/test_appliance.py b/tests/controller/test_appliance.py
index 3ed325a0..810ea5e3 100644
--- a/tests/controller/test_appliance.py
+++ b/tests/controller/test_appliance.py
@@ -25,7 +25,8 @@ def test_appliance_json():
         "default_name_format": "{name}-{0}",
         "category": 0,
         "symbol": "qemu.svg",
-        "server": "local"
+        "server": "local",
+        "platform": None
     })
     assert a.__json__() == {
         "appliance_id": a.id,
@@ -35,7 +36,8 @@ def test_appliance_json():
         "default_name_format": "{name}-{0}",
         "category": "router",
         "symbol": "qemu.svg",
-        "compute_id": "local"
+        "compute_id": "local",
+        "platform": None
     }
 
 
@@ -46,7 +48,8 @@ def test_appliance_json_with_not_known_category():
         "default_name_format": "{name}-{0}",
         "category": 'Not known',
         "symbol": "qemu.svg",
-        "server": "local"
+        "server": "local",
+        "platform": None
     })
     assert a.__json__() == {
         "appliance_id": a.id,
@@ -56,7 +59,31 @@ def test_appliance_json_with_not_known_category():
         "default_name_format": "{name}-{0}",
         "category": "Not known",
         "symbol": "qemu.svg",
-        "compute_id": "local"
+        "compute_id": "local",
+        "platform": None
+    }
+
+
+def test_appliance_json_with_platform():
+    a = Appliance(None, {
+        "node_type": "dynamips",
+        "name": "Test",
+        "default_name_format": "{name}-{0}",
+        "category": 0,
+        "symbol": "dynamips.svg",
+        "server": "local",
+        "platform": "c3725"
+    })
+    assert a.__json__() == {
+        "appliance_id": a.id,
+        "node_type": "dynamips",
+        "builtin": False,
+        "name": "Test",
+        "default_name_format": "{name}-{0}",
+        "category": "router",
+        "symbol": "dynamips.svg",
+        "compute_id": "local",
+        "platform": "c3725"
     }