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

"Item not writable" when trying to set a leaf from a bash script

This is a simplified version of the YANG model I'm working with: module echo { namespace "http://namespace.com/ns/echo/1.0"; prefix echo; import tailf-common { prefix tailf; } import ietf-inet-types { …
Dimitroff
  • 120
  • 1
  • 7
1
vote
1 answer

New-URN for enterprise yang module

I am developing enterprise yang module. I have a registered domain name.Do i need to registered top-level URN to the iana for yang data module's namespace like urn:rdns:: ?
Jay ganatra
  • 29
  • 1
  • 5
1
vote
1 answer

How many leafref is possible inside a leaf in Yang modelling?

According to RFC - RFC 6020 - LeafRef I can understand that the leaf can contain a leafref which inturn have the path pointing to the instance which is referenced but question is how many leafrefs are possible for one leaf? Only one or…
Melwyn Jensen
  • 161
  • 1
  • 10
1
vote
2 answers

Why does pyang validation allow to define a list without a valid key if the list is in a grouping?

The RFC6020 says: The "key" statement [...] takes as an argument a string that specifies a space-separated list of leaf identifiers of this list. [...] Each such leaf identifier MUST refer to a child leaf of the list. The leafs can be defined…
Piotr Babij
  • 837
  • 5
  • 12
1
vote
1 answer

accessing a specific leaf-list entry using yang restconf

It is clear to me how to refer to a list item (restconf draft) but it is not clear how to refer to a specific leaf-list entry. For example, given the following definition: module x { container y { leaf-list z; } } and if I have the…
user19937
  • 587
  • 1
  • 7
  • 25
1
vote
1 answer

Yang type not found

There is not too many questions about YANG models here in stackoverflow, but I hope you can help me out. I have created a YANG model and I want to import it into another module. The import statement is like this: import…
Ricardo
  • 23
  • 3
0
votes
1 answer

In YANG, Refining group not triggering error

I’ve added a “refine” and “must” when “uses” refers to a group. An example of how it’s being used is as follows : uses bird-config { refine feathers-count { …
IPbean
  • 1
0
votes
1 answer

How to convert Yang to XPath?

I need to know if there are any tools that can take .yang file as an input and return all the XPaths that will be present. (I tried pyang, but I couldn't find any option to convert to XPath) For example: if .yang file is…
0
votes
1 answer

Yang pattern not accepting regex containing ^ and $

Yang pattern does not accept valid Regex when it contains caret ^ or dollar $. The bellow pattern is valid on Regex validators, but when run inside a Yang pattern template in an is-types.yang file my application errors. However when i take off the ^…
0
votes
0 answers

bad arg and connection errors using Netconf-Yang on IOS-XE

I'm working Netconf-Yang for the first time on an IOS-XE device (Cat 9k, 16.8.1r) and I'm sending the following XML block to change an interface description. I'm using ansible netconf_config with these parameters: - name: netconf playbook hosts:…
MrPoulet
  • 91
  • 1
  • 1
  • 6
0
votes
1 answer

Default string values for union types in Yang Schema

Why can't the leaf wibble be assigned a default value "-"in the following schema (comments not in schema, added to post for clarity) module type { namespace "example.com"; prefix "foo"; typedef optional-value { type union…
Olumide
  • 5,397
  • 10
  • 55
  • 104
0
votes
2 answers

Why netconf is not using XML as data modeling language?

We know Netconf uses yang as data modeling language. Also it comprises of XML. Why XML itself is not used as modeling language?. What stops XML as a data modeling language?.
JavaUser
  • 25,542
  • 46
  • 113
  • 139
0
votes
1 answer

alternative way to use boolean container

container first{ container second{ type boolean; } } how can i do something like this.(My error:i can't boolean a container/error: unexpected keyword "type") I don't want to use leaf. Is there an alternative ?
0
votes
1 answer

allow a range of vlans NSO CISCO

I'm trying to build L2VPN service in which we need to allow a range of vlans in the customer side. The configuration is as follow: device { name ME0 data interface GigabitEthernet0/2 no switchport …
Brun
  • 9
  • 2
0
votes
2 answers

Yang model mandatory node only when condition is true

I have an XML file: true foo and a Yang model: container a { leaf b { type boolean; } leaf c { type string; } } Node 'c' is mandatory only when node 'b' equals 'true'. If I add a mandatory:…
anegru
  • 1,023
  • 2
  • 13
  • 29