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
9
votes
3 answers

Parsing YANG Model in java

How do I parse YANG models in java ? I need to convert the yang model into a xml format. I have already tried pyang. But since it is in python, it does not suite my requirement.
Keshava
  • 702
  • 1
  • 7
  • 20
6
votes
2 answers

how to convert YANG data model to JSON data?

How do I convert "YANG" data model to "JSON"? As there is many many docs available in web, in that they changed in YANG synatx to JSON but how the value for the leaf or leaf list they are getting? from where and how it will get actual data in JSON…
5
votes
1 answer

YANG vs Protobuf

We are trying to model the configuration of a networking device. The model will be pretty much hierarchical. What are the pros and cons of writing the model in Yang vs Protobuf?
SimpleCoder
  • 1,101
  • 2
  • 10
  • 21
5
votes
0 answers

No response for RPC requests from opendaylight testtool simulator devices

I was able to simulate netconf devices with opendaylight simulators. During startup, I provided the yang schemas path too. But, when I login to the device through netconf and send any RPC request applicable for the yang schemas, there is no response…
5
votes
1 answer

Generate xml/json from Yang model

I've been trying to find something that can generate sample xml/json data from the yang model in java, For eg for xsd there are tools where you can generate the Sample xml. I tried Pyang: 1. Its in Python. 2. After conversion it gives me yin format…
Abhishek
  • 51
  • 1
  • 3
4
votes
1 answer

Yang action vs rpc and anydata vs anyxml

I could not understand the exact difference between Yang action vs Yang rpc and as well the difference between anydata vs anyxml. Why someone should model using anydata or anyxml? I tried finding more information about this, but I could not find.…
Ram
  • 301
  • 2
  • 12
4
votes
1 answer

understand YANG and its goals

I've read https://en.wikipedia.org/wiki/YANG but still having problems to understand the practical use of YANG, and the benefits it provides. As I understand, it now is used not only by NETCONF, as was originally designed. YANG is not a language in…
Mark
  • 6,052
  • 8
  • 61
  • 129
3
votes
1 answer

YANG and Choice - what does the XML look like?

I am trying to figure out the proper syntax for implementing the choice field from a yang model into its corresponding configuration xml. Unfortunately, the documentation in RFC 6020 and other Yang related web pages don't seem to show how to use a…
E.S.
  • 2,733
  • 6
  • 36
  • 71
3
votes
1 answer

Where to find examples for parsing YANG files using opendaylight

I added the following dependency in my pom.xml org.opendaylight.yangtools yang-parser-impl 2.1.8
3
votes
1 answer

Force maven to use old compiled java class from Yang in OpenDaylight

How i can force maven to recompile OpenDaylight-Openflowplugin project using previous generated Java classes by Yang, rather then generate new java classes with every compilation? I'm trying to edit the java classes generated by Yang but every time…
Kevin Costa
  • 87
  • 10
3
votes
4 answers

How to convert yang to xml

I would like to convert yang to xml format. Please let me know if any tools are available already. I tried with pyang yin format, which provides xml format but not in desired format. Generated xml: Ex:
3
votes
1 answer

How to refine the mandatory property of nodes from a grouping in YANG language?

I defined a grouping which has a leaf with mandatory property set to false. But in some cases, I would like to use this grouping and specify that the leaf should be mandatory. How do I achieve this in YANG?
HAO
  • 85
  • 8
3
votes
2 answers

Leaf Node 'when' or 'must' statement Usage

I am in the process of learning OpenDayLight and Yang and can't figure out how to put a constraint on a leaf node. I have a leaf node (vpn-id). When the l3vpn-type node equals 'bgp', I want data for this one to be allowed for vpn-id. If the leaf…
David Roberts
  • 43
  • 1
  • 7
3
votes
3 answers

What is the difference between Operational and Config in YANG?

What is the difference between Operational and Config in YANG model? Is it a correct way to supporting GET,PUT,POST and DELETE interfaces both in Operational and Config ?
vinllen
  • 1,369
  • 2
  • 18
  • 36
3
votes
1 answer

Persisting JSON data (validated with yang model)

I need to persist some configuration data in a database/store. JSON data can be validated with an existing Yang model. One of the requirements is to keep track of each leaf and leaf-list item and quickly rollback to a previous version. Do you think…
tartar
  • 688
  • 4
  • 16
1
2 3
10 11