robshakir / pyangbind

A plugin for pyang that creates Python bindings for a YANG model.
Other
201 stars 121 forks source link

config: false Lists may not have a "key" sub-stmt / ordered-by #7

Closed robshakir closed 9 years ago

robshakir commented 9 years ago

Note: Two changes to resolve under this ticket:

According to RFC6020, a list that is config: false may not have a key statement - this is currently not supported in pyangbind.

Example module - yang/vendor/cisco/xr/530/Cisco-IOS-XR-cdp-oper.yang

        container neighbors {
          xr:xr-xml-map "cdp_oper:Neighbors";
          description "The CDP neighbor tables on this node";

          container details {
            xr:xr-xml-map "cdp_oper:DetailTable";
            description "The detailed CDP neighbor table";

            list detail {
              xr:xr-xml-map "cdp_oper:Detail";
              description
                "Detailed information about a CDP neighbor
                entry";
              leaf interface-name {
                xr:xr-xml-map "cdp_oper:InterfaceName";
                type xr:Interface-name;
                description "The interface name";
              }
              leaf device-id {
                xr:xr-xml-map "cdp_oper:DeviceID";
                type string;
                description "The neighboring device identifier";
              }
              uses CDP-NEIGHBOR;
            }
          }
aashaikh commented 9 years ago

We use a similar construct in the RIB model, where there may be a multitude of routes in the table with the same prefix/next-hop/etc. so creating a keyless list is useful since it's read-only.

would it make sense in this case to create a map with a system-generated key (e.g., uuid) that is just never accessed by the user?

btw, do you use an ordered collection for ordered-by: user lists?

robshakir commented 9 years ago

ordered-by is not yet supported, but I was planning to use a collections.OrderedDict - under the YANGList class (right now self._members there is a dict()).

There are a couple of options here - I would prefer to use a dict since otherwise YANGList needs to handle the fact that self._members might have multiple types.

robshakir commented 9 years ago

Resolved in 4fa7f47f2ac44c0bf9122517ffc1e82c36065867.