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

YDK5.5 can not create a top entity as a list #888

Open
xulleon opened this issue Mar 8, 2019 · 1 comment
Open

YDK5.5 can not create a top entity as a list #888

xulleon opened this issue Mar 8, 2019 · 1 comment
Assignees

Comments

@xulleon
Copy link

xulleon commented Mar 8, 2019

Issue tracker is ONLY used for reporting bugs. Please use the YDK Community for any support issues.
In YDK 5.5, if a module has a top entity as a list. Currently there is no way for YDK to generate a list entity. If it is not a top entity, I used to gnerate the entity and then by refer to its parent, which is the list entity. However, since the entity is at top, it dose not have a parent. Therefore the usual way to refer it parent as list does not work.

Expected Behavior

Take BGP neighbor as an example. after a neighbor instance is created as nbr. then its parent will be the neighbor list. nbr.parent.append(nbr)

Current Behavior

For Cisco-ios-xr-vrf-cfg, the top entity is Vrf, after it was created, i.e. vrf. vrf has not parent as it is on the top level. therefore, there is no way to refer its parent as the vrf_list.

Steps to Reproduce

find a module, which has a top entity as a list. simply generate the top entity, then dir the entity, you will find parent is not in the list.

Your Script


Logs

Enable logging and post the logs below


System Information

@ygorelik
Copy link
Collaborator

ygorelik commented Mar 9, 2019

Reproduced the issue in ydk-0.8.1 with ydktest model bundle, which defines top-level list node oc_pattern/oc-a.
Test to run:

    def test_top_list(self):
        from ydk.models.ydktest import oc_pattern
        obj_A = oc_pattern.OcA()
        obj_A.a = 'Hello'
        obj_A.b.b = 'Hello'
        
        obj_B = oc_pattern.OcA()
        obj_B.a = 'GoodBye'
        obj_B.b.b = 'GoodBye'

        self.crud.create(self.ncc, [obj_A, obj_B])
        
        obj_f = oc_pattern.OcA()
        read = self.crud.read(self.ncc, obj_f)
        print_entity(read, self.root_schema)

The test produced the following results:

2019-03-09 11:21:56,787 - ydk - INFO - Executing CRUD create operation on [oc-pattern:oc-A[a='Hello'], oc-pattern:oc-A[a='GoodBye']]
2019-03-09 11:21:56,787 - ydk - INFO - Executing 'edit-config' RPC on [oc-pattern:oc-A[a='Hello'], oc-pattern:oc-A[a='GoodBye']]
2019-03-09 11:21:56,795 - ydk - INFO - ============= Generated RPC to send to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><edit-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <target>
    <candidate/>
  </target>
  <config><oc-A xmlns="http://cisco.com/ns/yang/oc-pattern" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="merge">
  <a>Hello</a>
  <B>
    <b>Hello</b>
  </B>
</oc-A>
<oc-A xmlns="http://cisco.com/ns/yang/oc-pattern" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="merge">
  <a>GoodBye</a>
  <B>
    <b>GoodBye</b>
  </B>
</oc-A>
</config>
</edit-config>
</rpc>

2019-03-09 11:21:56,814 - ydk - INFO - ============= Reply RPC received from device =============
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="4">
  <ok/>
</rpc-reply>

2019-03-09 11:21:56,815 - ydk - INFO - Executing 'commit' RPC
2019-03-09 11:21:56,815 - ydk - INFO - ============= Generated RPC to send to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><commit xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
</rpc>

2019-03-09 11:21:56,849 - ydk - INFO - ============= Reply RPC received from device =============
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="5">
  <ok/>
</rpc-reply>

2019-03-09 11:21:56,849 - ydk - INFO - Operation succeeded
pydev debugger: warning: trying to add breakpoint to file that does not exist: /usr/local/lib/python2.7/dist-packages/ydk/providers/_encoder.py (will have no effect)
pydev debugger: warning: trying to add breakpoint to file that does not exist: /usr/local/lib/python2.7/dist-packages/ydk/providers/_validator.py (will have no effect)
pydev debugger: warning: trying to add breakpoint to file that does not exist: /usr/local/lib/python2.7/dist-packages/ydk/providers/_validator.py (will have no effect)
Error removing breakpoint: Breakpoint id not found: /usr/local/lib/python2.7/dist-packages/ydk/types/py_types.py id: 14. Available ids: [2, 12]

pydev debugger: warning: trying to add breakpoint to file that does not exist: /usr/local/lib/python2.7/dist-packages/ydk/providers/_provider_plugin.py (will have no effect)
pydev debugger: warning: trying to add breakpoint to file that does not exist: /usr/local/lib/python2.7/dist-packages/ydk/providers/_encoder.py (will have no effect)
pydev debugger: warning: trying to add breakpoint to file that does not exist: /usr/local/lib/python2.7/dist-packages/ydk/providers/_validator.py (will have no effect)
pydev debugger: warning: trying to add breakpoint to file that does not exist: /usr/local/lib/python2.7/dist-packages/ydk/providers/_encoder.py (will have no effect)
pydev debugger: warning: trying to add breakpoint to file that does not exist: /usr/local/lib/python2.7/dist-packages/ydk/providers/_validator.py (will have no effect)
2019-03-09 11:22:14,866 - ydk - INFO - Executing CRUD read operation on [oc-pattern:oc-A[a='None']]
2019-03-09 11:22:14,866 - ydk - INFO - Executing 'get' RPC on [oc-pattern:oc-A[a='None']]
2019-03-09 11:22:14,869 - ydk - INFO - ============= Generated RPC to send to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><get xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <filter><oc-A xmlns="http://cisco.com/ns/yang/oc-pattern"/></filter>
</get>
</rpc>

2019-03-09 11:22:14,879 - ydk - INFO - ============= Reply RPC received from device =============
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="6">
  <data>
    <oc-A xmlns="http://cisco.com/ns/yang/oc-pattern">
      <a>GoodBye</a>
      <B>
        <b>GoodBye</b>
      </B>
    </oc-A>
    <oc-A xmlns="http://cisco.com/ns/yang/oc-pattern">
      <a>Hello</a>
      <B>
        <b>Hello</b>
      </B>
    </oc-A>
  </data>
</rpc-reply>


=====>  Printing DataNode: '/oc-pattern:oc-A[a='GoodBye']'
ok

----------------------------------------------------------------------
Ran 1 test in 99.960s

OK
<oc-A>
  <a>GoodBye</a>
  <B>
    <b>GoodBye</b>
  </B>
</oc-A>

2019-03-09 11:23:36,510 - ydk - INFO - Disconnected from device

Note, that YDK allowed create the top-level list with multiple entries and Netconf worked perfectly well. But at the end the YDK failed decode multiple list elements and returned single entry.

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

No branches or pull requests

2 participants