- new_spec = self.make_pod_spec()
- if new_spec == self.state.spec:
- unit.status = ActiveStatus("Ready")
- return
- self.framework.model.pod.set_spec(new_spec)
- self.state.spec = new_spec
- unit.status = ActiveStatus("Ready")
-
- def make_pod_spec(self):
- config = self.framework.model.config
-
- ports = [
- {"name": "port", "containerPort": config["port"], "protocol": "TCP",},
- ]
-
- kubernetes = {
- "readinessProbe": {
- "tcpSocket": {"port": config["port"]},
- "timeoutSeconds": 5,
- "periodSeconds": 5,
- "initialDelaySeconds": 10,
- },
- "livenessProbe": {
- "tcpSocket": {"port": config["port"]},
- "timeoutSeconds": 5,
- "initialDelaySeconds": 45,
- },
+ def _on_nbi_relation_changed(self, event: EventBase) -> NoReturn:
+ """Reads information about the nbi relation.
+
+ Args:
+ event (EventBase): NBI relation event.
+ """
+ data_loc = event.unit if event.unit else event.app
+ logger.error(dict(event.relation.data))
+ nbi_host = event.relation.data[data_loc].get("host")
+ nbi_port = event.relation.data[data_loc].get("port")
+
+ if (
+ nbi_host
+ and nbi_port
+ and (self.state.nbi_host != nbi_host or self.state.nbi_port != nbi_port)
+ ):
+ self.state.nbi_host = nbi_host
+ self.state.nbi_port = nbi_port
+ self.on.configure_pod.emit()
+
+ def _on_nbi_relation_departed(self, event: EventBase) -> NoReturn:
+ """Clears data from nbi relation.
+
+ Args:
+ event (EventBase): NBI relation event.
+ """
+ self.state.nbi_host = None
+ self.state.nbi_port = None
+ self.on.configure_pod.emit()
+
+ def _missing_relations(self) -> str:
+ """Checks if there missing relations.
+
+ Returns:
+ str: string with missing relations
+ """
+ data_status = {
+ "nbi": self.state.nbi_host,