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

Issue with correctly encoding operational model data #452

Closed
111pontes opened this issue May 22, 2017 · 2 comments
Closed

Issue with correctly encoding operational model data #452

111pontes opened this issue May 22, 2017 · 2 comments
Labels

Comments

@111pontes
Copy link
Collaborator

111pontes commented May 22, 2017

In YDK-Py 0.5.4, filter data is ignored by parent objects. For example, the following code attempts to only read BGP neighbor data:

bgp = xr_ipv4_bgp_oper.Bgp()  # create filter object

instance = bgp.instances.Instance()
instance.instance_name = "default"
neighbor = instance.instance_active.default_vrf.neighbors.Neighbor()
instance.instance_active.default_vrf.neighbors.neighbor.append(neighbor)
bgp.instances.instance.append(instance)

# read data from NETCONF device
bgp = crud.read(provider, bgp)

Instead, it retrieves all data:

2017-05-22 10:18:54,857 - ydk.providers._provider_plugin - DEBUG - 
<rpc xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:a78c4ef5-d8a5-416e-a7c2-ec859b2f2fab">
  <get>
    <filter type="subtree">
      <bgp xmlns="http://cisco.com/ns/yang/Cisco-IOS-XR-ipv4-bgp-oper"/>
    </filter>
  </get>
</rpc>

Specifying, the most specific object can be used as a workaround:

neighbor = crud.read(provider, bgp.instances.instance[0].instance_active.default_vrf.neighbors.neighbor[0])

@ghost ghost added the bug label May 23, 2017
@ghost
Copy link

ghost commented May 26, 2017

The issue seems that the 0.5.4 encoder cannot encode any operational data. For example, using openconfig-bgp.Bgp class, the state data is left out when creating the payload :

from ydk.models.openconfig.openconfig_bgp import Bgp
from ydk.providers import CodecServiceProvider
from ydk.services import CodecService

codec=CodecService()
codec_p=CodecServiceProvider(type='xml')

f = Bgp()
q = Bgp.Neighbors.Neighbor()
q.neighbor_address = '1.2.3.4'
q.state.description='test'
f.neighbors.neighbor.append(q)
codec.encode(codec_p,f)
Encoding operation initiated
Result of encoding: 
<bgp xmlns="http://openconfig.net/yang/bgp">
  <neighbors>
    <neighbor>
      <neighbor-address>1.2.3.4</neighbor-address>
    </neighbor>
  </neighbors>
</bgp>

Confirmed that this issue is not there in ydk 0.6.0-alpha for this model. Also tested Cisco-IOS-XR-ipv4-bgp-oper and encoding seems to work fine there

 print(codec.encode(codec_p,f))
<bgp xmlns="http://openconfig.net/yang/bgp">
  <neighbors>
    <neighbor>
      <neighbor-address>1.2.3.4</neighbor-address>
      <state>
        <description>test</description>
      </state>
    </neighbor>
  </neighbors>
</bgp>


@ghost ghost changed the title Filter data ignored in children objects Issue with correctly encoding operational model data May 31, 2017
@ghost
Copy link

ghost commented May 31, 2017

The problem is this line which is present in all of the generated model APIs. If the container/list is not config, we are always returning False in _has_data().

@ghost ghost closed this as completed in f8a3b9f May 31, 2017
ylil93 pushed a commit to ylil93/ydk-gen that referenced this issue Sep 14, 2017
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

No branches or pull requests

1 participant