Skip to content

Commit

Permalink
Merge pull request #264 from nikodemas/update_datasources_script
Browse files Browse the repository at this point in the history
Add url to datasources file
  • Loading branch information
nikodemas authored Feb 8, 2024
2 parents 8233ef9 + 158d9ea commit 5ae144f
Show file tree
Hide file tree
Showing 2 changed files with 419 additions and 203 deletions.
16 changes: 12 additions & 4 deletions src/python/CMSMonitoring/datasources_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@ def __init__(self):
"""
self.parser = argparse.ArgumentParser(prog="PROG", usage=desc)
self.parser.add_argument(
"--token", action="store", dest="token", default=None,
help="Admin token: either file with token or token string"
"--token",
action="store",
dest="token",
default=None,
help="Admin token: either file with token or token string",
)
self.parser.add_argument(
"--url",
Expand Down Expand Up @@ -48,7 +51,12 @@ def get_datasources(token, base="https://monit-grafana.cern.ch"):
print(response.text)
sys.exit(1)
return {
x["name"]: {"id": x["id"], "type": x["type"], "database": x["database"]}
x["name"]: {
"id": x["id"],
"type": x["type"],
"database": x["database"],
"url": x["url"],
}
for x in fullResponse
}

Expand All @@ -59,7 +67,7 @@ def main():
opts = optmgr.parser.parse_args()
token = os.getenv("GRAFANA_ADMIN_TOKEN", opts.token)
if os.path.exists(token): # if token is a file
token = open(token).readline().replace('\n', '')
token = open(token).readline().replace("\n", "")
output = opts.output
base = opts.url
if not token:
Expand Down
Loading

0 comments on commit 5ae144f

Please sign in to comment.