Skip to content

Commit

Permalink
fixed bug in container for grafana
Browse files Browse the repository at this point in the history
  • Loading branch information
FloSch62 committed Apr 22, 2024
1 parent ebde8d3 commit bb04190
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ RUN chmod +x /app/entrypoint.sh

# Set the working directory in the container
WORKDIR /data
ENV APP_BASE_DIR=/app

# Use the entrypoint script to handle script execution
ENTRYPOINT ["/app/entrypoint.sh"]
Expand Down
17 changes: 13 additions & 4 deletions lib/Grafana.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ def gf_flowchart_rule_traffic(self, ruleName="traffic:inOrOut", metric=None, lin
Dictionary containing information relevant to the traffic Rules
"""
# Load the traffic rule template from file
with open("lib/templates/traffic_rule_template.json") as f:
base_dir = os.getenv('APP_BASE_DIR', '')

with open(os.path.join(base_dir, "lib/templates/traffic_rule_template.json"), "r") as f:
rule = json.load(f)

rule["alias"] = ruleName
Expand All @@ -135,7 +137,9 @@ def gf_flowchart_rule_operstate(self, ruleName="oper_state", metric=None, link_i
Dictionary containing information relevant to the Operational State Rules
"""
# Load the operstate rule template from file
with open("lib/templates/operstate_rule_template.json") as f:
base_dir = os.getenv('APP_BASE_DIR', '')

with open(os.path.join(base_dir,"lib/templates/operstate_rule_template.json"), "r") as f:
rule = json.load(f)

rule["alias"] = ruleName
Expand All @@ -151,7 +155,9 @@ def gf_flowchart_panel_template(self, xml=None, rulesData=None, targetsList=None
Embedding of the XML diagram, the Rules and the Targets
"""
# Load the panel template from file
with open("lib/templates/panel_template.json") as f:
base_dir = os.getenv('APP_BASE_DIR', '')

with open(os.path.join(base_dir,"lib/templates/panel_template.json"), "r") as f:
panel = json.load(f)

panel[0]["flowchartsData"]["flowcharts"][0]["xml"] = xml
Expand All @@ -165,8 +171,11 @@ def gf_dashboard_template(self, panels=None, dashboard_name="lab-telemetry"):
"""
Dictionary containing information relevant to the Grafana Dashboard Root JSON object
"""

base_dir = os.getenv('APP_BASE_DIR', '')

# Load the dashboard template from file
with open("lib/templates/dashboard_template.json") as f:
with open(os.path.join(base_dir, "lib/templates/traffic_rule_template.json")) as f:
dashboard = json.load(f)

dashboard["panels"] = panels
Expand Down

0 comments on commit bb04190

Please sign in to comment.