X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Fcharm%2Fgrafana%2Fsrc%2Fcharm.py;h=d10ccf23335081c0da81b167a37b0ae1422c5cf1;hb=021b307297a6ab8dfe9ee3af03154989bcd9e0e8;hp=2d982d12fc14e39e04e89463f42b2f995d41bb9f;hpb=49379ced23b5e344a773ce77ac9cb59c1864e19b;p=osm%2Fdevops.git diff --git a/installers/charm/grafana/src/charm.py b/installers/charm/grafana/src/charm.py index 2d982d12..d10ccf23 100755 --- a/installers/charm/grafana/src/charm.py +++ b/installers/charm/grafana/src/charm.py @@ -22,33 +22,25 @@ # pylint: disable=E0213 -import logging -from typing import Optional, NoReturn from ipaddress import ip_network +import logging +from pathlib import Path +from string import Template +from typing import NoReturn, Optional +from urllib.parse import urlparse from ops.main import main - from opslib.osm.charm import CharmedOsmBase, RelationsMissing - +from opslib.osm.interfaces.prometheus import PrometheusClient from opslib.osm.pod import ( - IngressResourceV3Builder, - FilesV3Builder, ContainerV3Builder, + FilesV3Builder, + IngressResourceV3Builder, PodSpecV3Builder, ) +from opslib.osm.validator import ModelValidator, validator -from opslib.osm.validator import ( - ModelValidator, - validator, -) - -from opslib.osm.interfaces.prometheus import PrometheusClient - -from urllib.parse import urlparse -from string import Template -from pathlib import Path - logger = logging.getLogger(__name__) PORT = 3000 @@ -90,8 +82,12 @@ class GrafanaCharm(CharmedOsmBase): super().__init__(*args, oci_image="image") self.prometheus_client = PrometheusClient(self, "prometheus") - self.framework.observe(self.on["prometheus"].relation_changed, self.configure_pod) - self.framework.observe(self.on["prometheus"].relation_broken, self.configure_pod) + self.framework.observe( + self.on["prometheus"].relation_changed, self.configure_pod + ) + self.framework.observe( + self.on["prometheus"].relation_broken, self.configure_pod + ) def _build_dashboard_files(self, config: ConfigModel): files_builder = FilesV3Builder() @@ -101,11 +97,11 @@ class GrafanaCharm(CharmedOsmBase): ) if config.osm_dashboards: osm_dashboards_mapping = { - "kafka_exporter_dashboard.yaml": "files/kafka_exporter_dashboard.yaml", - "mongodb_exporter_dashboard.yaml": "files/mongodb_exporter_dashboard.yaml", - "mysql_exporter_dashboard.yaml": "files/mysql_exporter_dashboard.yaml", - "nodes_exporter_dashboard.yaml": "files/nodes_exporter_dashboard.yaml", - "summary_dashboard.yaml": "files/summary_dashboard.yaml", + "kafka_exporter_dashboard.json": "files/kafka_exporter_dashboard.json", + "mongodb_exporter_dashboard.json": "files/mongodb_exporter_dashboard.json", + "mysql_exporter_dashboard.json": "files/mysql_exporter_dashboard.json", + "nodes_exporter_dashboard.json": "files/nodes_exporter_dashboard.json", + "summary_dashboard.json": "files/summary_dashboard.json", } for file_name, path in osm_dashboards_mapping.items(): files_builder.add_file(file_name, Path(path).read_text())