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

Yang model validation error. Element not allowed anywhere, expected end-tag

I have the following YANG model. I want to validate the model against custom xml data. module turing-machine { namespace "http://example.net/turing-machine"; prefix "tm"; description "Data model for the Turing Machine."; revision…
anegru
  • 1,023
  • 2
  • 13
  • 29
0
votes
1 answer

Trying to install a YANG plugin in Eclpse -JavaEditorMessages.SemantincHighlighting has encountered a prpblem

I am trying to install a YANG plugin in Eclipse https://docs.opendaylight.org/en/stable-boron/getting-started-guide/project-specific-guides/yangide.html I am getting this error and I have no idea how to fix this Does anybody know what is wrong here…
MiniMe
  • 1,057
  • 4
  • 22
  • 47
0
votes
1 answer

how can i change a yang model into a xml or json file,when there is a union type element?

''' i want to change a yang model into xml, but there is a union type in yang model, and the odl check there is a error in the xml, i don`t known how to solve it ''' ''' the part of yang model leaf prefix { type leafref { …
0
votes
0 answers

How to use pyang module to compile, validate yang operations and sending back command to device

I am working on a project where i have to get yang files from device , edit them and then validate the yang structure and send back command as RPC to the device. I am able to login into device using ncclient on port 830
0
votes
1 answer

Yang regex expression

I want to have "YANG" regex expression inputting a string of the format "c[space or consecutive spaces][character string][space or consecutive spaces]c" Please let me know the yang regex for this. Please suggest only the "yang" expressions. example:…
Darshan b
  • 157
  • 7
0
votes
0 answers

Opendaylight serialize null values issue

I'm developing a project using Opendaylight (oxygen-sr4). I defined objects by Yang. .yang file like: grouping person{ leaf enName{ type string; } leaf zhName{ type string; } } When I transmit a person object to the front-end, I found field missing…
ghoultf
  • 1
  • 3
0
votes
1 answer

Error in compiling hello world example of Opendaylight Fluorine - yang tools issue

I had a working hello-world ODL project on Carbon release. I changed the POM dependencies to the latest version from the public repository and now I am getting a failure while compiling the 'impl' project: cannot access…
Dhopu K
  • 5
  • 4
0
votes
1 answer

Why leaf node with name type does not work in yang model?

I have this simple yang model leaf type { type string; description "some description"; } This is not working. Can someone please explain if string 'type' is invalid for leaf name in yang?
pzk
  • 19
  • 1
  • 7
0
votes
2 answers

ncclient.operations.rpc.RPCError: 'YANG framework' detected the 'fatal' condition 'Operation not supported on this datastore'

I am configuring the hostname of my cisco XR using ncclient. But I am receiving bellow an RPCError- Traceback (most recent call last): File "obj4.py", line 13, in edit_result = device.edit_config(target='running',config=host_name,…
Prarthana Shedge
  • 135
  • 1
  • 3
  • 11
0
votes
0 answers

how to parse yin files with opendaylight

I tried to follow this wiki https://docs.opendaylight.org/en/latest/developer-guide/yang-tools.html to make an example. But I don't know how to initiate YinStatementStreamSource and can not found YangInferencePipeline in neon release. below is my…
clark
  • 1
0
votes
1 answer

Yang - Implementing order dependent CLIs

I have two CLIs and I have this below requirement. If #1 is configured first, then #2 config is NOT allowed. If #2 is configured first, then #1 config is allowed. I have tried using must, but that makes them mutually exclusive. How do I implement…
disputedbug
  • 265
  • 1
  • 3
  • 6
0
votes
0 answers

How to exclude module name in leaf value of Identityref during ODL validation?

I have YANG model and JSON object which will be verified by ODL (see bellow). I need to exclude module name from JSON to verify. When I exclude module name from identityref ("type": "center-car-sale-type:sedan") and send only identityref name…
0
votes
1 answer

Accessing Individual leaf in leaf in list of yang

I want to access value of leaf of list in yang module? Ex module abc { list xyz{ key a; leaf a{ type int }, leaf b{ type string }, leaf c{ type string …
0
votes
1 answer

What are the SDK's in C/C++ (Open source) I can use to develop Netconf client and Server

I am looking to develop a client and agent using any open source netconf frameworks. Can anyone please suggest an open source library which is similar like How NetSNMP is there for SNMP.
0
votes
3 answers

Can Netconf protocol be used for monitoring the device data?

I have been using the SNMP to read the object id's for monitoring the network devices. I have come across a protocol called "NetConf" which is used for network configuration. Netconf also provides some API's to read the network device data. Can I be…