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

Netconf key elements are not serialized in specified order #363

Closed
wabain opened this issue Jan 20, 2017 · 1 comment
Closed

Netconf key elements are not serialized in specified order #363

wabain opened this issue Jan 20, 2017 · 1 comment
Labels

Comments

@wabain
Copy link

wabain commented Jan 20, 2017

The Python SDK places list keys before other elements when generating Netconf XML, but always sorts the key elements in alphabetical order. This behavior can cause XML generated by ydk by Cisco's ConfD.

The expected behavior is specified in RFCs 6020 and 7950, which state that:

The list's key nodes are encoded as subelements to the list's
identifier element, in the same order as they are defined within the
"key" statement.

Sample case, tested with 0.5.2 and master (cb522de):

ydk-id-order-bug.yang

module ydk-id-order-bug {
  namespace "http://example.org/ns/yang/ydk-id-order-bug";
  prefix "order-bug";

  list multi-key-list {
    key "c b";

    leaf a { type uint32; }
    leaf b { type uint32; }
    leaf c { type uint32; }
  }
}

Bundle file: ydk-id-order-bug.json

{
   "name": "ydk-id-order-bug",
   "version": "0.1.0",
   "ydk_version": "0.5.2",
   "models": {
       "file": [
           "ydk-id-order-bug.yang"
       ]
   }
}

Sample usage:

from ydk.providers import CodecServiceProvider
from ydk.services import CodecService

from ydk.models.ydk_id_order_bug.ydk_id_order_bug import MultiKeyList

model = MultiKeyList()

model.a = 1
model.b = 2
model.c = 3

svc = CodecService()
sp = CodecServiceProvider(type='xml')

print(svc.encode(sp, model))

## Output:
# <multi-key-list xmlns="http://example.org/ns/yang/ydk-id-order-bug">
#   <b>2</b>
#   <c>3</c>
#   <a>1</a>
# </multi-key-list>

## Expected output:
# <multi-key-list xmlns="http://example.org/ns/yang/ydk-id-order-bug">
#   <c>3</c>
#   <b>2</b>
#   <a>1</a>
# </multi-key-list>
@ghost ghost added the bug label Jan 25, 2017
@ghost
Copy link

ghost commented Feb 20, 2017

This will be fixed in the new YDK-Py infrastructure (ydk 0.6.0)

@ghost ghost closed this as completed Feb 20, 2017
@ghost ghost added the wontfix label Feb 20, 2017
@ghost ghost reopened this May 15, 2017
shgandhi added a commit to shgandhi/ydk-gen that referenced this issue May 27, 2017
* Updates order of serialization of key elements acc. to the RFCs
ghost pushed a commit that referenced this issue May 30, 2017
* Updates order of serialization of key elements acc. to the RFCs
@ghost ghost removed the wontfix label May 30, 2017
@ghost ghost closed this as completed May 30, 2017
shgandhi added a commit to shgandhi/ydk-gen that referenced this issue May 31, 2017
* Updates order of serialization of key elements acc. to the RFCs
shgandhi added a commit to shgandhi/ydk-gen that referenced this issue Jun 1, 2017
ghost pushed a commit that referenced this issue Jun 1, 2017
* Updates order of serialization of key elements acc. to the RFCs
ylil93 pushed a commit to ylil93/ydk-gen that referenced this issue Sep 14, 2017
…oDevNet#460)

* Updates order of serialization of key elements acc. to the RFCs
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