From 9bdf44ad7a64aff4673d50caa36e42fbbbef1d77 Mon Sep 17 00:00:00 2001 From: Tobias Waldekranz Date: Mon, 27 Mar 2023 10:02:27 +0200 Subject: [PATCH] mech: Play around with a native yang model --- src/mech/clixon.xml.in | 2 +- src/mech/yang/device.yang | 32 +++++++++++++++ src/mech/yang/infix-if-bridge.yang | 64 ++++++++++++++++++++++++++++++ src/mech/yang/infix-if-lag.yang | 39 ++++++++++++++++++ src/mech/yang/infix-if-veth.yang | 24 +++++++++++ src/mech/yang/infix-if-vlan.yang | 35 ++++++++++++++++ src/mech/yang/infix-if.yang | 32 +++++++++++++++ src/mech/yang/infix-native.yang | 8 ++++ src/mech/yang/infix.yang | 59 +++++++++------------------ 9 files changed, 254 insertions(+), 41 deletions(-) create mode 100644 src/mech/yang/device.yang create mode 100644 src/mech/yang/infix-if-bridge.yang create mode 100644 src/mech/yang/infix-if-lag.yang create mode 100644 src/mech/yang/infix-if-veth.yang create mode 100644 src/mech/yang/infix-if-vlan.yang create mode 100644 src/mech/yang/infix-if.yang create mode 100644 src/mech/yang/infix-native.yang diff --git a/src/mech/clixon.xml.in b/src/mech/clixon.xml.in index 71d22dab..414eff24 100644 --- a/src/mech/clixon.xml.in +++ b/src/mech/clixon.xml.in @@ -9,7 +9,7 @@ ietf-system:ntp-udp-port @DATAROOTDIR@/clixon @DATAROOTDIR@/yang - infix + device exec @LIBDIR@/clixon/backend @LIBDIR@/clixon/netconf diff --git a/src/mech/yang/device.yang b/src/mech/yang/device.yang new file mode 100644 index 00000000..fa7e536a --- /dev/null +++ b/src/mech/yang/device.yang @@ -0,0 +1,32 @@ +module device { + yang-version 1.1; + namespace "urn:kernelkit:yang:device"; + prefix device; + + import ietf-datastores { + prefix ds; + } + + import ietf-system { + prefix sys; + } + + import infix { + prefix ix; + } + + import clixon-autocli { + prefix autocli; + } + + description + "Base model + "; + + revision 2023-02-10 { + description + "Initial revision."; + reference + "N/A"; + } +} diff --git a/src/mech/yang/infix-if-bridge.yang b/src/mech/yang/infix-if-bridge.yang new file mode 100644 index 00000000..f0dca806 --- /dev/null +++ b/src/mech/yang/infix-if-bridge.yang @@ -0,0 +1,64 @@ +submodule infix-if-bridge { + yang-version 1.1; + belongs-to infix { + prefix ix; + } + + include infix-if; + + augment "/native/interfaces/interface/type" { + case bridge { + container bridge { + presence bridge; + description + "Bridge configuration"; + + container vlans { + list vlan { + key vid; + + leaf vid { + type uint16; + } + + leaf-list untagged { + type interface-ref; + + must "deref(.)/../bridge-port/bridge = ../../../../name" { + error-message + "All interfaces must be attached to this bridge"; + } + } + leaf-list tagged { + type interface-ref; + } + } + } + } + } + } + augment "/native/interfaces/interface/port" { + case bridge-port { + container bridge-port { + description + "Bridge port specific configuration"; + + leaf bridge { + type interface-ref; + mandatory true; + description + "Bridge interface to which this interface is attached"; + + must "deref(.)/../bridge" { + error-message + "Must refer to a bridge interface"; + } + } + + leaf pvid { + type uint16; + } + } + } + } +} diff --git a/src/mech/yang/infix-if-lag.yang b/src/mech/yang/infix-if-lag.yang new file mode 100644 index 00000000..36190430 --- /dev/null +++ b/src/mech/yang/infix-if-lag.yang @@ -0,0 +1,39 @@ +submodule infix-if-lag { + yang-version 1.1; + belongs-to infix { + prefix ix; + } + + include infix-if; + + augment "/native/interfaces/interface/type" { + case lag { + container lag { + presence lag; + description + "Link aggregation configuration"; + } + } + } + + augment "/native/interfaces/interface/port" { + case lag-port { + container lag-port { + description + "LAG port configuration"; + + leaf lag { + type interface-ref; + mandatory true; + description + "LAG interface to which this interface is attached"; + + must "deref(.)/../lag" { + error-message + "Must refer to a LAG interface"; + } + } + } + } + } +} diff --git a/src/mech/yang/infix-if-veth.yang b/src/mech/yang/infix-if-veth.yang new file mode 100644 index 00000000..281521c5 --- /dev/null +++ b/src/mech/yang/infix-if-veth.yang @@ -0,0 +1,24 @@ +submodule infix-if-veth { + yang-version 1.1; + belongs-to infix { + prefix ix; + } + + include infix-if; + + augment "/native/interfaces/interface/type" { + case veth { + container veth { + description + "Virtual ethernet pair specific configuration"; + + leaf peer { + type interface-ref; + mandatory true; + description + "Peer veth interface to which this interface is connected"; + } + } + } + } +} diff --git a/src/mech/yang/infix-if-vlan.yang b/src/mech/yang/infix-if-vlan.yang new file mode 100644 index 00000000..ae58d93d --- /dev/null +++ b/src/mech/yang/infix-if-vlan.yang @@ -0,0 +1,35 @@ +submodule infix-if-vlan { + yang-version 1.1; + belongs-to infix { + prefix ix; + } + + include infix-if; + + typedef vid { + type uint16 { + range "1..4095"; + } + } + + augment "/native/interfaces/interface/type" { + case vlan { + container vlan { + description + "VLAN specific configuration"; + + leaf interface { + type interface-ref; + mandatory true; + description + "Lower interface from which the specified VLAN is demuxed"; + } + + leaf id { + type vid; + mandatory true; + } + } + } + } +} diff --git a/src/mech/yang/infix-if.yang b/src/mech/yang/infix-if.yang new file mode 100644 index 00000000..33e99cdb --- /dev/null +++ b/src/mech/yang/infix-if.yang @@ -0,0 +1,32 @@ +submodule infix-if { + yang-version 1.1; + belongs-to infix { + prefix ix; + } + + include infix-native; + + typedef interface-ref { + type leafref { + path "/native/interfaces/interface/name"; + } + description + "This type is used by data models that need to reference + interfaces."; + } + + augment "/native" { + container interfaces { + list interface { + key "name"; + + leaf name { + type string; + } + + choice type; + choice port; + } + } + } +} diff --git a/src/mech/yang/infix-native.yang b/src/mech/yang/infix-native.yang new file mode 100644 index 00000000..143099bc --- /dev/null +++ b/src/mech/yang/infix-native.yang @@ -0,0 +1,8 @@ +submodule infix-native { + yang-version 1.1; + belongs-to infix { + prefix ix; + } + + container native; +} diff --git a/src/mech/yang/infix.yang b/src/mech/yang/infix.yang index 178eee50..44a6acf3 100644 --- a/src/mech/yang/infix.yang +++ b/src/mech/yang/infix.yang @@ -1,46 +1,25 @@ module infix { - yang-version 1.1; - namespace "urn:kernelkit:infix"; - prefix ix; + yang-version 1.1; + namespace "urn:kernelkit:yang:infix"; + prefix ix; - import ietf-datastores { - prefix ds; - } + include infix-native; + include infix-if; + include infix-if-bridge; + include infix-if-lag; + include infix-if-veth; + include infix-if-vlan; - import ietf-system { - prefix sys; - } - - import ietf-interfaces { - prefix if; - } - import ietf-ip { - prefix ip; - } - import iana-if-type { - prefix ianaift; - } - - import clixon-autocli { - prefix autocli; - } + organization "Kernelkit"; + contact + "https://github.com/kernelkit/"; + description + "Infix's native system model"; + revision 2023-03-17 { description - "Base model - "; - - revision 2023-02-10 { - description - "Initial revision."; - reference - "N/A"; - } - revision 2023-03-16 { - description "Add timezone deviations for system/clock."; - reference "N/A"; - } - - deviation /sys:system/clock/timezone-utc-offset { - deviate not-supported; - } + "Initial revision."; + reference + "github.com/kernelkit/infix"; + } }