Skip to content
Snippets Groups Projects
Commit 87e715aa authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Device - gNMI OpenConfig Driver:

- Refining code
parent 56449dc0
No related branches found
No related tags found
1 merge request!299Resolve "(CTTC) Fix CI/CD pipeline end-to-end tests not passing"
......@@ -40,7 +40,6 @@ class GnmiSessionHandler:
self._use_tls = settings.get('use_tls', False)
self._channel : Optional[grpc.Channel] = None
self._stub : Optional[gNMIStub] = None
self._yang_handler = None
self._monit_thread = None
self._yang_handler = YangHandler()
self._subscriptions = Subscriptions()
......
......@@ -80,14 +80,19 @@ class InterfaceHandler(_Handler):
yang_ipv4_addr.create_path('config/ip', address_ip)
yang_ipv4_addr.create_path('config/prefix-length', address_prefix)
LOGGER.info('YangHandler Data:')
for path, dnode in yang_handler.get_data_paths().items():
LOGGER.debug('|-> {:s}: {:s}'.format(str(path), json.dumps(dnode.print_dict())))
str_path = '/interfaces/interface[name={:s}]'.format(if_name)
str_data = yang_if.print_mem('json')
json_data = json.loads(str_data)
json_data = json_data['openconfig-interfaces:interface'][0]
str_data = json.dumps(json_data)
is_error = False
LOGGER.warning('Releasing...')
# List elements to release:
LOGGER.warning('Objects to release:')
#LOGGER.warning('Releasing...')
while not objects_to_free.empty():
LOGGER.warning('Getting...')
try:
......@@ -96,42 +101,23 @@ class InterfaceHandler(_Handler):
LOGGER.warning('Item is None')
continue
try:
type_obj = type(obj)
LOGGER.warning('Releasing[type]: {:s}'.format(str(type_obj)))
except:
LOGGER.exception('Releasing[type]: <failed>')
try:
str_obj = str(obj)
if str_obj is not None:
LOGGER.warning('Releasing[str]: {:s}'.format(str_obj))
except:
LOGGER.exception('Releasing[str]: <failed>')
try:
repr_obj = repr(obj)
if repr_obj is not None:
LOGGER.warning('Releasing[repr]: {:s}'.format(str(repr_obj)))
except:
LOGGER.exception('Releasing[repr]: <failed>')
try:
LOGGER.warning('Releasing: {:s} => {:s}'.format(
str(obj.path()), str(obj.print_mem('json'))
))
LOGGER.warning('Freeing...')
obj.free()
LOGGER.warning('Free done')
except:
LOGGER.exception('Something went wrong...')
is_error = True
break
LOGGER.warning('Releasing[type]: {:s}'.format(str(type(obj))))
LOGGER.warning('Releasing: {:s} => {:s}'.format(
str(obj.path()), str(obj.print_mem('json'))
))
#try:
# LOGGER.warning('Freeing...')
# obj.free()
# LOGGER.warning('Free done')
#except:
# LOGGER.exception('Something went wrong...')
# is_error = True
# break
except queue.Empty:
LOGGER.warning('No more objects...')
continue
if not is_error:
LOGGER.warning('Release done')
#LOGGER.warning('Release done')
return str_path, str_data
def parse(
......
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