Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List with identityref key is not being encoded correctly for python bundle #718

Closed
ghost opened this issue Mar 21, 2018 · 1 comment · Fixed by #721
Closed

List with identityref key is not being encoded correctly for python bundle #718

ghost opened this issue Mar 21, 2018 · 1 comment · Fixed by #721
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Mar 21, 2018

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

Expected Behavior

The object should be correctly encoded

Current Behavior

Seeing erroneous payload

Steps to Reproduce

Use the below script

Your Script

from ydk.models.openconfig import openconfig_bgp \
    as oc_bgp
from ydk.models.openconfig import openconfig_bgp_types as oc_bgp_types

def config_bgp(bgp):
    """Add config data to bgp object."""
    # global configuration
    bgp.global_.config.as_ = 65001
    afi_safi = bgp.global_.afi_safis.AfiSafi()
    afi_safi.afi_safi_name = oc_bgp_types.IPV4UNICAST()
    afi_safi.config.afi_safi_name = oc_bgp_types.IPV4UNICAST()
    afi_safi.config.enabled = True
    bgp.global_.afi_safis.afi_safi.append(afi_safi)

    # configure IBGP peer group
    peer_group = bgp.peer_groups.PeerGroup()
    peer_group.peer_group_name = "IBGP"
    peer_group.config.peer_group_name = "IBGP"
    peer_group.config.peer_as = 65001
    peer_group.transport.config.local_address = "Loopback0"
    afi_safi = peer_group.afi_safis.AfiSafi()
    afi_safi.afi_safi_name = oc_bgp_types.IPV4UNICAST()
    afi_safi.config.afi_safi_name = oc_bgp_types.IPV4UNICAST()
    afi_safi.config.enabled = True
    peer_group.afi_safis.afi_safi.append(afi_safi)
    bgp.peer_groups.peer_group.append(peer_group)

    # configure IBGP neighbor
    neighbor = bgp.neighbors.Neighbor()
    neighbor.neighbor_address = "172.16.255.2"
    neighbor.config.neighbor_address = "172.16.255.2"
    neighbor.config.peer_group = "IBGP"
    bgp.neighbors.neighbor.append(neighbor)

crud.create(provider, bgp)

Logs

Enable logging and post the logs below

2018-03-21 16:22:04,039 - ydk - DEBUG - Top container path: openconfig-bgp:bgp
2018-03-21 16:22:04,039 - ydk - DEBUG - Looking to populate schemas for afi-safi[afi-safi-name='<ydk.models.openconfig.openconfig_bgp_types.IPV4UNICAST object at 0x1057a9468>']
2018-03-21 16:22:04,039 - ydk - DEBUG - Ready to populate schemas for afi-safi[afi-safi-name='<ydk.models.openconfig.openconfig_bgp_types.IPV4UNICAST object at 0x1057a9468>']
2018-03-21 16:22:04,039 - ydk - DEBUG - Getting new modules for afi-safi[afi-safi-name='<ydk.models.openconfig.openconfig_bgp_types.IPV4UNICAST object at 0x1057a9468>']
2018-03-21 16:22:04,039 - ydk - DEBUG - Getting new modules for afi-safi[afi-safi-name='<ydk.models.openconfig.openconfig_bgp_types.IPV4UNICAST object at 0x1057a9468>']
2018-03-21 16:22:04,040 - ydk - DEBUG - Getting child schema with path 'afi-safi[afi-safi-name='<ydk.models.openconfig.openconfig_bgp_types.IPV4UNICAST object at 0x1057a9468>']' in afi-safis
2018-03-21 16:22:04,040 - ydk - DEBUG - Getting data nodes with path 'afi-safi[afi-safi-name='<ydk.models.openconfig.openconfig_bgp_types.IPV4UNICAST object at 0x1057a9468>']'
2018-03-21 16:22:04,040 - ydk - DEBUG - Creating new data path 'afi-safi[afi-safi-name='<ydk.models.openconfig.openconfig_bgp_types.IPV4UNICAST object at 0x1057a9468>']' with value '' in 'afi-safis'
2018-03-21 16:22:04,040 - ydk - ERROR - Data is invalid according to the yang model. Error details: Unexpected character(s) '<' (<ydk.models.ope). Path: '/openconfig-bgp:bgp/global/afi-safis/afi-safi[afi-safi-name='<ydk.models.openconfig.openconfig_bgp_types.IPV4UNICAST object at 0x1057a9468>']/afi-safi-name'
Traceback (most recent call last):
  File "./nc-create-oc-bgp-40-ydk.py", line 108, in <module>
    crud.create(provider, bgp)
  File "/Users//p/lib/python3.6/site-packages/ydk/errors/error_handler.py", line 112, in helper
    return func(self, provider, entity, *args, **kwargs)
  File "/Users//p/lib/python3.6/site-packages/ydk/services/crud_service.py", line 45, in create
    return self._crud.create(provider, entity)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/contextlib.py", line 99, in __exit__
    self.gen.throw(type, value, traceback)
  File "/Users//p/lib/python3.6/site-packages/ydk/errors/error_handler.py", line 82, in handle_runtime_error
    _raise(_exc)
  File "/Users//p/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.YPYModelError:  Unexpected character(s) '<' (<ydk.models.ope). Path: /openconfig-bgp:bgp/global/afi-safis/afi-safi[afi-safi-name='<ydk.models.openconfig.openconfig_bgp_types.IPV4UNICAST object at 0x1057a9468>']/afi-safi-name

System Information

Using ydk-gen master branch with openconfig 0.1.4 bundle

@ghost ghost added the bug label Mar 21, 2018
@ghost ghost assigned ylil93 Mar 21, 2018
@ylil93
Copy link
Contributor

ylil93 commented Mar 22, 2018

Thanks for creating this issue @abhikeshav
I believe this issue rose after the native python issues change. My guess is since the sanity tests are passing, it has to do with unexpected behavior in retrieving the segment path. It seems to me that segment path retrieval for most cases will return a string, but in some cases the object printout is returned. My guess for these corner cases is where the object is a child list object.

Two things:

  1. investigate how GetSegmentPath() is being called in pytypes.py / how it's been implemented
  2. write add a test across cpp/py/go to cover cases like this in the future

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant