63 lines
2.6 KiB
Python
63 lines
2.6 KiB
Python
#Library includes definition and function for parsing SLO yaml definition into object
|
|
from tileFactory import get_dataExplorerTileSloThreshold
|
|
class Sloconfig:
|
|
def __init__(self):
|
|
self.hub = ""
|
|
self.metric = ""
|
|
self.custom_traffic = ""
|
|
self.custom_latency = ""
|
|
self.selector = ""
|
|
self.sloid = ""
|
|
self.slorelevant = False
|
|
self.graph_threshold = ""
|
|
self.singlevalue_threshold = ""
|
|
self.displayName = ""
|
|
self.department = ""
|
|
self.remoteurl = ""
|
|
self.hubtype = ""
|
|
self.tiles_actual = False
|
|
self.tiles_graph = False
|
|
self.tiles_ytd = False
|
|
self.slourl = ""
|
|
self.docurl = ""
|
|
|
|
#Loads values from yaml config files and parses them into object
|
|
def getSloConfigurations(sloconfig, scriptconfig):
|
|
configs = []
|
|
for hub in sloconfig["hubs"]:
|
|
conf = Sloconfig()
|
|
conf.hub = hub
|
|
conf.metric = sloconfig["metric"]
|
|
if "custom_latency_metric" in sloconfig:
|
|
conf.custom_latency = sloconfig["custom_latency_metric"]
|
|
if "custom_traffic_metric" in sloconfig:
|
|
conf.custom_traffic = sloconfig["custom_traffic_metric"]
|
|
conf.selector = sloconfig["selector_var"].replace("~","")
|
|
conf.singlevalue_threshold = get_dataExplorerTileSloThreshold(sloconfig["thresholds"]["single_value"])
|
|
conf.graph_threshold = get_dataExplorerTileSloThreshold(sloconfig["thresholds"]["graph_value"])
|
|
conf.displayName = sloconfig["displayname"]
|
|
conf.department = sloconfig["department"]
|
|
conf.docurl = sloconfig["doc_url"]
|
|
for tile in sloconfig["hubs"][hub]["tiles"]:
|
|
if tile == "actual":
|
|
conf.tiles_actual =True
|
|
elif tile == "graph":
|
|
conf.tiles_graph = True
|
|
elif tile == "ytd":
|
|
conf.tiles_ytd = True
|
|
for env in scriptconfig["hubs"]:
|
|
if env["name_env"] == hub:
|
|
conf.sloid = sloconfig["ids"][env["name_short"]]
|
|
if sloconfig["hubs"][hub]["type"] == "coco" :
|
|
conf.remoteurl = env["remote_url"]
|
|
conf.hubtype = "coco"
|
|
elif sloconfig["hubs"][hub]["type"] == "gcdm":
|
|
conf.remoteurl = env["remote_url_gcdm"]
|
|
conf.hubtype = "gcdm"
|
|
conf.slourl = conf.remoteurl + "/ui/slo?id="+conf.sloid+"&sloexp="+conf.sloid+"&slovis=Table"
|
|
if conf.selector.startswith("CoCo-QM-Report_"):
|
|
conf.slorelevant = True
|
|
configs.append(conf)
|
|
|
|
return configs
|