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

ODL Fluorine RpcRegistration is Deprecated How are RPCs Registered now?

I'm attempting to create a feature on the new ODL version for Fluorine. With this new release the package: org.opendaylight.mdsal.binding.api.RpcProviderService.RpcRegistration is deprecated. When going to the documentation for that package it…
UtahUnix
  • 23
  • 2
1
vote
1 answer

relative path of an xpath expression inside a YANG list

I have the following YANG model: list machines { key "name"; leaf "name" { type string; } leaf link { type leafref { …
password636
  • 981
  • 1
  • 7
  • 18
1
vote
0 answers

JSON encoding of payload to RESTCONF server for multiple resources creation

Is it possible to send a single request of creating multiple resources at the top-level to a RESTCONF server? For example, consider the following YANG module: module example-foomod { namespace "http://example.com/foomod"; prefix "foomod"; …
password636
  • 981
  • 1
  • 7
  • 18
1
vote
1 answer

how to implement netconf + yang c++ server

currently I'm implementing netconf server in c++. I found this site: https://www.appinf.com/docs/poco-2008.2/NetconfUserGuide.html And thought maybe I'll use poco for the purpose, yet I was unable to find the source code in the github repository,…
1
vote
1 answer

Best way to configure a node with NETCONF

I am quite new to Yang and Netconf based configurations. Is there any opensource visualizer or script where it takes Yang files and help me out while creating XML payload to be used by NETCONF to configure the end node ? Currently it is painful…
codingfreak
  • 4,467
  • 11
  • 48
  • 60
1
vote
0 answers

opendaylight: yangtools how to support "feature" declared as an "if-feature" statement in YANG file?

I am using opendaylight and compiling a yang file which has statements like if-feature "ipv4" When I compile the yang file and run a valid looking json file through it, I get Schema node with name l3 wasn't found under…
1
vote
1 answer

YANG: How to specify complex typedefs

I am learning about YANG. I want to a typedef consisting of a Uri and a list of IpAddress. So I tried something like the following: typedef mapping { type union { type inet:uri; list addresses { …
1
vote
1 answer

how is this yang notification valid?

yang 1.1 spec has this example, The following example defines a notification in a data node: module example-interface-module { yang-version 1.1; namespace "urn:example:interface-module"; prefix "if"; container interfaces { list…
user19937
  • 587
  • 1
  • 7
  • 25
1
vote
1 answer

How to update configurations on a NETCONF enabled device?

My device yang is as shown below - module router { yang-version 1; namespace "urn:sdnhub:odl:tutorial:router"; prefix router; description "Router configuration"; revision "2015-07-28" { description "Initial version."; …
1
vote
1 answer

restrict yang leafref key identifier without extra leaf

I have a yang model with a leafref, which is pointing to a list inside of a other list. Basically something like this: list some-names { key "name"; leaf name { type string; } list some-other-names { key…
phschoen
  • 2,021
  • 16
  • 25
1
vote
1 answer

why pyang does not throw error in this scenario

the following when condition is referring to a non existing node. I wonder why pyang does not throw error ? It does, if I use a wrong prefix though. can you review the when conditions (embedded in the module) please. is it allowed (in when…
user19937
  • 587
  • 1
  • 7
  • 25
1
vote
1 answer

usage of current vs ../ in yang xpath expressions

is the usage of .. and current() in the following snippet correct ? Meaning, there are times when current() and ../ are equivalent ? container c { leaf f1 { type string; } leaf f2 { type string; when "../f1 = 'abc'"; …
user19937
  • 587
  • 1
  • 7
  • 25
1
vote
1 answer

how to import a module in Yang

I'm trying to build a CLI. I choose to use 'yang' to do so. I'm new to it and can't find out how to import existing moduls. As exemple I found a module for ospf on github…
B3th4
  • 113
  • 1
  • 2
  • 10
1
vote
1 answer

YANG, leaf must be unique in a list

I cant figure out how to create a "must" for a leaf that makes it unique in a list. This is list with a leaf in it, this leaf may not have the same value as any other leaf in this list. Example of code: list myList { key name; leaf name { …
Samuel
  • 137
  • 1
  • 16
1
vote
1 answer

Regarding the yang model for netconf xml file

Team I have the below xml file:
fsociety
  • 977
  • 3
  • 12
  • 23