Questions tagged [ietf-netmod-yang]

YANG is a data modeling language originally designed to model data manipulated by the Network Configuration Protocol (NETCONF). Since the publication of YANG version 1 (RFC6020), YANG has been used or proposed to be used for other protocols (e.g., RESTCONF and CoMI). Use this tag for questions related to the YANG data modeling language and tools that process it.

YANG is the data modeling language for the Network Configuration Protocol (NETCONF). The name is an acronym for Yet Another Next Generation. The YANG data modeling language was developed by the NETMOD working group (NETMOD WG) in the Internet Engineering Task Force (IETF) and was published as RFC 6020 in October 2010. A new maintenance release of the core YANG specification has been published by the NETMOD WG in August 2016 (YANG 1.1, RFC 7950).

YANG is a language originally designed to model data for the NETCONF protocol. A YANG module defines a hierarchy of data that can be used for NETCONF-based operations, including configuration, state data, Remote Procedure Calls (RPCs), and notifications. This allows a complete description of all data sent between a NETCONF client and server. Although out of scope for YANG specification, YANG can also be used with protocols other than NETCONF.

YANG models the hierarchical organization of data as a tree in which each node has a name, and either a value or a set of child nodes. It provides clear and concise descriptions of the nodes, as well as the interaction between those nodes.

An example YANG module:

module example-forest {

  namespace "http://example.org/example-forest";
  prefix et;
  revision 2015-11-26;

  import ietf-yang-types {
    prefix yang;
  }

  typedef tree-species {
    type string;
    description "Defines the species of a tree.";
  }

  typedef a-tree {
    type leafref {
      path "/et:forest/et:trees/et:tree/et:id";
    }
    description "Represents a known tree.";
  }

  /*
   * Our forest.
   */
  container forest {
    description "A forest full of trees and potentially other stuff.";

    container trees {
      description "The trees of a forest.";

      list tree {
        description "Describes one tree in a forest.";        
        key id;

        leaf id {
          type string;
          description "A unique identifier of a tree.";
        }
        leaf species {
          type et:tree-species;
          description "The tree species.";
          mandatory true;
        }        
        leaf description {
          type string;
          description "A short description of the tree.";
        }
        leaf location {
          type string;
          mandatory true;
          description "The location of the tree";
        }
        leaf height {
          type uint8;
          units "meters";
          description "The height of the tree.";
        }

      }
    }
  }

  /**
   * Cutting schedules.
   */
  container cutting-schedules {
    description "Our cutting schedules.";

    list cutting-schedule {
      description "A cutting schedule.";    
      key "name date";

      leaf name {
        type string;
        description "A name for the schedule.";
      }
      leaf date {
        type yang:date-and-time;
        description "When to start cutting down trees.";
      }
      leaf-list tree {
        type a-tree;
        min-elements 1;
        description "Which trees to cut down.";
      }
    }
  }
}

Sample data in XML encoding:

<?xml version="1.0" encoding="utf-8"?>
<data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">

  <forest xmlns="http://example.org/example-forest">
    <trees>
      <tree>
        <id>Lisa</id>
        <species>pine</species>
        <location>Right in the centre of the forest.</location>
        <height>15</height>
      </tree>
      <tree>
        <id>Bob</id>
        <species>oak</species>
        <location>At the first Y split of the path through forest.</location>
        <height>20</height>
      </tree>
      <tree>
        <id>John</id>
        <species>birch</species>
        <description>Struck by lightning a few years ago.</description>
        <location>Next to the burnt down tree-house debris.</location>
        <height>10</height>
      </tree>
    </trees>
  </forest>

  <cutting-schedules xmlns="http://example.org/example-forest">
    <cutting-schedule>
      <name>High priority cleanup</name>
      <date>2015-11-30T16:00:00Z</date>
      <tree>Bob</tree>
      <tree>John</tree>
    </cutting-schedule>
  </cutting-schedules>

</data>

Learn more about YANG here:

161 questions
0
votes
1 answer

usage of yang model ietf-routing

I am trying to add config data according to these yang modules: https://github.com/mbj4668/pyang/blob/master/modules/ietf/ietf-routing.yang https://github.com/mbj4668/pyang/blob/master/modules/ietf/ietf-ipv4-unicast-routing.yang I am getting error…
m.divya.mohan
  • 2,261
  • 4
  • 24
  • 34
0
votes
1 answer

