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
1
vote
2 answers

Can a container inside a grouping be augmented in YANG?

The first module contains this: module a { namespace "my:namespace"; prefix a; grouping mygrouping { container firstcontainer { list modules { leaf firstmodule; leaf secondmodule; …
fatiha.kafou
  • 71
  • 1
  • 13
1
vote
1 answer

Is it possible to have a must statement in a YANG file where we can use arithmetic operations?

Can I use arithmetic operations in a must stament in a YANG file? example: container interface { leaf ifNumber{ type uint32; } must "ifNumber" % 8 = 0 { error-message "Must be multiple of 8"; } }
Vasi Marin
  • 453
  • 1
  • 3
  • 9
1
vote
1 answer

Add data if 'config false' YANG

Can i sent POST(not PUT or PATCH) command if the config statement is false? How? module system { namespace "system:uri"; prefix "sys"; leaf id { config false; type string; } } It's possible to define the leaf as a read-only in…
1
vote
1 answer

Non readable - YANG

There is a way to define non readable data in yang? module system{ leaf name{ type string; } leaf password{ type string; } } So in this case 'password' is the non readable data.
Shira E
  • 25
  • 5
1
vote
1 answer

YANG 1.1: RFC7950 Modules and Submodules backward compatibility

I'm quite new in YANG. While reading Module and Submodule section, I confused about the access right of submodule. RFC7950#section-5.1 indicated that: "A submodule can reference any definition in the module it belongs to and in all submodules…
Dat Nguyen
  • 13
  • 2
1
vote
1 answer

How to model a list in YANG with no common child elements?

I have an XML that looks like this. value value value value How can this list be modeled in YANG? The problem here is…
anegru
  • 1,023
  • 2
  • 13
  • 29
1
vote
1 answer

Netconf edit-config

Is this RPC valid? fe-0/0/0
Ram
  • 301
  • 2
  • 12
1
vote
1 answer

Netconf Notifications

RFC 5277 defines notification replay support. Just wondering what customer problems this notification replay can solve? What could be the need to scan through list of past notifications? At any point of time, controllers can always fire "get" RPC…
Ram
  • 301
  • 2
  • 12
1
vote
1 answer

Not able to provide deicmal fields less than that is defined in fraction-digits

I am working with yang (RFC 6020). I have a leaf node 'Frequency' in yang. Frequency field is of type decimal64 and fraction-digits are defined as 6 and range from -90.000000 to 90.000000. While trying to validate and save, following…
Rahil Khan
  • 13
  • 4
1
vote
1 answer

Pyang support for Yang 1.1

In our Application we use Pyang (pyang 1.7.3) for our Yang support. As of today our Application is complaint to RFC 6020, Yang 1.0. We would like to upgrade our Application to Support Yang 1.1, RFC7950. Any idea is Pyang 1.7.3 compatible with Yang…
Ram
  • 301
  • 2
  • 12
1
vote
1 answer

config=false node when mandatory

I have a Yang model which defines a config=false node which is mandatory too. Should I return that node as an empty XML node in get rpc response, even when my app does not support it? Ideally my app is supposed to support it, but due to limitations…
Ram
  • 301
  • 2
  • 12
1
vote
0 answers

Is it legal to POST/PUT/PATCH list and leaf-list in RESTCONF?

This is a follow-up question of this post. From @predi's answer I know that it is legal to GET a URL whose target resource is a list or leaf-list and DELETE can't use such URL. That is to say, given the following YANG definitions: list machine { …
password636
  • 981
  • 1
  • 7
  • 18
1
vote
1 answer

Is it legal to GET all list instances in RESTCONF?

Given the following YANG definitions, in module test: list machine { key "name"; leaf "name" { type string; } } and in data tree: "machine" : [ { "name": "a" }, { "name": "b" }, { "name": "c" } ] I want to know…
password636
  • 981
  • 1
  • 7
  • 18
1
vote
0 answers

How to fix Failed to resolve xpath: no module found for prefix rfc1213-mib in module MODULE-MIB

I'm trying to execute mvn clean install on a Yang project (that I created on Eclipse with the Yang extension) to run the models.yang that I converted from MIB and generate the specifications. The problem is when the project reaches the file …
1
vote
0 answers

Python binding to sysrepo gives invalid argument exception

I'm trying to bind some existing Python 2 code with the sysrepo package in OpenWrt. The Python binding uses SWIG to interface with the underlying C/C++. I try to create a YANG object by calling the Session.set_item() function, but I get an…
NetHead
  • 71
  • 1
  • 10