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

YDK return value of YANG action missing some attributes #871

Closed
ghost opened this issue Feb 5, 2019 · 2 comments
Closed

YDK return value of YANG action missing some attributes #871

ghost opened this issue Feb 5, 2019 · 2 comments
Assignees
Labels
Milestone

Comments

@ghost
Copy link

ghost commented Feb 5, 2019

Currently, the result of a running a YANG action is returned as a datanode here. However, when the return value of this function is encoded using YDK path Codec, it seems to be missing some parts of the data.

@ghost ghost changed the title YDK return value of YANG action seems to miss some attributes YDK return value of YANG action missing some attributes Feb 5, 2019
@ghost ghost added the bug label Feb 5, 2019
@nitishv
Copy link

nitishv commented Mar 19, 2019

Please find attached a test script and log used to re-produce this issue.

nso_action_rpc_test_code.txt

ydk.log

Thanks
Nitish (nvashish@cisco.com)
Crosswork, Cisco

@ygorelik ygorelik self-assigned this Mar 25, 2019
ygorelik pushed a commit that referenced this issue Mar 26, 2019
ygorelik pushed a commit that referenced this issue Mar 28, 2019
@ygorelik
Copy link
Collaborator

ygorelik commented Mar 29, 2019

The tailf Yang models use extensions defined in tailf-commmon.yang, including definition of sync-from node. This feature is not supported by YDK, which causes the described symptoms. All the Yang model extensions are simply dropped in YDK.

In order to provide some ways to analyze RPC data received from device, it was developed new API function, which returns data as a string (str):

    str NetconfSession.execute_netconf_operation( Rpc )

Here is the script with this new feature:

from ydk.providers import NetconfServiceProvider
from ydk.path import Repository
from ydk.services import Datastore
from ydk.path import Codec
from ydk.types import EncodingFormat
import logging
logger = logging.getLogger('ydk')

router_ip = '192.168.123.12'

provider = NetconfServiceProvider(repo=Repository('/opt/robot/data/cache'), address='192.168.123.111', username='nso', password='cisco123', port=2022)

data = '''<devices xmlns="http://tail-f.com/ns/ncs"><device><name>%s</name><sync-from/></device></devices>'''%router_ip

rpc = provider.get_session().get_root_schema().create_rpc("tailf-actions:action")
rpc.get_input_node().create_datanode("data", data)

result = provider.get_session().execute_netconf_operation(rpc)
print(result)

The script produces this result:

2019-03-29 00:28:55,593 - ydk - INFO - Connected to 192.168.123.111 on port 2022 using ssh with timeout of -1
2019-03-29 00:28:55,593 - ydk - INFO - ============= Sending RPC to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><action xmlns="http://tail-f.com/ns/netconf/actions/1.0">
  <data><devices xmlns="http://tail-f.com/ns/ncs"><device><name>192.168.123.12</name><sync-from/></device></devices></data>
</action>
</rpc>
2019-03-29 00:29:02,392 - ydk - INFO - ============= Received RPC from device =============
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
  <data>
    <devices xmlns="http://tail-f.com/ns/ncs">
      <device>
        <name>192.168.123.12</name>
        <sync-from>
          <result>true</result>
        </sync-from>
      </device>
    </devices>
  </data>
</rpc-reply>

<data>
    <devices xmlns="http://tail-f.com/ns/ncs">
      <device>
        <name>192.168.123.12</name>
        <sync-from>
          <result>true</result>
        </sync-from>
      </device>
    </devices>
  </data>
2019-03-29 00:29:02,392 - ydk - INFO - Disconnected from device
root@robot-nca-66dfd4ff7f-88dm7:/var/log/robot#

ygorelik pushed a commit to ygorelik/ydk-gen that referenced this issue Apr 2, 2019
@ghost ghost added this to the 0.8.3 milestone Apr 2, 2019
ghost pushed a commit that referenced this issue May 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants