X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=osm_mon%2Fdashboarder%2Fservice.py;h=5c05ef657518f505ecff4d60824d6387118c1287;hb=refs%2Fchanges%2F01%2F13801%2F2;hp=c8267777fbac8b5138bb2b8eea7b34fe2ad7f715;hpb=335cb85d4b71fb6a5d12d0b08636047686a2a1ba;p=osm%2FMON.git diff --git a/osm_mon/dashboarder/service.py b/osm_mon/dashboarder/service.py index c826777..5c05ef6 100644 --- a/osm_mon/dashboarder/service.py +++ b/osm_mon/dashboarder/service.py @@ -97,35 +97,59 @@ class DashboarderService: k8scluster_id = k8scluster["_id"] k8scluster_name = k8scluster["name"] osm_resource_uids.append(k8scluster_id) - osm_datasource_names.append("{}-{}".format(datasource_name_substr, k8scluster_name)) + osm_datasource_names.append( + "{}-{}".format(datasource_name_substr, k8scluster_name) + ) if k8scluster_id not in dashboard_uids: projects_read = k8scluster["_admin"]["projects_read"] if len(projects_read) and projects_read[0] == project_id: # Collect K8S Cluster IDs for periodical dashboard clean-up - k8scluster_address = k8scluster["credentials"]["clusters"][0]["cluster"]["server"] + k8scluster_address = k8scluster["credentials"]["clusters"][0][ + "cluster" + ]["server"] # Extract K8S Cluster ip from url - k8scluster_ip = re.findall(r'://([\w\-\.]+)', k8scluster_address)[0] + k8scluster_ip = re.findall( + r"://([\w\-\.]+)", k8scluster_address + )[0] # prometheus-operator url - datasource_url = "http://{}:{}".format(k8scluster_ip, prom_operator_port) + datasource_url = "http://{}:{}".format( + k8scluster_ip, prom_operator_port + ) # Create datsource for prometheus-operator in grafana datasource_type = "prometheus" - datasource_name = "{}-{}".format(datasource_name_substr, k8scluster_name) + datasource_name = "{}-{}".format( + datasource_name_substr, k8scluster_name + ) if datasource_name not in datasource_names: - self.grafana.create_datasource(datasource_name, datasource_type, datasource_url) - log.debug("Created datasource for k8scluster: %s", k8scluster_id) + self.grafana.create_datasource( + datasource_name, datasource_type, datasource_url + ) + log.debug( + "Created datasource for k8scluster: %s", k8scluster_id + ) if project["name"] != "admin": self.grafana.create_dashboard( - k8scluster_id, k8scluster_name, cnf_dashboard_path, project_name=project["name"], - datasource_name=datasource_name) + k8scluster_id, + k8scluster_name, + cnf_dashboard_path, + project_name=project["name"], + datasource_name=datasource_name, + ) else: self.grafana.create_dashboard( - k8scluster_id, k8scluster_name, cnf_dashboard_path, datasource_name=datasource_name) + k8scluster_id, + k8scluster_name, + cnf_dashboard_path, + datasource_name=datasource_name, + ) log.debug("Created dashboard for k8scluster: %s", k8scluster_id) else: - log.debug("Dashboard already exist for k8scluster: %s", k8scluster_id) + log.debug( + "Dashboard already exist for k8scluster: %s", k8scluster_id + ) # Reads existing NS list and creates a dashboard for each # TODO lavado: only create for ACTIVE NSRs @@ -148,7 +172,8 @@ class DashboarderService: # If there are metrics, create dashboard (if exists) if vnfd.get("vdu"): vdu_found = find_in_list( - vnfd.get("vdu"), lambda a_vdu: "monitoring-parameter" in a_vdu + vnfd.get("vdu"), + lambda a_vdu: "monitoring-parameter" in a_vdu, ) else: vdu_found = None @@ -171,7 +196,10 @@ class DashboarderService: log.info("Project %s not found", project_id) log.debug("Exception %s" % e) self.grafana.create_dashboard( - nsr_id, nsr_name, dashboard_path, project_name=project_name + nsr_id, + nsr_name, + dashboard_path, + project_name=project_name, ) log.debug("Created dashboard for NS: %s", nsr_id) else: