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

YANG model "when" statement usage

I understand that the "when" statement in a Yang model takes an XPATH expression as its argument. What is the correct YANG XPATH syntax to combine multiple expressions in order to model a type/value data container as follows ? container c1 { …
Mukesh MV
  • 61
  • 1
  • 5
0
votes
1 answer

How to use count() in must() clause in a YANG model?

I tried to research this over the last few days but my research came up short, there seems not to be a lot of material out there on the use of the must() clause in a YANG model. Background I am trying to extend the NETCONF model of an I2RS YANG…
0
votes
1 answer

usage of jyang parser to convert yang files into yin

I am currently doing a project on yang parser. I have come across an open source tool called "jYang" which is a parser for Yang files in Java. I have downloaded the source files and understood its procedure but i'm not knowing how to input the Yang…
0
votes
2 answers

leafref inside grouping to grouping

I want to create a leafref from one grouping to another, is it possible? I have the following files: a.yang: module a { namespace "http://something.com/a"; prefix a; import b { prefix b; } description "a…
hudac
  • 2,584
  • 6
  • 34
  • 57
-1
votes
1 answer

I need to get some information form the cisco device. It is cisco-ios-xe device

I have a CISCO device. The device is configured with the WebUI. Which have many details? But I am not able to get these following details from there. CPU Load Temperature Device details. Memory use Alarms I have tried many times to get those above…
Anshu
  • 1,277
  • 2
  • 13
  • 28
-1
votes
1 answer

How to make some parameter in yang model as read only

I have one yang model, which is use to change run time parameter of my application.how i can make some parameter read only because some parameter when get change it impact on my code.I want user cannot change that parameter on run time. …
-1
votes
1 answer

Opendaylight - How to control what data goes into which shard

I am developing an application which takes in some inputs, runs some algorithm and based on the result, a connecttion is established to a Netconf server using Opendaylight. I am following the ODL Netconf User Guide and everything is working…
Pravin Kumar
  • 137
  • 2
  • 13
-1
votes
1 answer

What is the xpath to access leaves within a list Yang?

I have this yang model: container x { list y{ key "a" leaf a{ } leaf b{ } } } how would I access a leaf for example the b leaf wouldn't it be x/y{value a}/b? or x/y/b I tried so many combos of xpaths none are working those…
citruscake
  • 21
  • 1
  • 7
-2
votes
2 answers

How do we convert NETCONF YANG file to equivalent java class file without using plugins?

I need to convert given YANG file to JAVA class file without using plugins. How to map the YANG structures to java elements?
-3
votes
1 answer

Failed to install pyang

I'm trying to install pyang by pip install pyang command and I got this error : Failed to establish a new connection: [Errno 101] Network is unreachable')': /simple/pyang/ Thank you.
-3
votes
1 answer

Programatically construct netconf edit-config request

I am trying to programatically construct netconf edit-config request for a yang schema config object. Currently I am constructing this xml string manually. Is there a way I can do this programatically? I am using golang for example, I am trying to…
madyjosh
  • 1
  • 1
1 2 3
10
11