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

Can a submodule belong to multiple modules in YANG?

I have a submodule which I would like to be used in two modules. Is it possible to use the one submodule in multiple modules and how to do that?
Rewa Kale
  • 41
  • 1
  • 3
0
votes
0 answers

Comparison based default value for a leaf in a same list in yang model

I would like to assign different default value to a leaf according to type of key the list entries take. as an example, although not correct: typedef type-id { type enumeration { enum a{ value 1; } enum b{ value…
yogi
  • 107
  • 1
  • 9
0
votes
0 answers

how to get a consolidated tree out of these 2 yang files

I have the following simple yang files. I was trying to get a tree output that consolidates the module and submodule, but, cant get. module modA { yang-version 1.1; namespace "http://www.example.com/"; prefix ma; …
user19937
  • 587
  • 1
  • 7
  • 25
0
votes
1 answer

Constrain to check increasing index in yang model

i am working on a yang model. In this i need to have a list in which one leaf key (index) should be always in increasing order. I need to add constrain for this in yang model. any solution for this?
0
votes
1 answer

Must statement in yang

my CLI looks like - router config site site123 eid-prefix instance-id 100 1.1.1.0/24 accept-more-specifics eid-prefix instance-id 102 2.2.2.0/24 accept-more-specifics eid-prefix instance-id 103 3.3.3.0/24 accept-more-specifics site…
user1060517
  • 355
  • 1
  • 5
  • 17
0
votes
1 answer

is it possible to make YANG list name configurable?

I have this configuration file where dps can have a list of switches (e.g. sw1, sw2, etc) each switch has db_id and list of interfaces as shown below. I want to write a YANG model for this fils. dps: : dp_id:
alshaboti
  • 643
  • 8
  • 18
0
votes
1 answer

Regex to filter '*' and '?' special character in yang model

I am trying to create a regex in yang model to not allow * and ? characters. String * and ? should not be allowed as input. .e.g. - abc* - should be okay - * - is not okay and should be rejected Similarly string ("?") should be…
sks
  • 146
  • 1
  • 13
0
votes
1 answer

What is the type of below mention data?

I am receiving below mention data type as a result of service call. I need to parse this data, It doesn't seems like JSON or YANG, wondering what it is? update { timestamp: 1513187126024174850 prefix { elem { name: "interfaces" } …
Ammad
  • 4,031
  • 12
  • 39
  • 62
0
votes
1 answer

How to put specific order for each container inside a grouping in YANG model?

Is there any way to specify the order of containers inside a grouping, instead of letting the system do it randomly? Example: grouping common-config-def { container myContent1 { uses myContent1-def; } container myContent2 { …
Trung
  • 1
  • 1
0
votes
1 answer

Yang Modeling Set a Field Based on Another Field

I am writing a Yang model. Is there away to set a leaf (string or enumeration) with a value based on another field. So for example, I want to say if x then field a value is b, if z then field a value is c. Edit: I am new to yang and still trying to…
A.J
  • 43
  • 1
  • 6
0
votes
1 answer

How to solve SchemaValidationFailedException: Child is not present in schema

I'm trying to use Databroker of MD-SAL to save a list of data, after modifying the yang file and InstanceIdentifier many times but always facing similar validation issue, for example java.util.concurrent.ExecutionException:…
HAO
  • 85
  • 8
0
votes
2 answers

How to configure swagger UI of Restconf in Opendaylight

Recently, I updated ODL project from Boron to Carbon. Before when I open one API in the UI, those details defined in Yang model of each rpc wasn't showed in "Response Class". After the upgrade, all the details are showed up, which takes time to…
HAO
  • 85
  • 8
0
votes
0 answers

What's the different between Config Subsystem(CSS) and Blueprint in Opendaylight?

The current opendaylight project I am working on doesn't use blueprint to do the dependency injection. Instead of that, it seems like a yang model is used to do that, which is defined under that bundle project. After searching around, I realized…
HAO
  • 85
  • 8
0
votes
2 answers

Maven Imported module [ietf-inet-types] was not found

I have OpenDayLight Boron-SR3 installed and a test YANG file in /opt/odl_l3vpn/dave/api/src/main/yang. module DaveTest { namespace "urn:opendaylight:params:xml:ns:DaveTest"; prefix dm; import "ietf-inet-types" { prefix…
0
votes
0 answers

Validating YANG against CLI arguments

We have a CLI-based app. that reads input from a JSON/YAML-like format called YANG and present the objects as CLI arguments, and I am supposed to test that, but i am clueless on where to start. example: root@beer#./app -a web_url -b web_username -c…