netconf-wg / restconf

9 stars 4 forks source link

using JSON-optimized-data-strucutere versus the existing YANG XML-optimized-data-strucutres in REST #64

Closed slieberth closed 8 years ago

slieberth commented 8 years ago

Standards are essential to the success of networking, and unless there is major improvement by deviating from the standard, it is best practice to follow standards.

we are developing a open-source router project and the intial though was to go for YANG. However I see some complexitiy in the YANG data-strucutr, which is not necesseraly needed in JSON.

Have there been thoughts to use a JSON-optimized-data-strucutere instead of the XML-optimized-YANG data-strucutres. I think Netconf and Yang and bound closely together, If we move to an REST api, which offers JSON support, also a more efficient data-structure could be applied:

In the examples below: JSON optimized code has 10 lines and 6 levels of hierarchy. the YANG compliant equivalent has 18 lines and 9 levels of hierarchy. That is an imporvemnt of 30-40%, also the JSON model is much easier to read.

e.g. this JSON data-strucutre (in YAML represenation)

bgp:
  neighbors:
    33.33.33.33:
      description: BGP-neighbor-description-3
      peer-as: 3333
      peer-type: external
      afi-safis:
        ipv4-unicast:
          enabled: true
          max-prefixes: 900001
          restart-timer: 61

has the same information content as the YANG-OpenConfig compliant datastructure (also in YAML format):

bgp:
  neighbors:
  - neighbor:
      neighbor-address: 33.33.33.33
      config:
        description: BGP-neighbor-description-3
        peer-as: 3333
        peer-type: external
      afi-safis:
      - afi-safi:
          afi-safi-name: ipv4-unicast
          config:
            enabled: true
          ipv4-unicast:
            prefix-limit:
              config:
                max-prefixes: 900001
                restart-timer: 61

Basically the JSON model would not use YANG lists, but just containers, leaf and leaf-Lists.

feedback appreciated

best regards Stefan

abierman commented 8 years ago

RESTCNF uses a JSON encoding defined for YANG

https://www.ietf.org/id/draft-ietf-netmod-yang-json-10.txt