Loading src/device/service/drivers/gnmi_openconfig/GnmiSessionHandler.py +8 −15 Original line number Diff line number Diff line Loading @@ -272,33 +272,26 @@ class GnmiSessionHandler: else: # Handle boolean values if isinstance(v, bool): # These fields should remain as actual boolean values according to OpenConfig schema if k in {'enabled', 'auto-negotiate', 'forwarding-viable', 'loopback-mode'}: # Keep as boolean - don't convert to string continue elif 'status' in k: # FIX: YANG schemas expect string enums, not boolean values # Convert ALL boolean values to strings for YANG compatibility if 'status' in k: obj[k] = 'UP' if v else 'DOWN' changed += 1 else: # For other boolean fields, convert to string boolean # Convert to string boolean for all fields obj[k] = 'true' if v else 'false' changed += 1 # Handle string values that look like booleans but are actually enums elif isinstance(v, str): v_lower = v.lower() if v_lower in {'true', 'false'}: if k in {'enabled', 'auto-negotiate', 'forwarding-viable', 'loopback-mode', 'hold-time', 'carrier-detect', 'suppress-fec', 'fec-mode'}: # Convert string boolean to actual boolean for these fields obj[k] = (v_lower == 'true') changed += 1 elif 'status' in k: if 'status' in k: # Convert string boolean to UP/DOWN for status fields obj[k] = 'UP' if v_lower == 'true' else 'DOWN' changed += 1 else: # For other fields, keep as string enum to avoid YANG validation errors # Don't convert to boolean - keep as "true"/"false" strings changed += 1 # FIX: Keep all other string booleans as strings # Don't convert to actual booleans - YANG expects string enums # This prevents the "Invalid non-string-encoded enumeration value" error elif isinstance(obj, list): for item in obj: changed += self._coerce_boolean_enums_to_strings(item) Loading Loading
src/device/service/drivers/gnmi_openconfig/GnmiSessionHandler.py +8 −15 Original line number Diff line number Diff line Loading @@ -272,33 +272,26 @@ class GnmiSessionHandler: else: # Handle boolean values if isinstance(v, bool): # These fields should remain as actual boolean values according to OpenConfig schema if k in {'enabled', 'auto-negotiate', 'forwarding-viable', 'loopback-mode'}: # Keep as boolean - don't convert to string continue elif 'status' in k: # FIX: YANG schemas expect string enums, not boolean values # Convert ALL boolean values to strings for YANG compatibility if 'status' in k: obj[k] = 'UP' if v else 'DOWN' changed += 1 else: # For other boolean fields, convert to string boolean # Convert to string boolean for all fields obj[k] = 'true' if v else 'false' changed += 1 # Handle string values that look like booleans but are actually enums elif isinstance(v, str): v_lower = v.lower() if v_lower in {'true', 'false'}: if k in {'enabled', 'auto-negotiate', 'forwarding-viable', 'loopback-mode', 'hold-time', 'carrier-detect', 'suppress-fec', 'fec-mode'}: # Convert string boolean to actual boolean for these fields obj[k] = (v_lower == 'true') changed += 1 elif 'status' in k: if 'status' in k: # Convert string boolean to UP/DOWN for status fields obj[k] = 'UP' if v_lower == 'true' else 'DOWN' changed += 1 else: # For other fields, keep as string enum to avoid YANG validation errors # Don't convert to boolean - keep as "true"/"false" strings changed += 1 # FIX: Keep all other string booleans as strings # Don't convert to actual booleans - YANG expects string enums # This prevents the "Invalid non-string-encoded enumeration value" error elif isinstance(obj, list): for item in obj: changed += self._coerce_boolean_enums_to_strings(item) Loading