Commit 5fd9db35 authored by Sergios Aftsidis's avatar Sergios Aftsidis
Browse files

[RG-n2ntraffic] Add get_graph_for_node_link

This new function implements the previous functionality that
views/api:link() had. It no longer uses 'Links' objects to
resolve a node link, but directly searches for the required
'Graph' object. Then, if the 'separate' argument is provided,
calls graph_for_each interface' to get all the separate graphs
that form this aggregation, otherwise just returns the png of
the aggregate graph using a reverse url resolution of 'get-png-data'.
parent bdf1c05d
......@@ -244,3 +244,37 @@ def create_links_dict(links):
return ifces
def get_graph_for_node_link(local, remote, separate=False):
response = []
graph = Graph.objects.get(
description__contains='%s - %s' % (local, remote)
graph = None
if graph:
if separate:
# '-1d', '-300' now need to be fixed values as we are not creating
# the graphs, only getting the ones that rg creates with those
# default values
response = graph_for_each_interface(
graph, graph.datasources.all(), '-1d', '-300')
url = reverse(
kwargs={'path': '%s-1d-300.png' %}
response = {
'graph': url,
'links': [{"from_descr": graph.description}]
response = {'graph': False, 'links': []}
return response
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment