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

YFilter dropped when used with NetconfService and EntityCollection #803

Closed
ghost opened this issue Jun 19, 2018 · 1 comment
Closed

YFilter dropped when used with NetconfService and EntityCollection #803

ghost opened this issue Jun 19, 2018 · 1 comment
Labels

Comments

@ghost
Copy link

ghost commented Jun 19, 2018

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

Expected Behavior

From: https://communities.cisco.com/thread/92597
Below 2 scripts should produce same payloads.

Current Behavior

from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ipv4_ospf_cfg
from ydk.filters import YFilter  
from ydk.services import NetconfService                       
from ydk.services import Datastore
from ydk.providers import NetconfServiceProvider    

os=Cisco_IOS_XR_ipv4_ospf_cfg.Ospf()
os.yfilter = YFilter.create
                                
n = NetconfService()
provider = NetconfServiceProvider(address='<ip-addr>' , username='<>', password='<>')

With the above object, below 2 scripts are producing different payloads

Your Script

n.edit_config(provider,Datastore.running,[os])

produces below xml

  <edit-config>
    <target>
      <running/>
    </target>
    <config>
      <ospf xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-ospf-cfg"/>
    </config>
  </edit-config>
</rpc>
n.edit_config(provider,Datastore.running,os)

produces below xml

  <edit-config>
    <target>
      <running/>
    </target>
    <config>
      <ospf xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-ospf-cfg" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="create"/>
    </config>
  </edit-config>

System Information

ydk 0.7.2-dev
@ghost ghost added the bug label Jun 19, 2018
@ygorelik
Copy link
Collaborator

Fixed the issue in YDK-0.8.1.

Test Script

from __future__ import absolute_import

import sys
import unittest
import logging

from ydk.filters import YFilter  
from ydk.providers import NetconfServiceProvider
from ydk.services import NetconfService, Datastore

from test_utils import print_entity

from ydk.models.cisco_ios_xr import Cisco_IOS_XR_ipv4_ospf_cfg

def enable_logging(level):
    log = logging.getLogger('ydk')
    log.setLevel(level)
    handler = logging.StreamHandler()
    formatter = logging.Formatter(("%(asctime)s - %(name)s - %(levelname)s - %(message)s"))
    handler.setFormatter(formatter)
    log.addHandler(handler)

if __name__ == '__main__':
    enable_logging(logging.INFO)
    ncc = NetconfServiceProvider(address='10.30.110.84', username='admin', password='admin', port=830)
    root_schema = ncc.get_session().get_root_schema()
    ns = NetconfService()

    os=Cisco_IOS_XR_ipv4_ospf_cfg.Ospf()
    os.yfilter = YFilter.create

    ns.edit_config(ncc, Datastore.candidate, [os])

    ns.discard_changes(ncc)

Resulting Log

2019-01-11 09:59:04,853 - ydk - INFO - Path where models are to be downloaded: /home/yan/.ydk/10.30.110.84_830
2019-01-11 09:59:04,871 - ydk - INFO - Connected to 10.30.110.84 on port 830 using ssh with timeout of -1
2019-01-11 09:59:04,872 - ydk - INFO - Executing 'edit-config' RPC on [Cisco-IOS-XR-ipv4-ospf-cfg:ospf]
2019-01-11 09:59:04,904 - 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><ospf xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-ospf-cfg" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="create"/>
</config>
</edit-config>
</rpc>

2019-01-11 09:59:05,218 - ydk - INFO - ============= Reply RPC received from device =============
<?xml version="1.0"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="1">
  <ok/>
</rpc-reply>

2019-01-11 09:59:05,219 - ydk - INFO - Executing 'discard-changes' RPC
2019-01-11 09:59:05,220 - ydk - INFO - ============= Generated RPC to send to device =============
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"><discard-changes xmlns="urn:ietf:params:xml:ns:netconf:base:1.0"/>
</rpc>

2019-01-11 09:59:05,544 - ydk - INFO - ============= Reply RPC received from device =============
<?xml version="1.0"?>
<rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="2">
  <ok/>
</rpc-reply>

2019-01-11 09:59:05,544 - ydk - INFO - Disconnected from device

Note. The filter nc:operation="create" is present in the RPC as expected.

ygorelik pushed a commit to ygorelik/ydk-gen that referenced this issue Jan 11, 2019
ygorelik pushed a commit to ygorelik/ydk-gen that referenced this issue Jan 11, 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

1 participant