Removing pydantic from LCM charm
[osm/devops.git] / installers / charm / lcm / src / charm.py
index d65bdcf..52b6964 100755 (executable)
@@ -21,7 +21,6 @@
 ##
 
 import logging
-from pydantic import ValidationError
 from typing import Any, Dict, NoReturn
 
 from ops.charm import CharmBase, CharmEvents
@@ -112,10 +111,8 @@ class LcmCharm(CharmBase):
         Args:
             event (EventBase): Kafka relation event.
         """
-        data_loc = event.unit if event.unit else event.app
-
-        message_host = event.relation.data[data_loc].get("host")
-        message_port = event.relation.data[data_loc].get("port")
+        message_host = event.relation.data[event.unit].get("host")
+        message_port = event.relation.data[event.unit].get("port")
 
         if (
             message_host
@@ -145,9 +142,7 @@ class LcmCharm(CharmBase):
         Args:
             event (EventBase): DB relation event.
         """
-        data_loc = event.unit if event.unit else event.app
-
-        database_uri = event.relation.data[data_loc].get("connection_string")
+        database_uri = event.relation.data[event.unit].get("connection_string")
 
         if database_uri and self.state.database_uri != database_uri:
             self.state.database_uri = database_uri
@@ -168,10 +163,8 @@ class LcmCharm(CharmBase):
         Args:
             event (EventBase): Keystone relation event.
         """
-        data_loc = event.unit if event.unit else event.app
-
-        ro_host = event.relation.data[data_loc].get("host")
-        ro_port = event.relation.data[data_loc].get("port")
+        ro_host = event.relation.data[event.unit].get("host")
+        ro_port = event.relation.data[event.unit].get("port")
 
         if (
             ro_host
@@ -262,7 +255,7 @@ class LcmCharm(CharmBase):
                 self.model.app.name,
                 self.port,
             )
-        except ValidationError as exc:
+        except ValueError as exc:
             logger.exception("Config/Relation data validation error")
             self.unit.status = BlockedStatus(str(exc))
             return