X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Fcharm%2Fosm-nbi%2Fsrc%2Fcharm.py;h=77c8a182a0392d68c90602718b1ac582c1652f2b;hb=a86e06186fc2688599647603068cecbee712c800;hp=964050a96ec3b7b88d92621843dfaa8876245788;hpb=ff8f33e3d93360bacdd3061ce9cfad6ddb3229a6;p=osm%2Fdevops.git diff --git a/installers/charm/osm-nbi/src/charm.py b/installers/charm/osm-nbi/src/charm.py index 964050a9..77c8a182 100755 --- a/installers/charm/osm-nbi/src/charm.py +++ b/installers/charm/osm-nbi/src/charm.py @@ -40,8 +40,10 @@ from charms.osm_libs.v0.utils import ( check_container_ready, check_service_active, ) +from charms.osm_nbi.v0.nbi import NbiProvides +from charms.osm_temporal.v0.temporal import TemporalRequires from lightkube.models.core_v1 import ServicePort -from ops.charm import ActionEvent, CharmBase +from ops.charm import ActionEvent, CharmBase, RelationJoinedEvent from ops.framework import StoredState from ops.main import main from ops.model import ActiveStatus, Container @@ -80,6 +82,8 @@ class OsmNbiCharm(CharmBase): }, ) self.kafka = KafkaRequires(self) + self.nbi = NbiProvides(self) + self.temporal = TemporalRequires(self) self.mongodb_client = MongoClient(self, "mongodb") self.prometheus_client = PrometheusClient(self, "prometheus") self.keystone_client = KeystoneClient(self, "keystone") @@ -111,9 +115,10 @@ class OsmNbiCharm(CharmBase): # Eventually it will become ready after the first pebble-ready event. check_container_ready(self.container) - self._configure_service(self.container) + if not self.debug_mode.started: + self._configure_service(self.container) self._update_ingress_config() - + self._update_nbi_relation() # Update charm status self._on_update_status() except CharmError as e: @@ -145,6 +150,11 @@ class OsmNbiCharm(CharmBase): finally: self._on_update_status() + def _update_nbi_relation(self, event: RelationJoinedEvent = None) -> None: + """Handler for the nbi-relation-joined event.""" + if self.unit.is_leader(): + self.nbi.set_host_info(self.app.name, SERVICE_PORT, event.relation if event else None) + def _on_get_debug_mode_information_action(self, event: ActionEvent) -> None: """Handler for the get-debug-mode-information action event.""" if not self.debug_mode.started: @@ -173,6 +183,9 @@ class OsmNbiCharm(CharmBase): self.on["kafka"].relation_broken: self._on_required_relation_broken, # Action events self.on.get_debug_mode_information_action: self._on_get_debug_mode_information_action, + self.on.nbi_relation_joined: self._update_nbi_relation, + self.on["temporal"].relation_changed: self._on_config_changed, + self.on["temporal"].relation_broken: self._on_required_relation_broken, } for relation in [self.on[rel_name] for rel_name in ["mongodb", "prometheus", "keystone"]]: event_handler_mapping[relation.relation_changed] = self._on_config_changed @@ -206,6 +219,8 @@ class OsmNbiCharm(CharmBase): missing_relations.append("prometheus") if self.keystone_client.is_missing_data_in_app(): missing_relations.append("keystone") + if not self.temporal.host or not self.temporal.port: + missing_relations.append("temporal") if missing_relations: relations_str = ", ".join(missing_relations) @@ -275,6 +290,14 @@ class OsmNbiCharm(CharmBase): "OSMNBI_AUTHENTICATION_SERVICE_USERNAME": self.keystone_client.username, "OSMNBI_AUTHENTICATION_SERVICE_PASSWORD": self.keystone_client.password, "OSMNBI_AUTHENTICATION_SERVICE_PROJECT": self.keystone_client.service, + # DISABLING INTERNAL SSL SERVER + "OSMNBI_SERVER_SSL_MODULE": "", + "OSMNBI_SERVER_SSL_CERTIFICATE": "", + "OSMNBI_SERVER_SSL_PRIVATE_KEY": "", + "OSMNBI_SERVER_SSL_PASS_PHRASE": "", + # Temporal configuration + "OSMNBI_TEMPORAL_HOST": self.temporal.host, + "OSMNBI_TEMPORAL_PORT": self.temporal.port, }, } },