CiscoDevNet / ydk-gen

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

Missing local validation for static route prefixes #385

Closed marumer closed 7 years ago

marumer commented 7 years ago

Hi, Working on a presentation focused on a value of local validation, I create a wrong ip prefix for a static route but I keep receiving a ydk.errors.YPYServiceProviderError instead of a ydk.errors.YPYDataValidationError and I have confirmed below that the message comes from the Netconf server. I have tried obvious wrong string like 1.1.1???, with the same result ... no local validation.

This is the code: router_static = xr_ip_static_cfg.RouterStatic() vrf_unicast = router_static.default_vrf.address_family.vrfipv4.vrf_unicast vrf_prefix = vrf_unicast.vrf_prefixes.VrfPrefix() vrf_prefix.prefix = "1.1.1.A" # Note that this is a wrong IP address vrf_prefix.prefix_length = 24 vrf_next_hop_next_hop_address = vrf_prefix.vrf_route.vrf_next_hop_table.VrfNextHopNextHopAddress() vrf_next_hop_next_hop_address.next_hop_address = "192.168.10.5" vrf_prefix.vrf_route.vrf_next_hop_table.vrf_next_hop_next_hop_address.append(vrf_next_hop_next_hop_address) vrf_unicast.vrf_prefixes.vrf_prefix.append(vrf_prefix)

and the logging: CREATE operation initiated

1.1.1.A 24 192.168.10.5 1.1.1.A 24 192.168.10.5 protocol bad-element error ns1:router-static/ns1:default-vrf/ns1:address-family/ns1:vrfipv4/ns1:vrf-unicast/ns1:vrf-prefixes/ns1:vrf-prefix[prefix = '1.1.1.A' and prefix-length = '24']/ns1:prefix prefix

CREATE operation completed

111pontes commented 7 years ago

The current release of YDK-Py (0.5.3) may miss some regular expression checks depending on the pattern involved. The new YDK-Py infrastructure (expected to be in 0.6.0) will take care of these issues.