Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: [802.3_YANG] Yanglint for config validatation



In your 'load' statements, it looks like you loaded the same module twice.  I think you wanted 'cn' and 'ci' instead of two 'cn' modules from Qcz.

$ yanglint

> load iana-if-type

> load ieee802-dot1ab-lldp

> load ieee802-dot1q-lldp-basic-tlv

> load ieee802-dot1q-lldp-evb-tlv

> load ieee802-dot1q-lldp-dcbx-tlv

> load ieee802-dot1q-lldp-cn-tlv

> load ieee802-dot1q-lldp-cn-tlv

> load ieee802-dot1q-lldp-tr-tlv

> data  -t config   -f json test-lldp_basic1.xml


On Wed, Jun 10, 2020 at 12:30 PM Don Fedyk <dfedyk@xxxxxxxx> wrote:

Hi

 

(I’m hoping the message makes it through the reflectors after re-subscribing ).

I used Yanglint on the lldp modules. 802.1Qcz 

Attached is a test file and some output.  Note I fixed some warnings in yanglint. (yanglint require full prefixes in the YANG file.)

 

Using yanglint for this is fairly straight forward but the config it a bit tedious.

How I do it:

I  create an XML file (sample attached) that has the following format:

 

<if:interfaces

   xmlns:if="urn:ietf:params:xml:ns:yang:ietf-interfaces"

   xmlns:ia="urn:ietf:params:xml:ns:yang:iana-if-type">

<!—the prefix is shortened to a small set “if” etc  you can use the full one but the xml is verbose.-->

<if:interface>

      <if:name>eth0</if:name>

      <if:type>ia:ethernetCsmacd</if:type>

      <!--if:oper-status>up</if:oper-status-->

    </if:interface>

 

The XML I generate from the tree file an using only read/write objects.  You can do read only objects too but then you need to fill in a lot of data that may no be obvious and the conditional yang kicks in.  I tried interfaces and it keep wanting more and more data.

You can use the output of pyang that produces xml. I find it faster to build my own tags.

You need to follow the tree structure but the order in the tree is not strict.

I use group substitution to change “interface” into <if:interface> and duplicate and change the second occurrence to  </if:interface>

 

Then with a file of begin/end tags I add the tree structure.

 

<ll:lldp

  xmlns:ll="urn:ieee:std:802.1AB:yang:ieee802-dot1ab-lldp"

  xmlns:ab="urn:ieee:std:802.1Q:yang:ieee802-dot1ab-types"

  xmlns:llb="urn:ieee:std:802.1Q:yang:ieee802-dot1q-lldp-basic-tlv"

  xmlns:lle="urn:ieee:std:802.1Q:yang:ieee802-dot1q-lldp-evb-tlv" 

  xmlns:lld="urn:ieee:std:802.1Q:yang:ieee802-dot1q-lldp-dcbx-tlv" 

  xmlns:llc="urn:ieee:std:802.1Q:yang:ieee802-dot1q-lldp-cn-tlv" 

  xmlns:lli="urn:ieee:std:802.1Q:yang:ieee802-dot1q-lldp-ci-tlv" 

  xmlns:llr="urn:ieee:std:802.1Q:yang:ieee802-dot1q-lldp-tr-tlv" 

  xmlns:rt="urn:ietf:params:xml:ns:yang:ietf-routing-types"

  xmlns:yt="urn:ietf:params:xml:ns:yang:ietf-yang-types"

  xmlns:if="urn:ietf:params:xml:ns:yang:ietf-interfaces"

  xmlns:ia="urn:ietf:params:xml:ns:yang:iana-if-type">

  <ll:lldp-id>lldp1</ll:lldp-id>

  <ll:message-fast-tx>100</ll:message-fast-tx>

  <ll:message-tx-hold-multiplier>2</ll:message-tx-hold-multiplier>

  <ll:message-tx-interval>30</ll:message-tx-interval>

  <ll:reinit-delay>2</ll:reinit-delay>

  <ll:tx-credit-max>5</ll:tx-credit-max>

  <ll:tx-fast-init>4</ll:tx-fast-init>

  <ll:notification-interval>30</ll:notification-interval>

  <llr:topology-recognition-tlv-extension>

    <llr:topology-level>2</llr:topology-level>

  </llr:topology-recognition-tlv-extension>

 

Then I run Yanglint and load the modules.  I prefer the json output.

$ yanglint

> load iana-if-type

> load ieee802-dot1ab-lldp

> load ieee802-dot1q-lldp-basic-tlv

> load ieee802-dot1q-lldp-evb-tlv

> load ieee802-dot1q-lldp-dcbx-tlv

> load ieee802-dot1q-lldp-cn-tlv

> load ieee802-dot1q-lldp-cn-tlv

> load ieee802-dot1q-lldp-tr-tlv

> data  -t config   -f json test-lldp_basic1.xml

 

{

  "ietf-interfaces:interfaces": {

    "interface": [

      {

        "name": "eth0",

        "type": "iana-if-type:ethernetCsmacd",

        "ieee802-dot1q-bridge:bridge-port": {

 

        }

      },

      {

        "name": "eth1",

        "type": "iana-if-type:ethernetCsmacd",

        "ieee802-dot1q-bridge:bridge-port": {

 

        }

      }

    ]

  },

  "ieee802-dot1ab-lldp:lldp": [

    {

      "lldp-id": "lldp1",

      "message-fast-tx": 100,

      "message-tx-hold-multiplier": 2,

      "message-tx-interval": 30,

      "reinit-delay": 2,

      "tx-credit-max": 5,

      "tx-fast-init": 4,

      "notification-interval": 30,

      "ieee802-dot1q-lldp-tr-tlv:topology-recognition-tlv-extension": {

        "topology-level": 2

 

See the attached files for a complete setup.

 

Cheers

Don

 

 


To unsubscribe from the STDS-802-3-YANG list, click the following link: https://listserv.ieee.org/cgi-bin/wa?SUBED1=STDS-802-3-YANG&A=1