CharmHub and new kafka and zookeeper charms
- Charmed installer uses bundles published in CharmHub
- Use new zookeeper and kafka sidecar-charm
- Changes in the charms to integrate with the new Kafka
Change-Id: Ie59fe1c7c72774b317abe2433fafb28a11472b72
Signed-off-by: David Garcia <david.garcia@canonical.com>
diff --git a/installers/charm/nbi/src/charm.py b/installers/charm/nbi/src/charm.py
index faba78a..4aaecb9 100755
--- a/installers/charm/nbi/src/charm.py
+++ b/installers/charm/nbi/src/charm.py
@@ -29,10 +29,10 @@
from urllib.parse import urlparse
+from charms.kafka_k8s.v0.kafka import KafkaEvents, KafkaRequires
from ops.main import main
from opslib.osm.charm import CharmedOsmBase, RelationsMissing
from opslib.osm.interfaces.http import HttpServer
-from opslib.osm.interfaces.kafka import KafkaClient
from opslib.osm.interfaces.keystone import KeystoneClient
from opslib.osm.interfaces.mongo import MongoClient
from opslib.osm.interfaces.prometheus import PrometheusClient
@@ -118,6 +118,9 @@
class NbiCharm(CharmedOsmBase):
+
+ on = KafkaEvents()
+
def __init__(self, *args) -> NoReturn:
super().__init__(
*args,
@@ -139,9 +142,9 @@
},
)
- self.kafka_client = KafkaClient(self, "kafka")
- self.framework.observe(self.on["kafka"].relation_changed, self.configure_pod)
- self.framework.observe(self.on["kafka"].relation_broken, self.configure_pod)
+ self.kafka = KafkaRequires(self)
+ self.framework.observe(self.on.kafka_available, self.configure_pod)
+ self.framework.observe(self.on.kafka_broken, self.configure_pod)
self.mongodb_client = MongoClient(self, "mongodb")
self.framework.observe(self.on["mongodb"].relation_changed, self.configure_pod)
@@ -174,10 +177,7 @@
def _check_missing_dependencies(self, config: ConfigModel):
missing_relations = []
- if (
- self.kafka_client.is_missing_data_in_unit()
- and self.kafka_client.is_missing_data_in_app()
- ):
+ if not self.kafka.host or not self.kafka.port:
missing_relations.append("kafka")
if not config.mongodb_uri and self.mongodb_client.is_missing_data_in_unit():
missing_relations.append("mongodb")
@@ -227,7 +227,7 @@
"command": [
"sh",
"-c",
- f"until (nc -zvw1 {self.kafka_client.host} {self.kafka_client.port} ); do sleep 3; done; exit 0",
+ f"until (nc -zvw1 {self.kafka.host} {self.kafka.port} ); do sleep 3; done; exit 0",
],
}
)
@@ -257,9 +257,9 @@
"OSMNBI_SERVER_ENABLE_TEST": config.enable_test,
"OSMNBI_STATIC_DIR": "/app/osm_nbi/html_public",
# Kafka configuration
- "OSMNBI_MESSAGE_HOST": self.kafka_client.host,
+ "OSMNBI_MESSAGE_HOST": self.kafka.host,
"OSMNBI_MESSAGE_DRIVER": "kafka",
- "OSMNBI_MESSAGE_PORT": self.kafka_client.port,
+ "OSMNBI_MESSAGE_PORT": self.kafka.port,
# Database configuration
"OSMNBI_DATABASE_DRIVER": "mongo",
# Storage configuration