Adding MON relation to Keystone for charmed OSM
Change-Id: Icc81251002736a4e25579f42500a5a8f6b3fe74a
Signed-off-by: calvinosanc1 <guillermo.calvino@canonical.com>
diff --git a/installers/charm/bundles/osm-ha/bundle.yaml b/installers/charm/bundles/osm-ha/bundle.yaml
index 8069543..cb361ae 100644
--- a/installers/charm/bundles/osm-ha/bundle.yaml
+++ b/installers/charm/bundles/osm-ha/bundle.yaml
@@ -112,6 +112,7 @@
options:
database_commonkey: osm
log_level: DEBUG
+ keystone_enabled: true
annotations:
gui-x: 250
gui-y: 50
@@ -199,3 +200,5 @@
- prometheus:prometheus
- - ng-ui:nbi
- nbi:nbi
+ - - mon:keystone
+ - keystone:keystone
diff --git a/installers/charm/bundles/osm/bundle.yaml b/installers/charm/bundles/osm/bundle.yaml
index 58a9707..0783993 100644
--- a/installers/charm/bundles/osm/bundle.yaml
+++ b/installers/charm/bundles/osm/bundle.yaml
@@ -106,6 +106,7 @@
options:
database_commonkey: osm
log_level: DEBUG
+ keystone_enabled: true
annotations:
gui-x: 250
gui-y: 50
@@ -193,3 +194,5 @@
- prometheus:prometheus
- - ng-ui:nbi
- nbi:nbi
+ - - mon:keystone
+ - keystone:keystone
diff --git a/installers/charm/mon/config.yaml b/installers/charm/mon/config.yaml
index 93d77fe..2fffbc5 100644
--- a/installers/charm/mon/config.yaml
+++ b/installers/charm/mon/config.yaml
@@ -72,3 +72,7 @@
description: Grafana password
type: string
default: admin
+ keystone_enabled:
+ description: MON will use Keystone backend
+ type: boolean
+ default: false
diff --git a/installers/charm/mon/metadata.yaml b/installers/charm/mon/metadata.yaml
index 05aa547..663315e 100644
--- a/installers/charm/mon/metadata.yaml
+++ b/installers/charm/mon/metadata.yaml
@@ -45,3 +45,5 @@
interface: mongodb
prometheus:
interface: prometheus
+ keystone:
+ interface: keystone
diff --git a/installers/charm/mon/src/charm.py b/installers/charm/mon/src/charm.py
index 98c3297..26dee3f 100755
--- a/installers/charm/mon/src/charm.py
+++ b/installers/charm/mon/src/charm.py
@@ -43,6 +43,7 @@
from opslib.osm.interfaces.kafka import KafkaClient
from opslib.osm.interfaces.mongo import MongoClient
from opslib.osm.interfaces.prometheus import PrometheusClient
+from opslib.osm.interfaces.keystone import KeystoneClient
logger = logging.getLogger(__name__)
@@ -51,6 +52,7 @@
class ConfigModel(ModelValidator):
+ keystone_enabled: bool
vca_host: str
vca_user: str
vca_password: str
@@ -92,6 +94,10 @@
self.on["prometheus"].relation_broken, self.configure_pod
)
+ self.keystone_client = KeystoneClient(self, "keystone")
+ self.framework.observe(self.on["keystone"].relation_changed, self.configure_pod)
+ self.framework.observe(self.on["keystone"].relation_broken, self.configure_pod)
+
def _check_missing_dependencies(self, config: ConfigModel):
missing_relations = []
@@ -101,6 +107,9 @@
missing_relations.append("mongodb")
if self.prometheus_client.is_missing_data_in_app():
missing_relations.append("prometheus")
+ if config.keystone_enabled:
+ if self.keystone_client.is_missing_data_in_app():
+ missing_relations.append("keystone")
if missing_relations:
raise RelationsMissing(missing_relations)
@@ -144,6 +153,18 @@
"OSMMON_GRAFANA_PASSWORD": config.grafana_password,
}
)
+ if config.keystone_enabled:
+ container_builder.add_envs(
+ {
+ "OSMMON_KEYSTONE_ENABLED": True,
+ "OSMMON_KEYSTONE_URL": self.keystone_client.host,
+ "OSMMON_KEYSTONE_DOMAIN_NAME": self.keystone_client.user_domain_name,
+ "OSMMON_KEYSTONE_PROJECT_DOMAIN_NAME": self.keystone_client.project_domain_name,
+ "OSMMON_KEYSTONE_SERVICE_USER": self.keystone_client.username,
+ "OSMMON_KEYSTONE_SERVICE_PASSWORD": self.keystone_client.password,
+ "OSMMON_KEYSTONE_SERVICE_PROJECT": self.keystone_client.service,
+ }
+ )
container = container_builder.build()
# Add container to pod spec
diff --git a/installers/charm/mon/tests/test_charm.py b/installers/charm/mon/tests/test_charm.py
index 6fcd6a6..5d6f1a0 100644
--- a/installers/charm/mon/tests/test_charm.py
+++ b/installers/charm/mon/tests/test_charm.py
@@ -49,6 +49,7 @@
"global_request_timeout": 10,
"collector_interval": 30,
"evaluator_interval": 30,
+ "keystone_enabled": True,
}
self.harness.update_config(self.config)
@@ -64,7 +65,7 @@
self.assertTrue(
all(
relation in self.harness.charm.unit.status.message
- for relation in ["mongodb", "kafka", "prometheus"]
+ for relation in ["mongodb", "kafka", "prometheus", "keystone"]
)
)
@@ -85,6 +86,7 @@
self.initialize_kafka_relation()
self.initialize_mongo_relation()
self.initialize_prometheus_relation()
+ self.initialize_keystone_relation()
# Verifying status
self.assertNotIsInstance(self.harness.charm.unit.status, BlockedStatus)
@@ -113,6 +115,28 @@
{"hostname": "prometheus", "port": 9090},
)
+ def initialize_keystone_relation(self):
+ keystone_relation_id = self.harness.add_relation("keystone", "keystone")
+ self.harness.add_relation_unit(keystone_relation_id, "keystone/0")
+ self.harness.update_relation_data(
+ keystone_relation_id,
+ "keystone",
+ {
+ "host": "host",
+ "port": 5000,
+ "user_domain_name": "ud",
+ "project_domain_name": "pd",
+ "username": "u",
+ "password": "p",
+ "service": "s",
+ "keystone_db_password": "something",
+ "region_id": "something",
+ "admin_username": "something",
+ "admin_password": "something",
+ "admin_project_name": "something",
+ },
+ )
+
if __name__ == "__main__":
unittest.main()