OPMAAS-4530, OPMAAS-4534 Bug fixes
parent
cab7660a8d
commit
3be1a6d76e
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
metadata:
|
||||
basename: "Global Offboard Reliability 2.0"
|
||||
stagingname: "[STAGING]Global Offboard Reliability 2.0"
|
||||
basename: "Global Offboard Reliability 2.1"
|
||||
stagingname: "[STAGING]Global Offboard Reliability 2.1"
|
||||
owner: "PATRYK.GUDALEWICZ@partner.bmw.de"
|
||||
#actual tile
|
||||
single_value_header_1: "Last 1 h"
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
import yaml
|
||||
from decouple import config
|
||||
import json
|
||||
from datetime import datetime
|
||||
import argparse
|
||||
from tileFactory import createHeaderTiles
|
||||
from tileFactory import createImageTile
|
||||
|
|
@ -11,6 +12,9 @@ from repoConfig import pull_repo
|
|||
from repoConfig import push_repo
|
||||
from sloHelper import load_slo_parameter
|
||||
from sloConfigLoader import getSloConfigurations
|
||||
from remoteDashboard import get_all_dashboards_withname
|
||||
from remoteDashboard import backup_dashboards
|
||||
from remoteDashboard import create_or_update_dashboard
|
||||
import warnings
|
||||
warnings.filterwarnings("ignore")
|
||||
|
||||
|
|
@ -91,7 +95,25 @@ def main():
|
|||
with open("./tiles/dashboard_tiles_"+str(dahboardcount)+".json", "w") as file:
|
||||
json.dump(dashboard_json, file, indent=2)
|
||||
generatedfiles.append("dashboard_tiles_"+str(dahboardcount)+".json")
|
||||
|
||||
#Upload staging dashboard if auto upload is specified
|
||||
if args.auto_upload:
|
||||
print("Getting existing STAGING dashboards from Dynatrace")
|
||||
for item, doc in doc.items():
|
||||
if(item == "globaldashboard"):
|
||||
token = dict(doc[2])
|
||||
url = dict(doc[1])
|
||||
print("Crawling through: " + item)
|
||||
print("Gather data, hold on a minute")
|
||||
DTTOKEN = config(token.get('env-token-name'))
|
||||
DTURL = url.get('env-url')
|
||||
print("Downloading STAGING dashboards to local repo ("+blname+")...")
|
||||
existingdashboards = get_all_dashboards_withname(DTTOKEN, DTURL,script_config["metadata"]["stagingname"]+" - " +blname)
|
||||
print("Uploading STAGING dashboards to Dynatrace ("+blname+")...")
|
||||
backup_dashboards(DTTOKEN, DTURL, existingdashboards)
|
||||
now=datetime.now()
|
||||
strnowdate = now.strftime("%Y%m%d")
|
||||
push_repo(archiverepo, strnowdate+"_Global dashboard as code auto-upload backup")
|
||||
create_or_update_dashboard(DTTOKEN, DTURL, existingdashboards, generatedfiles, blname,script_config,args.department)
|
||||
print("DONE")
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
|
@ -66,7 +66,7 @@ def remove_dashboards(DTAPIToken, DTENV, dashboards):
|
|||
def create_or_update_dashboard(DTAPIToken, DTENV, dashboards, files, businessline, config, department):
|
||||
if(files):
|
||||
for index, filename in enumerate(files,start=1):
|
||||
with open('./'+filename) as file:
|
||||
with open('./tiles/'+filename) as file:
|
||||
tilesjson = json.load(file)
|
||||
if any(dashboard["name"].endswith("#"+str(index)) for dashboard in dashboards):
|
||||
existingdashboard = next((dashboard for dashboard in dashboards if dashboard["name"].endswith("#"+str(index))), None)
|
||||
|
|
@ -85,13 +85,13 @@ def create_or_update_dashboard(DTAPIToken, DTENV, dashboards, files, businesslin
|
|||
else:
|
||||
print("Dashboard for file: "+filename + " not found.")
|
||||
if(department == "ALL"):
|
||||
dashfullname = config["stagingname"]
|
||||
dashfullname = config["metadata"]["stagingname"]
|
||||
else:
|
||||
dashfullname = config["stagingname"] + " - " + businessline + " #" + str(index)
|
||||
dashfullname = config["metadata"]["stagingname"] + " - " + businessline + " #" + str(index)
|
||||
newdashboard = {
|
||||
"dashboardMetadata":{
|
||||
"name": dashfullname,
|
||||
"owner": "PATRYK.GUDALEWICZ@partner.bmw.de"
|
||||
"owner": config["metadata"]["owner"]
|
||||
},
|
||||
"tiles":[]
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue