CiscoDevNet / ydk-gen

Generate model-driven APIs from YANG models
http://ciscodevnet.github.io/ydk-gen/
Apache License 2.0
136 stars 74 forks source link

YModelError: Failed to resolve identityref #1058

Closed ldacol closed 2 years ago

ldacol commented 2 years ago

Issue tracker is ONLY used for reporting bugs. Please use the YDK Community for any support issues.

Expected Behavior

Leaf values with identityref mapped to module prefix should resolve correctly

Current Behavior

No mapping of module prefixes to module names. Preceding the module name to the identity such as install-protocol-eq : openconfig-policy-types: BGP allows the generation of the XML code however it is unclear the system will accept configuration in which the header xmlns is present in the tag.

Steps to Reproduce

Run the configuration in the script below through decode/encode functions

Your Script

openconfig-routing-policy:routing-policy:
  policy-definitions:
    policy-definition:
      - name: PS-CTR-EXPORT-IPV4
        statements:
          statement:
            - name: NEXT-HOP-SELF
              conditions:
                config:
                  install-protocol-eq : BGP
              actions:
                bgp-actions:
                  config:
                    set-next-hop: 10.0.0.1

Logs

Enable logging and post the logs below

Traceback (most recent call last):
  File "convert.py", line 63, in <module>
    print(yang_yaml_to_xml(ARGS['yaml_file']))
  File "convert.py", line 47, in yang_yaml_to_xml
    decoded_json_yang = CODEC.decode(JSON_PROVIDER, config_json_yang)
  File "/opt/cteneteng/lib/python3.6/site-packages/ydk/errors/error_handler.py", line 112, in helper
    return func(self, provider, entity, *args, **kwargs)
  File "/opt/cteneteng/lib/python3.6/site-packages/ydk/services/codec_service.py", line 140, in decode
    return self._decode(provider, payload_holder, subtree)
  File "/opt/cteneteng/lib/python3.6/site-packages/ydk/services/codec_service.py", line 174, in _decode
    root_data_node = codec_service.decode(root_schema, payload, provider.encoding)
RuntimeError: YCoreError: YCodecError:Invalid JSON data (missing begin-array).. Path: /openconfig-routing-policy:routing-policy/defined-sets/prefix-sets/prefix-set[name='DEFAULT']/prefixes/prefix

System Information

Python 3.6, Linux RHEL 7.9

ygorelik commented 2 years ago

Please read carefully your error message. It states: "Invalid JSON data (missing begin-array).. ", meaning that translation from YAML to JSON was incorrect. Have you validated the JSON string? What is it? Regarding the identityref value. It must include prefix to specify module, from which the identity is taken. In JSON encoding the value of the identityref leaf should have format: "module:value". In XML encoding the module is identified by its namespace. If you agree with my findings, please close the issue.

ldacol commented 2 years ago

It was my finding as well that adding the module:value would allow the encoding to XML. I have some issues though with the XML code when it comes to be applied to the device as it would return an error. As it may be device dependent closing this issue