def get_graph(graph_type, depth, query, root, all_tenants): TopologyController._check_input_para(graph_type, depth, query, root, all_tenants) try: graph_data = pecan.request.client.call(pecan.request.context, 'get_topology', graph_type=graph_type, depth=depth, query=query, root=root, all_tenants=all_tenants) LOG.debug(graph_data) graph = json.loads(graph_data) if graph_type == 'graph': return graph if graph_type == 'tree': node_id = CLUSTER_ID 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: LOG.exception('failed to get topology.') abort(404, 'Failed to get topology.')
def get_graph(graph_type, depth, query, root, all_tenants): TopologyController._check_input_para(graph_type, depth, query, root, all_tenants) try: graph_data = pecan.request.client.call(pecan.request.context, 'get_topology', graph_type=graph_type, depth=depth, query=query, root=root, all_tenants=all_tenants) graph = decompress_obj(graph_data) if graph_type == 'graph': return graph if graph_type == 'tree': if nx.__version__ >= '2.0': node_id = '' for node in graph['nodes']: if (root and node[VProps.VITRAGE_ID] == root) or \ (not root and node[VProps.ID] == CLUSTER_ID): node_id = node[VProps.GRAPH_INDEX] break else: node_id = CLUSTER_ID 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: LOG.exception('failed to get topology.') abort(404, 'Failed to get topology.')
def get_graph(graph_type, depth, query, root, all_tenants): TopologyController._check_input_para(graph_type, depth, query, root, all_tenants) try: graph_data = pecan.request.client.call(pecan.request.context, 'get_topology', graph_type=graph_type, depth=depth, query=query, root=root, all_tenants=all_tenants) LOG.info(graph_data) graph = json.loads(graph_data) if graph_type == 'graph': return graph if graph_type == 'tree': 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) abort(404, str(e))
def get_graph(graph_type, depth, query, root): try: graph_data = pecan.request.client.call(pecan.request.context, 'get_topology', graph_type=graph_type, depth=depth, query=query, root=root) LOG.info(graph_data) graph = json.loads(graph_data) if graph_type == 'graph': return graph if graph_type == 'tree': 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) abort(404, str(e))
def get_graph(graph_type, depth, query, root): try: graph_data = pecan.request.client.call(pecan.request.context, 'get_topology', graph_type=graph_type, depth=depth, query=query, root=root) LOG.info(graph_data) graph = json.loads(graph_data) if graph_type == 'graph': return graph if graph_type == 'tree': return RootRestController.as_tree(graph) except Exception as e: LOG.exception('failed to get topology %s ', e) abort(404, str(e))