Skip to content
Snippets Groups Projects
Commit a43a22f5 authored by calvinosanc1's avatar calvinosanc1 Committed by Mark Beierl
Browse files

Adding MON relation to Keystone for charmed OSM


Change-Id: Icc81251002736a4e25579f42500a5a8f6b3fe74a
Signed-off-by: default avatarcalvinosanc1 <guillermo.calvino@canonical.com>
parent 6dc17050
No related branches found
No related tags found
No related merge requests found
......@@ -112,6 +112,7 @@ applications:
options:
database_commonkey: osm
log_level: DEBUG
keystone_enabled: true
annotations:
gui-x: 250
gui-y: 50
......@@ -199,3 +200,5 @@ relations:
- prometheus:prometheus
- - ng-ui:nbi
- nbi:nbi
- - mon:keystone
- keystone:keystone
......@@ -106,6 +106,7 @@ applications:
options:
database_commonkey: osm
log_level: DEBUG
keystone_enabled: true
annotations:
gui-x: 250
gui-y: 50
......@@ -193,3 +194,5 @@ relations:
- prometheus:prometheus
- - ng-ui:nbi
- nbi:nbi
- - mon:keystone
- keystone:keystone
......@@ -72,3 +72,7 @@ options:
description: Grafana password
type: string
default: admin
keystone_enabled:
description: MON will use Keystone backend
type: boolean
default: false
......@@ -45,3 +45,5 @@ requires:
interface: mongodb
prometheus:
interface: prometheus
keystone:
interface: keystone
......@@ -43,6 +43,7 @@ from opslib.osm.validator import (
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 @@ PORT = 8000
class ConfigModel(ModelValidator):
keystone_enabled: bool
vca_host: str
vca_user: str
vca_password: str
......@@ -92,6 +94,10 @@ class MonCharm(CharmedOsmBase):
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 @@ class MonCharm(CharmedOsmBase):
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 @@ class MonCharm(CharmedOsmBase):
"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
......
......@@ -49,6 +49,7 @@ class TestCharm(unittest.TestCase):
"global_request_timeout": 10,
"collector_interval": 30,
"evaluator_interval": 30,
"keystone_enabled": True,
}
self.harness.update_config(self.config)
......@@ -64,7 +65,7 @@ class TestCharm(unittest.TestCase):
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 @@ class TestCharm(unittest.TestCase):
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 @@ class TestCharm(unittest.TestCase):
{"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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment