aboutsummaryrefslogtreecommitdiffstats
path: root/src/python/netconf_server/netconf_change_listener_factory.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/python/netconf_server/netconf_change_listener_factory.py')
-rw-r--r--src/python/netconf_server/netconf_change_listener_factory.py26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/python/netconf_server/netconf_change_listener_factory.py b/src/python/netconf_server/netconf_change_listener_factory.py
index 9b9ff24..f023542 100644
--- a/src/python/netconf_server/netconf_change_listener_factory.py
+++ b/src/python/netconf_server/netconf_change_listener_factory.py
@@ -19,7 +19,6 @@
###
import logging
-
from netconf_server.netconf_app_configuration import NetconfAppConfiguration
from netconf_server.netconf_change_listener import NetconfChangeListener
from netconf_server.netconf_kafka_client import NetconfKafkaClient, provide_configured_kafka_client
@@ -35,18 +34,25 @@ class NetconfChangeListenerFactory(object):
self.app_configuration = app_configuration
def create(self) -> NetconfChangeListener:
- subscriptions = list()
- for module_name in self.modules_to_subscribe_names:
- subscriptions.append(
- ConfigChangeSubscriber(module_name)
+ try:
+ subscriptions = list()
+ for module_name in self.modules_to_subscribe_names:
+ subscriptions.append(
+ ConfigChangeSubscriber(module_name)
+ )
+ kafka_client = NetconfChangeListenerFactory._try_to_create_kafka_client(
+ self.app_configuration.kafka_host_name,
+ self.app_configuration.kafka_port
)
- kafka_client = NetconfChangeListenerFactory._try_to_create_kafka_client(
- self.app_configuration.kafka_host_name,
- self.app_configuration.kafka_port
- )
- return NetconfChangeListener(subscriptions, kafka_client, self.app_configuration.kafka_topic)
+ return NetconfChangeListener(subscriptions, kafka_client, self.app_configuration.kafka_topic)
+ except Exception as e:
+ raise NetconfChangeListenerException(e)
@staticmethod
def _try_to_create_kafka_client(kafka_host_name: str, kafka_port: int):
return provide_configured_kafka_client(kafka_host_name, kafka_port) # type: NetconfKafkaClient
+
+
+class NetconfChangeListenerException(Exception):
+ pass