Commit 6e5f6759 authored by Lu Xu's avatar Lu Xu 👀

software/ors-amarisoft: fix ncclient waiting notification forever

The Ncclient does not have a timeout for taking notifications, causing it to wait indefinitely. This can result in the connection being lost while the waiting process is still ongoing.
parent 9f39dcad
...@@ -48,7 +48,7 @@ md5sum = 0450e9fa50844e4d6e51d608625c57f6 ...@@ -48,7 +48,7 @@ md5sum = 0450e9fa50844e4d6e51d608625c57f6
[ru_lopcomm_ncclient_common.py] [ru_lopcomm_ncclient_common.py]
_update_hash_filename_ = ru/lopcomm/ncclient_common.py _update_hash_filename_ = ru/lopcomm/ncclient_common.py
md5sum = 6f8d0592cc4b0b695cea5a0c25aafc4e md5sum = b3504313d232c2505a8c252ae9109c62
[ru_lopcomm_stats.jinja2.py] [ru_lopcomm_stats.jinja2.py]
_update_hash_filename_ = ru/lopcomm/stats.jinja2.py _update_hash_filename_ = ru/lopcomm/stats.jinja2.py
......
...@@ -103,10 +103,8 @@ class LopcommNetconfClient: ...@@ -103,10 +103,8 @@ class LopcommNetconfClient:
sub = self.conn.create_subscription() sub = self.conn.create_subscription()
self.logger.info('Subscription to %s successful' % (self.address,)) self.logger.info('Subscription to %s successful' % (self.address,))
def get_notification(self): def get_notification(self):
result = None
while result == None:
self.logger.debug('Waiting for notification from %s...' % (self.address,)) self.logger.debug('Waiting for notification from %s...' % (self.address,))
result = self.conn.take_notification(block=True) result = self.conn.take_notification(block=True, timeout=120)
if result: if result:
self.logger.debug('Got new notification from %s...' % (self.address,)) self.logger.debug('Got new notification from %s...' % (self.address,))
result_in_xml = result._raw result_in_xml = result._raw
...@@ -121,6 +119,8 @@ class LopcommNetconfClient: ...@@ -121,6 +119,8 @@ class LopcommNetconfClient:
self.software_json_logger.info('', extra={'data': json.dumps(data_dict)}) self.software_json_logger.info('', extra={'data': json.dumps(data_dict)})
else: else:
self.cfg_json_logger.info('', extra={'data': json.dumps(data_dict)}) self.cfg_json_logger.info('', extra={'data': json.dumps(data_dict)})
else:
raise TimeoutError
def edit_config(self, config_files): def edit_config(self, config_files):
for config_file in config_files: for config_file in config_files:
with open(config_file) as f: with open(config_file) as f:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment