From 8066409cdad0e026d2b14130f54bd55c2e3ad181 Mon Sep 17 00:00:00 2001 From: Pierre Riteau Date: Tue, 14 Nov 2017 15:52:36 +0000 Subject: [PATCH] Fix display of host details when cpu_info is empty If a Blazar host was created with an empty cpu_info value, displaying host details would fail with the error: SyntaxError: unexpected EOF while parsing (, line 0) This is because calling eval() on an empty string raises a SyntaxError. This patch ensures that if cpu_info is empty, it is set to an empty dictionary instead. Change-Id: I38d9f92fd7937de4ec1492d06ddea834b6c423ef --- blazar_dashboard/api/client.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/blazar_dashboard/api/client.py b/blazar_dashboard/api/client.py index e35a35a..be57fe3 100644 --- a/blazar_dashboard/api/client.py +++ b/blazar_dashboard/api/client.py @@ -51,7 +51,10 @@ class Host(base.APIDictWrapper): super(Host, self).__init__(apiresource) def cpu_info_dict(self): - return eval(getattr(self, 'cpu_info', "")) + cpu_info_dict = getattr(self, 'cpu_info', '{}') + if not cpu_info_dict: + cpu_info_dict = '{}' + return eval(cpu_info_dict) def extra_capabilities(self): excaps = {}