03-02-2022 06:42 AM - edited 03-02-2022 06:43 AM
Hello,
I am getting the following error
Traceback (most recent call last): File "convert.py", line 54, in <module> print(yang_yaml_to_xml(ARGS['yaml_file'])) File "convert.py", line 40, in yang_yaml_to_xml yang_xml = CODEC.encode(XML_PROVIDER, decoded_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 78, in encode return self._encode(provider, entity_holder, pretty, subtree) File "/opt/cteneteng/lib/python3.6/site-packages/ydk/services/codec_service.py", line 110, in _encode return result File "/export/apps/python/3.6.9/lib/python3.6/contextlib.py", line 99, in __exit__ self.gen.throw(type, value, traceback) File "/opt/cteneteng/lib/python3.6/site-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error _raise(_exc) File "/opt/cteneteng/lib/python3.6/site-packages/ydk/errors/error_handler.py", line 54, in _raise exec("raise exc from None") File "<string>", line 1, in <module> ydk.errors.YModelError: Value "None" does not satisfy the constraint "([0-9]+\.\.[0-9]+)|exact" (range, length, or pattern). Path: /openconfig-routing-policy:routing-policy/defined-sets/prefix-sets/prefix-set[name='DEFAULT']/prefixes/prefix[ip-prefix='0.0.0.0/0'][masklength-range='None']/masklength-range
whilst running a python code to decode yang yaml into xml below snippet of configuration. Running ydk_models_openconfig-0.1.8-py3.6 models and libydk-0.8.5-1. Any assistance appreciated
Thanks and regards
Luca
--- openconfig-routing-policy:routing-policy: policy-definitions: policy-definition: - name: TEST-1-EXPORT-IPV4 statements: statement: - name: NEXT-HOP-SELF conditions: config: install-protocol-eq: openconfig-policy-types:BGP actions: openconfig-bgp-policy:bgp-actions: config: set-next-hop: 10.0.0.1 - name: TEST-2-EXPORT-IPV4 statements: statement: - name: AGGREGATE-ACCEPT conditions: config: install-protocol-eq: openconfig-policy-types:LOCAL_AGGREGATE actions: config: policy-result: ACCEPT_ROUTE - name: TEST-1-IMPORT-IPV4 statements: statement: - name: DEFAULT-REJECT conditions: match-prefix-set: config: prefix-set: DEFAULT actions: config: policy-result: ACCEPT_ROUTE defined-sets: prefix-sets: prefix-set: - name: DEFAULT prefixes: prefix: - ip-prefix: 0.0.0.0/0 - masklength-range: exact
03-02-2022 08:19 AM
That looks like a bug in libyang library code. Could you please open new issue here.
In the meantime I would suggest you use XmlSubtreeCodec, which skips data value validation.
Yan Gorelik
03-02-2022 05:25 PM
Submitted new issue to GitHub.
Thanks for the quick reply and workaround.
Luca
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: