From 05191311735575e461bf28628f579c6d227d5f77 Mon Sep 17 00:00:00 2001 From: Benjamin Bertrand <benjamin.bertrand@esss.se> Date: Fri, 28 Sep 2018 11:35:36 +0200 Subject: [PATCH] Display hosts with no interface JIRA INFRA-569 #action In Progress --- app/network/views.py | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/app/network/views.py b/app/network/views.py index 26e691e..f917f1f 100644 --- a/app/network/views.py +++ b/app/network/views.py @@ -473,18 +473,24 @@ def create_scope(): @bp.route("/_retrieve_hosts") @login_required def retrieve_hosts(): - data = [ - ( - host.name, - str(host.device_type), - host.description, - interface.name, - interface.ip, - str(interface.network), - ) - for host in models.Host.query.all() - for interface in host.interfaces - ] + data = [] + for host in models.Host.query.all(): + if host.interfaces: + for interface in host.interfaces: + data.append( + ( + host.name, + str(host.device_type), + host.description, + interface.name, + interface.ip, + str(interface.network), + ) + ) + else: + data.append( + (host.name, str(host.device_type), host.description, "", "", "") + ) return jsonify(data=data) -- GitLab