Commit 7491396f authored by Pedro Duarte's avatar Pedro Duarte
Browse files

add edbug logs

parent b9d8d474
Loading
Loading
Loading
Loading
+19 −2
Original line number Diff line number Diff line
@@ -71,6 +71,7 @@ class GnmiSessionHandler:
            self._channel = get_grpc_channel(self._address, self._port, self._use_tls, self._logger)
            self._stub = gNMIStub(self._channel)
            self._capabilities = check_capabilities(self._stub, self._username, self._password, timeout=120)
            self._logger.info('Connected and capabilities retrieved: %s', self._capabilities)
            self._monit_thread = MonitoringThread(
                self._stub, self._logger, self._settings, self._in_subscriptions, self._out_samples)
            self._monit_thread.start()
@@ -88,6 +89,8 @@ class GnmiSessionHandler:
        if len(resource_keys) == 0: resource_keys = ALL_RESOURCE_KEYS
        chk_type('resources', resource_keys, list)
        
        self._logger.info('Processing resource keys: %s', resource_keys)

        parsing_results = []

        get_request = GetRequest()
@@ -95,6 +98,12 @@ class GnmiSessionHandler:
        get_request.encoding = Encoding.Value(self._encoding) if self._encoding else Encoding.JSON_IETF
        #get_request.use_models.add() # kept empty: return for all models supported
        supported_models = self._capabilities.get('supported_models', set())
        self._logger.info('Supported models from capabilities: %s', supported_models)
        
        # If no capabilities were retrieved, log a warning but proceed with all paths
        if not supported_models:
            self._logger.warning('No supported models found in capabilities, proceeding with all paths')
            supported_models = set()  # Empty set means no filtering
        for i,resource_key in enumerate(resource_keys):
            str_resource_name = 'resource_key[#{:d}]'.format(i)
            try:
@@ -102,10 +111,16 @@ class GnmiSessionHandler:
                self._logger.debug('[GnmiSessionHandler:get] resource_key = {:s}'.format(str(resource_key)))
                str_path = get_path(resource_key)
                self._logger.debug('[GnmiSessionHandler:get] str_path = {:s}'.format(str(str_path)))
                parent_namespace = str_path.split(':')[0].strip('/') if ':' in str_path else None
                if parent_namespace is not None and parent_namespace not in supported_models:
                # Extract namespace from path (e.g., "openconfig-platform" from "/openconfig-platform:components")
                parent_segment = str_path.strip('/').split('/')[0]
                parent_namespace = parent_segment.split(':')[0].strip('/') if ':' in parent_segment else None
                self._logger.debug('Extracted namespace: %s from path: %s', parent_namespace, str_path)
                self._logger.debug('Supported models: %s, checking if %s is in it', supported_models, parent_namespace)
                if parent_namespace not in supported_models:
                    self._logger.warning('Skipping path %s because model %s is not advertised', str_path, parent_namespace)
                    continue
                
                self._logger.debug('Adding path to GET request: %s', str_path)
                get_request.path.append(path_from_string(str_path))
            except Exception as e: # pylint: disable=broad-except
                MSG = 'Exception parsing {:s}: {:s}'
@@ -117,6 +132,8 @@ class GnmiSessionHandler:
        if len(parsing_results) > 0:
            return parsing_results

        self._logger.info('Final GET request paths: %s', [path_to_string(p) for p in get_request.path])
        
        # If no valid paths were added (e.g., all filtered by unsupported models), skip the Get call
        if len(get_request.path) == 0:
            self._logger.warning('No GET paths requested after capability filtering; returning empty result set')
+7 −0
Original line number Diff line number Diff line
@@ -26,6 +26,11 @@ def check_capabilities(

    data = grpc_message_to_json(reply)
    
    # Debug logging
    import logging
    logger = logging.getLogger(__name__)
    logger.info('Raw capabilities response: %s', data)

    gnmi_version = data.get('gNMI_version')
    if gnmi_version is None or gnmi_version != '0.7.0':
        raise Exception('Unsupported gNMI version: {:s}'.format(str(gnmi_version)))
@@ -36,6 +41,8 @@ def check_capabilities(
        if isinstance(supported_model, dict) and 'name' in supported_model
    }
    
    logger.info('Extracted supported models: %s', supported_models)

    supported_encodings = {
        supported_encoding
        for supported_encoding in data.get('supported_encodings', [])