How to augment list from one module to another and add leafs YANG

Suppose I have two modules, I would like to extend one list with new leafs. module A { list deviceList { key name; leaf name{ } leaf hostname{ } } } and I would like to augment it to another…
marhyno
  • 677
  • 1
  • 8
  • 20
0
votes
1 answer

Unable to access Yang capabilities via Python ncclient

I have a Cisco CSRv1000 with Cisco XE version 16.8.1a. I have enabled netconf-yang and when i run the command ssh -2 -s admin@172.30.43.115 netconf it displays the YANG on CLI. However if i run the following code on python, it gives an error…
Mervin Hemaraju
  • 1,921
  • 2
  • 22
  • 71
0
votes
1 answer

leaf name and type name can be same in yang

Below example is correct yang statement or not? it is valid by pyang but JNC is unable to process grouping TLId { leaf age { type Age; mandatory true; } } typedef Age { type string { pattern '[0-9][0-9]'; } } Please suggest
0
votes
1 answer

Config or operational data from pyang confd

Can we determine if it is a configuration or operational data model from the pyang model in confD, If I do not have permission to read the actual yang file Eg: module: my-test +--rw something +--rw leaf1? string +--rw leaf2? …
Sravya
  • 661
  • 8
  • 9
0
votes
1 answer

editing 'config false' leaf in YANG

How do I change 'config false' leafs and update the values in my server so when a client make get-config command he will get the updated value? leaf state { type enumeration { enum DISABLED { description "array carrier is not…
0
votes
1 answer

Cisco NSO Yang packages succeed to load but it's oper-status remains down

Does anybody ever played with Cisco NSO (it is basically a YANG/XML model issue, no need to be NSO expert) ? If yes, thanks for any help about this issue: I am developping a new Yang model using Cisco NSO tools. Find here the Yang model: module…
0
votes
1 answer

Opendaylight feature installation error which is not providing the required output Even after JDK 11 installation and maven 3.6

While doing feature:install odl-restconf using karaf ODL installation guide here at https://docs.opendaylight.org/en/stable-magnesium/getting-started-guide/installing_opendaylight.html I am getting below error and couldn't able to figure it out,…
0
votes
3 answers

Error "Duplicate namespace in XML input" when retrieving a list over NETCONF using Opendaylight

I am using Opendaylight (release 0.10.1) as NETCONF client to send requests to a Netopeer2 server. My YANG model is a third-party model consisting of several modules which contain, among other attributes, several list elements. This translates into…
0
votes
1 answer

Calling a 'C' function inside yang file

Can we call a 'C' function in yang file ? Or is there any way to accomplish this ? Basically I want to call a 'C' fun which will return a integer value and use that in my .yang file. Below is my leaf structure : leaf memory { type int16; default…
Vinayak49
  • 77
  • 2
  • 8
0
votes
1 answer

In Yang Modelling, I want to implement a leaf which can accept values from range 10 to 1000 in multiples of 10

In Yang Modelling, I want to implement a leaf(as shown below) which can accept values ranging from 10 to 1000. The catch here is the value should be in multiple of 10's. Ex : 10,20,30,40...1000 My current leaf structure is : leaf range-limit { …
Vinayak49
  • 77
  • 2
  • 8
0
votes
1 answer

How does instance-identifier looks like in yang model?

AS far as I understand, instance-identifier type has an XPath statement which points to some node is a tree. And what's next? How does instance-identifier identify this node? How do I apply instance-identifier to the node it points to? Or do I get…
Olga
  • 119
  • 1
  • 1
  • 12
0
votes
0 answers

Go few levels up in the nested object in js

How can we go up to several levels in the nested object beginning from one of it's deeply nested child? i'm dealing with yang language and in some objects I find a "path" substatement like "../../../../some node". So I need to go 4 levels up to…
Olga
  • 119
  • 1
  • 1
  • 12
0
votes
1 answer

How to get the specific child element from the parent in restconf

How to get the specific child element from the the parent in restconf, but at the same time to get all the parent's child in restconf? for example: my module module system{ leaf name{ type string; } leaf version{ type string; …
Shira E
  • 25
  • 5
0
votes
1 answer

How to implement recursion in YANG model using leafref?

I have the following XML that I want to model with YANG. The XML contains a list of nodes and each node contains a list of neighbor nodes. 1 2 3
anegru
  • 1,023
  • 2
  • 13
  • 29