1

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 service-abstract-type-definition {
    prefix sfc-satd;
    revision-date 2015-11-15;
}

And the usage of it looks like this:

leaf abstract-type {
  type sfc-satd:service-abstract-type-definition;
  description
    "Abstract Type definition for the Service Function";
}

This leaf is inside a grouping.

The imported module looks like this:

  module service-abstract-type-definition {

  namespace "urn:odl:params:xml:ns:yang:sfc-satd";

  prefix sfc-satd;

  import service-locator {
    prefix sfc-sl;
    revision-date 2014-07-01;
  }

  description
    "This module contains YANG definitions for managing Service Abstract Type Definition";

  revision 2015-11-15 {
    description
      "First version of Service Abstract Type Definition.";
  }

  // Service Function
  // Service Abstract Type definitions

  container service-abstract-type-definition {
    description
      "List of parameters to define an abstract type of Service Function";

    leaf name {
      type string;
      description "Service Function type names such as firewall, dpi, tcp-proxy, etc";
    }

    leaf symmetry {
      type boolean;
      description "SF is involved in a symmetric service path";
    }

    leaf bidirectionality {
      type boolean;
      description "SF handles uplink and downlink traffic";
    }

    leaf nsh-aware {
      type boolean;
      description "Service Function can handle Network Service Headers";
    }

    container dpl {
      description "Data Plane Locators from the Service Function";
      uses sfc-sl:data-plane-locator;
    }
  }
}

When compiling I get the ERROR saying

type satd:service-abstract-type-definition is not found

and I really don't get it. Any idea?

Thanks

GileBrt
  • 1,830
  • 3
  • 20
  • 28
Ricardo
  • 23
  • 3
  • Ok, I think I figured it out: In order to put reference a module as a type, you need to create a typedef inside that module. That was missing in my case. – Ricardo Nov 22 '15 at 13:35
  • Can you pls tell me what are the tools i need to install on my ubuntu system to compile and test yang modules ? – Abhishek Sagar Sep 01 '16 at 17:41

1 Answers1

1

You generally use import statements for two reasons in NETMOD YANG 1.0: reusing top-level definitions from another module and injecting definitions from your module into another module.

There are five top-level definitions that may be imported from another module in YANG: groupings, typedefs, extensions, features and identities. In your case you were trying to import a definition that is not one of those - a YANG container, which represents one of the data definition statements (they define nodes that may be instantiated AKA the data tree). The other data definition statements are: leaf, leaf-list, list, choice, case, augment, uses, and anyxml.

You cannot import data definition statements for use in your module, unless they are defined within a grouping and referenced with the uses statement. Furthermore, the leaf statement's type child statement represents the data type of a leaf instance, which restricts the set of valid values for the instance's value (the set of values for the text node of an XML element in XML encoding for example). Leaf statements also cannot be parents to other data definition statements - that is why they are called leafs (a data tree branch ends with them).

The term type in YANG is more like the data types in programming languages and should not be confused with certain terms from other schema languages (complex types), which define structure. Like you found out yourself, you may define custom data types in YANG by using the typedef statement.

predi
  • 5,528
  • 32
  • 60