clicon / clixon

YANG-based toolchain including NETCONF and RESTCONF interfaces and an interactive CLI
http://www.clicon.org/
Other
208 stars 70 forks source link

Enum from YANG-Model #478

Closed temabeloglinski closed 5 months ago

temabeloglinski commented 7 months ago

Hi Olof! I have a question about enumeration from yang-model. Is it possible by any method using Clixon to select data not only about the configured values, but also about all possible values? For example, via restconf.

olofhagsand commented 7 months ago

You can get the YANG schema itself via netconf or restconf.

temabeloglinski commented 7 months ago

@olofhagsand I understand correctly that through netconf or restconf you can get a similar structure with all enumeration values?

  |     |     +--rw layer2
  |     |        +--rw config
  |     |           +--rw ethernet
  |     |           |  +--rw config
  |     |           |  |  +--rw mac-address?           oc-yang:mac-address
  |     |           |  |  +--rw duplex-mode            enumeration
  |     |           |  |  +--rw port-speed             enumeration
  |     |           |  |  +--rw enable-flow-control?   boolean
  |     |           |  +--ro state
  |     |           |     +--ro mac-address?           oc-yang:mac-address
  |     |           |     +--ro duplex-mode            enumeration
  |     |           |     +--ro port-speed             enumeration
  |     |           |     +--ro enable-flow-control?   boolean
  |     |           +--rw switched-vlan
  |     |              +--rw config
  |     |              |  +--rw interface-mode?   oc-vlan-types:vlan-mode-type
  |     |              |  +--rw native-vlan?      oc-vlan-types:vlan-id
  |     |              |  +--rw access-vlan?      oc-vlan-types:vlan-id
  |     |              |  +--rw trunk-vlans*      union
  |     |              +--ro state
  |     |                 +--ro interface-mode?   oc-vlan-types:vlan-mode-type
  |     |                 +--ro native-vlan?      oc-vlan-types:vlan-id
  |     |                 +--ro access-vlan?      oc-vlan-types:vlan-id
  |     |                 +--ro trunk-vlans*      union
olofhagsand commented 7 months ago

Yes,in RFC 6022, for example,ietf-netconf-monitoring.yang defines container schemas state and get-schema RPC, to retrieve the YANG definitions. Clixon sypports this by default. See option CLICON_NETCONF_MONITORING. There is also the module-set including a module list in RFC8525 ietf-yang-library.yang that lists the modules. That is about getting the schema.

Regarding enum values, a recent commit improved the enum/value API by two new functions: yang_enum2int()and yang_enum_int_value().

Maybe this is more what you are looking for?