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__)
class ConfigModel(ModelValidator):
+ keystone_enabled: bool
vca_host: str
vca_user: str
vca_password: str
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 = []
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)
"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
"global_request_timeout": 10,
"collector_interval": 30,
"evaluator_interval": 30,
+ "keystone_enabled": True,
}
self.harness.update_config(self.config)
self.assertTrue(
all(
relation in self.harness.charm.unit.status.message
- for relation in ["mongodb", "kafka", "prometheus"]
+ for relation in ["mongodb", "kafka", "prometheus", "keystone"]
)
)
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)
{"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()