From d3039ea9cb87844fd7e481fcd1419b9ddb00617c Mon Sep 17 00:00:00 2001 From: Alexander Tivelkov Date: Tue, 29 Nov 2016 13:49:00 +0300 Subject: [PATCH] Fixed output of lists in topology viewer Topology viewers treated lists of values as "container" properties, even if these lists contained atomic values. So these values were missing from topology viewer diagram. This patch introduces the pre-processing of item data in topology viewer, which detects list of atomic values and replaces them with comma-separated strings joining all the values of the list. Among others this fixes an issue when ip addresses of the virtual machine were not displayed in topology viewer. Change-Id: I60d4a399b2068e861df42a71228233b0db9ec821 Closes-bug: #1645668 --- muranodashboard/environments/topology.py | 9 +++++++++ .../notes/ips-display-topology-5a45876dafc637eb.yaml | 4 ++++ 2 files changed, 13 insertions(+) create mode 100644 releasenotes/notes/ips-display-topology-5a45876dafc637eb.yaml diff --git a/muranodashboard/environments/topology.py b/muranodashboard/environments/topology.py index 79a79be37..ac633d38e 100644 --- a/muranodashboard/environments/topology.py +++ b/muranodashboard/environments/topology.py @@ -141,6 +141,14 @@ def _create_ext_network_node(name): return node +def _convert_lists(node_data): + for key, value in six.iteritems(node_data): + if isinstance(value, list) and all( + map(lambda s: not isinstance(s, (dict, list)), value)): + new_value = ', '.join(str(v) for v in value) + node_data[key] = new_value + + def _split_seq_by_predicate(seq, predicate): holds, not_holds = [], [] for elt in seq: @@ -193,6 +201,7 @@ def render_d3_data(request, environment): def rec(node_data, node_key, parent_node=None): if not isinstance(node_data, dict): return + _convert_lists(node_data) node_type = node_data.get('?', {}).get('type') node_id = node_data.get('?', {}).get('id') atomics, containers = _split_seq_by_predicate( diff --git a/releasenotes/notes/ips-display-topology-5a45876dafc637eb.yaml b/releasenotes/notes/ips-display-topology-5a45876dafc637eb.yaml new file mode 100644 index 000000000..4e68fede0 --- /dev/null +++ b/releasenotes/notes/ips-display-topology-5a45876dafc637eb.yaml @@ -0,0 +1,4 @@ +--- +fixes: + - VM IP addresses are now properly displayed in the environment topology + viewer.