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
2
votes
1 answer

YANG - Modeling non-mandatory containers

Currently I am working with YANG as part of a (legacy) Python project. I am somewhat stuck at the task of defining a schema, which shall then be used to verify data, organized as a Python dictionary. If it is possible, I would "like" to keep the…
Trollokia
  • 23
  • 1
  • 4
2
votes
1 answer

why is this leafref invalid according to pyang

For the following module yy { yang-version 1.1; namespace "urn:example:yy"; prefix yyX; container x4 { leaf x5 { type string; } } grouping gx { leaf l { type leafref { …
user19937
  • 587
  • 1
  • 7
  • 25
2
votes
1 answer

deleting a leaf with default value (yang)

say I have this container c { leaf l1; leaf l2 (default 'abcd'); } and I do this (restconf): DELETE /c/l2 what is the expected behavior in the server ? is it 'delete the leaf data' or 'do not delete but preserve the leaf with default…
user19937
  • 587
  • 1
  • 7
  • 25
2
votes
0 answers

hosting heterogeneous yang schemas at arbitrary locations

I have this need to be able to navigate heterogeneous schema trees from a known point in the overall schema tree. say, I define a container node /middleware:devices and when I learn the device schemas of various devices , want to hook/host…
user19937
  • 587
  • 1
  • 7
  • 25
2
votes
2 answers

unique constraint in yang models

if I have the following model devices { device { key id; interfaces { interface { key id; unique name; } } } } which data is valid or invalid according to yang's key and unique …
user19937
  • 587
  • 1
  • 7
  • 25
2
votes
1 answer

YANG - leafref seems not to be working

I would appreciate if a more yang experienced person could help me. I am triying to apply a constraint reference between 2 different lists, in the next way: list company{ key company-id; leaf company-id { type yang:uuid; …
J. Reyes
  • 41
  • 1
  • 6
2
votes
1 answer

Yang parsing in JAVA

I was looking to find a YANG parser and came across this question Parsing YANG Model in java I was wondering if there's any documentation for yang tools - API documentation or examples?
2
votes
2 answers

Use YANG Tools as a Java code generator for MD-SAL in Opendaylight

Recently I study the API definition for Opendaylight. As we know, YANG is a modeling language for NETCONF. However, Opendaylight uses it as a Java code generator for MD-SAL. So I am wondering : How does YANG Tool help generate Java code for…
1
vote
1 answer

How to use + operator performs addition into "default" Statement

In 'leaf remote-port' I need to get value from 'leaf base-port' and add number 100. The code below is incorrect because. the value "base-port + 100" does not match its base type - not an integer module internet-module { yang-version 1.1; …
1
vote
0 answers

RFC 6241 interpretation related to file:// URI

The Netconf RFC 6241 provides an example like shown below. file://checkpoint.conf
Ram
  • 301
  • 2
  • 12
1
vote
1 answer

Yang modeling language - select / deselect one or multiple options within bits type

Is there possibility in YANG language to select one option in bit type leaf, which will deselect all other bits ? What I would like to do is, by default Whole-Platform is selected, but when user selects some other option, the Whole-Platform will be…
marhyno
  • 677
  • 1
  • 8
  • 20
1
vote
1 answer

Only allow unique keys in seperate lists in YANG Model

My yang model has two same-level lists. I need the elements on both lists to be unique. Not unique within each list, but unique in the union of the lists. Is there a way to define this with a must statement or something? container parent { list…
1
vote
0 answers

Why there are differences between the yang model capabilities receive in the Netconf hello message and Opendaylight?

I've been trying to manage a device using the Restconf northbound interface of Opendaylight Oxigen and the Netconf southbound connected to a device that is running Netopeer with several yang data models. Basically, i'm following this…
1
vote
2 answers

Creating an atomic process for a netconf edit-config request

I am creating a custom system that, when a user submits a netconf edit-config, it will initiate a set of actions in my system that will atomically alter the configuration of our system and then submit a notification to the user of its success or…
E.S.
  • 2,733
  • 6
  • 36
  • 71
1
vote
1 answer

How to augment an enumeration in YANG

Is there a way to augment an enumeration in another module in YANG ? There is no way, in my case, to put all the values in the first module where the enumeration was defined. Knowing that the enumeration is inside a grouping as follows: grouping…
fatiha.kafou
  • 71
  • 1
  • 13
1 2
3
10 11