CiscoDevNet / ydk-gen

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

openconfig bundle bgp neigbors apply-policy field is str instead of List[str] #1027

Closed rinhomdf closed 3 years ago

rinhomdf commented 4 years ago

Openconfig bundle coming with 0.8.5 (0.1.8) has a type mismatch according to what is reported in the generated docs.

import_policy list of policy names in sequence to be applied on receiving a routing update in the current context, e.g., for the current peer group, neighbor, address family, etc

type: list of str

Expected Behavior

The following apply_policy defintion should not return YModel error of incorrect type

bgp_neighbors: openconfig_bgp.Bgp.Neighbors
neighbor = bgp_neighbors.Neighbor()
...
neighbor.apply_policy.config.import_policy = ["policy1", "policy2"]

Current Behavior

Instead it returns a YModel Error exception when passing values

bgp_neighbors: openconfig_bgp.Bgp.Neighbors
neighbor = bgp_neighbors.Neighbor()
...
neighbor.apply_policy.config.import_policy = ["policy1", "policy2"]

ydk.errors.YModelError: Invalid value ['policy1', 'policy2'] for 'import_policy'. Got type: 'list'. Expected types: 'str'

It has to be replaced for now with:

neighbor.apply_policy.config.import_policy = "policy1"

System Information

python 3.7.7 ydk 0.8.5 ydk-models-openconfig 0.1.8

ygorelik commented 3 years ago

This is not a bug, but a request of new feature, YDK API enhancement.

The _neighbor.apply_policy.config.importpolicy is YLeafList object, therefore multiple value assignment could be done this way:

neighbor.apply_policy.config.import_policy.extend(["policy1", "policy2"])

or

neighbor.apply_policy.config.import_policy = "policy1"
neighbor.apply_policy.config.import_policy = "policy2"