pyangbind icon indicating copy to clipboard operation
pyangbind copied to clipboard

openconfig-acl.yang ietf json dumps sequence-id key as string

Open AbhishekGtHub opened this issue 4 years ago • 1 comments

I am trying to generate IETF json for openconfig-acl and using dumps method as follows

Python 2.7.17 (default, Nov 19 2019, 22:13:04) 
[GCC 9.1.0] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import openconfig_acl   
>>> from pyangbind.lib import pybindJSON
>>> base = openconfig_acl.openconfig_acl()
>>> acl = base.acl.acl_sets.acl_set.add("Test ACL_IPV4")
>>> entry100 = acl.acl_entries.acl_entry.add(100)
>>> entry100.config.sequence_id = 100
>>> print(pybindJSON.dumps(base, mode='ietf', indent=2))
{
  "openconfig-acl:acl": {
    "acl-sets": {
      "acl-set": [
        {
          "acl-entries": {
            "acl-entry": [
              {
                "config": {
                  "sequence-id": 100  <<<<<<<<<< Integer
                }, 
                "sequence-id": "100"  <<<<<<<<< String. Leafref to config/sequence-id
              }
            ]
          }, 
          "type": "ACL_IPV4", 
          "name": "Test"
        }
      ]
    }
  }
}

Sequence ID is a integer as per openconfig-acl.yang model https://github.com/openconfig/public/blob/master/release/models/acl/openconfig-acl.yang#L379 https://github.com/openconfig/public/blob/master/release/models/acl/openconfig-acl.yang#L337

and Integers are used for add API when creating the entry100 object but when dumps is called its in string format. Is this expected? Is there any option to generate the json such that the leafref sequence-id is also integer? Thanks.

AbhishekGtHub avatar Jun 06 '20 20:06 AbhishekGtHub

Duplicate of Issue #139

mike-albano avatar Jun 07 '20 15:06 mike-albano

Closing as duplicate of https://github.com/robshakir/pyangbind/issues/139 -- will try to look into this soon.

xavier-contreras avatar Jul 28 '23 19:07 xavier-contreras