From 62bcb511b551804993aa04604a493d05fb977102 Mon Sep 17 00:00:00 2001 From: dongwenjuan Date: Thu, 12 May 2016 04:44:26 -0400 Subject: [PATCH] tree topology API should return the specified root use `vitrage topology show` with tree grap-type and specified root, it returns the tree should begin with the specified root, not the default OPENSTACK_CLUSTER Fixes: bug #1580840 Change-Id: I2bbac311ce9370b91f27b12c039e67c450fed754 Signed-off-by: dongwenjuan --- vitrage/api/controllers/v1/topology.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/vitrage/api/controllers/v1/topology.py b/vitrage/api/controllers/v1/topology.py index ebcc795af..be3b5cf62 100644 --- a/vitrage/api/controllers/v1/topology.py +++ b/vitrage/api/controllers/v1/topology.py @@ -21,6 +21,8 @@ from pecan.core import abort from vitrage.api.controllers.rest import RootRestController from vitrage.api.policy import enforce +from vitrage.common.constants import VertexProperties as VProps +from vitrage.datasources import OPENSTACK_CLUSTER # noinspection PyProtectedMember from vitrage.i18n import _LI @@ -64,7 +66,13 @@ class TopologyController(RootRestController): if graph_type == 'graph': return graph if graph_type == 'tree': - return RootRestController.as_tree(graph) + node_id = OPENSTACK_CLUSTER + if root: + for node in graph['nodes']: + if node[VProps.VITRAGE_ID] == root: + node_id = node[VProps.ID] + break + return RootRestController.as_tree(graph, node_id) except Exception as e: LOG.exception('failed to get topology %s ', e)