Skip to content
Merged

#186 #188

Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 14 additions & 11 deletions autogole-api/src/python/RTMonLibs/Template.py
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,7 @@ def t_createDashboard(self, *args, **kwargs):
out["uid"] = args[0]["intents"][0]["id"]
return out

def t_createHostFlow(self, sitehost, *args):
def t_createHostFlow(self, sitehost, num, *args):
"""Create Host Flow Template"""
out = []
interfaces = self.m_groups['Hosts'].get(sitehost, "")
Expand All @@ -464,7 +464,7 @@ def t_createHostFlow(self, sitehost, *args):
sitename = sitehost.split(":")[0]
hostname = sitehost.split(":")[1]
intfline = "|".join(interfaces.keys())
row = self.t_addRow(*args, title=f"Host Flow Summary: {sitehost}")
row = self.t_addRow(*args, title=f"{num}. Host Flow Summary: {sitehost}")
panels = dumpJson(self._t_loadTemplate("hostflow.json"), self.logger)
panels = panels.replace("REPLACEME_DATASOURCE", str(self.t_dsourceuid))
panels = panels.replace("REPLACEME_SITENAME", sitename)
Expand All @@ -474,7 +474,7 @@ def t_createHostFlow(self, sitehost, *args):
out += self.addRowPanel(row, panels, True)
return out

def t_createSwitchFlow(self, sitehost, *args):
def t_createSwitchFlow(self, sitehost, num, *args):
"""Create Switch Flow Template"""
def findIntf(interfaces):
"""Find Interface"""
Expand Down Expand Up @@ -519,7 +519,7 @@ def findIntf(interfaces):
sitename = sitehost.split(":")[0]
hostname = sitehost.split(":")[1]
intfline = findIntf(interfaces)
row = self.t_addRow(*args, title=f"Switch Flow Summary: {sitehost}")
row = self.t_addRow(*args, title=f"{num}. Switch Flow Summary: {sitehost}")
panels = dumpJson(self._t_loadTemplate("switchflow.json"), self.logger)
panels = panels.replace("REPLACEME_DATASOURCE", str(self.t_dsourceuid))
panels = panels.replace("REPLACEME_SITENAME", sitename)
Expand Down Expand Up @@ -721,21 +721,24 @@ def t_createTemplate(self, *args, **kwargs):

# Add Links on top of the page
self.generated['links'] = self.t_addLinks(*args, **kwargs)
# Add Debug Info (manifest, instance)
self.generated['panels'] += self.t_addDebug(*args)
added = []
hostnum, switchnum = 1, 1
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

look at enumerate and use only 1 index from a list. No need separate numbers for hostnum, switchnum

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets say I have [host, host, host, switch] will it not create
host1
host2
host3
and switch4?

but we want hostt1, host2, host3, switch1 right?

Copy link
Collaborator

@juztas juztas Apr 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want it in a flow:
host1, switch2, switch3, switch4, host5

for item in self.orderlist:
if item['Type'] == 'Host' and item['Name'] not in added:
self.generated['panels'] += self.t_createHostFlow(item["Name"], *args)
self.generated['panels'] += self.t_createHostFlow(item["Name"], hostnum, *args)
added.append(item['Name'])
hostnum += 1
elif item['Type'] == 'Switch' and item['Node'] not in added:
self.generated['panels'] += self.t_createSwitchFlow(item["Node"], *args)
self.generated['panels'] += self.t_createSwitchFlow(item["Node"], switchnum, *args)
added.append(item['Node'])
switchnum += 1
else:
self.logger.error(f"Unknown Type: {item['Type']}. Skipping... {item}")
# Add L2 Debugging
self.generated['panels'] += self.t_addL2Debugging(*args)

if len(diagrams) > 1:
self.generated['panels'] += diagrams[1]
if self.config.get('Debug', True):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need documentation inside config file

if len(diagrams) > 1:
self.generated['panels'] += diagrams[1]
# Add Debug Info (manifest, instance)
self.generated['panels'] += self.t_addDebug(*args)
return {"dashboard": self.generated}, {"uid": self.generated['uid'], "annotation_panels": self.annotationids}