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
This commit is contained in:
Alexander Tivelkov 2016-11-29 13:49:00 +03:00
parent 30c88ac981
commit d3039ea9cb
2 changed files with 13 additions and 0 deletions

View File

@ -141,6 +141,14 @@ def _create_ext_network_node(name):
return node 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): def _split_seq_by_predicate(seq, predicate):
holds, not_holds = [], [] holds, not_holds = [], []
for elt in seq: for elt in seq:
@ -193,6 +201,7 @@ def render_d3_data(request, environment):
def rec(node_data, node_key, parent_node=None): def rec(node_data, node_key, parent_node=None):
if not isinstance(node_data, dict): if not isinstance(node_data, dict):
return return
_convert_lists(node_data)
node_type = node_data.get('?', {}).get('type') node_type = node_data.get('?', {}).get('type')
node_id = node_data.get('?', {}).get('id') node_id = node_data.get('?', {}).get('id')
atomics, containers = _split_seq_by_predicate( atomics, containers = _split_seq_by_predicate(

View File

@ -0,0 +1,4 @@
---
fixes:
- VM IP addresses are now properly displayed in the environment topology
viewer.