Loading src/device/service/drivers/gnmi_openconfig/GnmiSessionHandler.py +19 −9 Original line number Diff line number Diff line Loading @@ -98,12 +98,7 @@ 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: Loading @@ -113,9 +108,7 @@ class GnmiSessionHandler: self._logger.debug('[GnmiSessionHandler:get] str_path = {:s}'.format(str(str_path))) # 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) parent_namespace = parent_segment.split(':')[0] if ':' in parent_segment else None if parent_namespace not in supported_models: self._logger.warning('Skipping path %s because model %s is not advertised', str_path, parent_namespace) continue Loading @@ -141,7 +134,24 @@ class GnmiSessionHandler: metadata = [('username', self._username), ('password', self._password)] timeout = None # GNMI_SUBSCRIPTION_TIMEOUT = int(sampling_duration) # Try the original request first try: get_reply = self._stub.Get(get_request, metadata=metadata, timeout=timeout) except Exception as e: self._logger.warning('Get request failed with original paths: %s', e) self._logger.info('Retrying with non-namespaced paths...') fallback_request = GetRequest() fallback_request.type = GetRequest.DataType.ALL fallback_request.encoding = get_request.encoding for path in get_request.path: path_str = path_to_string(path) fallback_request.path.append(path_from_string(path_str.split(':', 1)[1] if ':' in path_str else path_str)) get_reply = self._stub.Get(fallback_request, metadata=metadata, timeout=timeout) self._logger.debug('get_reply={:s}'.format(grpc_message_to_json_string(get_reply))) results = [] Loading src/device/service/drivers/gnmi_openconfig/tools/Capabilities.py +0 −7 Original line number Diff line number Diff line Loading @@ -26,11 +26,6 @@ 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))) Loading @@ -41,8 +36,6 @@ 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', []) Loading Loading
src/device/service/drivers/gnmi_openconfig/GnmiSessionHandler.py +19 −9 Original line number Diff line number Diff line Loading @@ -98,12 +98,7 @@ 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: Loading @@ -113,9 +108,7 @@ class GnmiSessionHandler: self._logger.debug('[GnmiSessionHandler:get] str_path = {:s}'.format(str(str_path))) # 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) parent_namespace = parent_segment.split(':')[0] if ':' in parent_segment else None if parent_namespace not in supported_models: self._logger.warning('Skipping path %s because model %s is not advertised', str_path, parent_namespace) continue Loading @@ -141,7 +134,24 @@ class GnmiSessionHandler: metadata = [('username', self._username), ('password', self._password)] timeout = None # GNMI_SUBSCRIPTION_TIMEOUT = int(sampling_duration) # Try the original request first try: get_reply = self._stub.Get(get_request, metadata=metadata, timeout=timeout) except Exception as e: self._logger.warning('Get request failed with original paths: %s', e) self._logger.info('Retrying with non-namespaced paths...') fallback_request = GetRequest() fallback_request.type = GetRequest.DataType.ALL fallback_request.encoding = get_request.encoding for path in get_request.path: path_str = path_to_string(path) fallback_request.path.append(path_from_string(path_str.split(':', 1)[1] if ':' in path_str else path_str)) get_reply = self._stub.Get(fallback_request, metadata=metadata, timeout=timeout) self._logger.debug('get_reply={:s}'.format(grpc_message_to_json_string(get_reply))) results = [] Loading
src/device/service/drivers/gnmi_openconfig/tools/Capabilities.py +0 −7 Original line number Diff line number Diff line Loading @@ -26,11 +26,6 @@ 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))) Loading @@ -41,8 +36,6 @@ 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', []) Loading