Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Status
subtletrue
colourYellow
titleWork in Progress

...

Additional Resources (still to be examined)

*Although this documentation link is to the latest ODL doc revision, it is very outdated and the code examples need significant updates, see findings in Mini-PoC below (bug reported: https://jira.opendaylight.org/browse/DOCS-126)

...

The package org.opendaylight.yangtools.yang.model.util.type contains classes for all the possible data types including:

  • BaseBinaryType
  • BaseBitsType
  • BaseBooleanType
  • BaseDecimalType
  • BaseEnumerationType
  • BaseInt8Type
  • BaseInt16Type
  • BaseInt32Type
  • BaseInt64Type
  • BaseStringType
  • BaseUint8Type
  • BaseUint16Type
  • BaseUint32Type
  • BaseUint64Type

There are also some special data types such as:

  • BaseEmptyType
  • BaseIdentityrefType
  • BaseInstanceIdentifierType
  • BaseLeafrefType
  • BaseUnionType

And also 'restricted' versions of the base types such as:

  • RestrictedStringType
  • RestrictedUint64Type

...

JSON
Validation

...

Datatypes and basic constraints

...

leaf response-code {
  type string;
}

...

Image Removed

...

.yang.model.util.type contains classes for all the possible data types including:

  • BaseBinaryType
  • BaseBitsType
  • BaseBooleanType
  • BaseDecimalType
  • BaseEnumerationType
  • BaseInt8Type
  • BaseInt16Type
  • BaseInt32Type
  • BaseInt64Type
  • BaseStringType
  • BaseUint8Type
  • BaseUint16Type
  • BaseUint32Type
  • BaseUint64Type

There are also some special data types such as:

  • BaseEmptyType
  • BaseIdentityrefType
  • BaseInstanceIdentifierType
  • BaseLeafrefType
  • BaseUnionType

And also 'restricted' versions of the base types such as:

  • RestrictedStringType
  • RestrictedUint64Type


NoNo pnf-name string length 256Optional<LengthConstraint> AbstractLengthRestrictedType.getLengthConstraint() list server {
  key "name";
  unique "ip port";
  leaf name ChoiceStatementImage RemovedErrorMessageStatement
DescriptionYangJava Object ViewNotesXML Validation

JSON
Validation

Datatypes and basic constraints

Basic String

leaf response-code {
  type string;
}

Image Added

TypeStatement TypeAwareDeclaredStatement.getType()YesYes
Mandatory Basic String

leaf response-code {925px
  type string;
    mandatory "true";
}

Image Added

Optional<MandatoryStatement> MandatoryStatementAwareDeclaredStatement.getMandatory()

NoNo
Limited String leaf pnf-name {
  type string {
    length "0..256";
}

Image Added

Optional<LengthConstraint> AbstractLengthRestrictedType.getLengthConstraint()

YesYes
typedef (String) with pattern

typedef dotted-quad {
  type string {
pattern
  '(([0-9] ...';
  }
}

leaf address {
   type dotted-quad;
   mandatory "true";
}

Image RemovedImage Added

Optional<MandatoryStatement> MandatoryStatementAwareDeclaredStatementList<PatternConstraint> RestrictedStringType.getMandatorygetPatternConstraints()YesYes
Limited Stringuint64 leaf cid {
  type
uint64 {
   
 range "0..503";
  }

Image Removed

}

Image Added

org.opendaylight.yangtools.yang.model.util.type.RestrictedUint64TypeYesYestypedef (String) with pattern
typedef dotted-quad boolean with default value

leaf blacklisted {
  type string {
pattern
  '(([0-9] ...';
  }
}

leaf address {
   type dotted-quad;
   mandatory "true";
}

Image Removed

List<PatternConstraint> RestrictedStringType.getPatternConstraints()YesYes
Limited uint64 leaf cid {
  type uint64 {
     range "0..503";
  }
}

Image Removed

org.opendaylight.yangtools.yang.model.util.type.RestrictedUint64TypeYesYes
boolean with default value

leaf blacklisted {
  type boolean;
  default 1;
}

Image Removed

boolean;
  default 1;
}

Image Added

org.opendaylight.yangtools.yang.model.util.type.DerivedBooleanTypeN/AN/A

Unique

Unique list server {
  key "name";
  unique "ip port";
  leaf name {
    type string;
  }
  leaf ip {
    type dotted-quad;
  }
  leaf port {
    type uint32;
  }}

Image Added

org.opendaylight.yangtools.yang.model.utilapi.typestmt.DerivedBooleanTypeUniqueStatementN/AN/A

Unique

UniqueNoNo

Choice

Choicechoice transfer-method {
  leaf transfer-interval {
    type string;
uint64 { range "15..2880"; }
  leaf ip {
    type dotted-quad;
  units minutes; }
  leaf port transfer-on-commit {
    type uint32empty;
  }}

Image RemovedImage Added

org.opendaylight.yangtools.yang.model.api.stmt.UniqueStatementNoNo

Choice

Choicechoice transfer-method {
  leaf transfer-interval {
    type uint64 { range "15..2880"; }
    units minutes; }
  leaf transfer-on-commit {
  type empty;
  }}
Image RemovedChoiceStatementN/AN/A

Must

Must leaf ifType {
type enumeration {
enum ethernet;
enum atm;}}
leaf ifMTU {
type uint32;}
must "ifType != 'ethernet' or "
+ "(ifType = 'ethernet' and ifMTU = 1500)"
{
error-message 466px"An ethernet MTU must be 1500";}

Image Added

org.opendaylight.yangtools.yang.model.api.stmt.ErrorMessageStatementN/AN/A

Must

Must leaf ifType {
type enumeration {
enum ethernet;
enum atm;}}
leaf ifMTU {
type uint32;}
must "ifType != 'ethernet' or "
+ "(ifType = 'ethernet' and ifMTU = 1500)"
{
error-message 466px"An ethernet MTU must be 1500";}
NoNo

When

When
leaf a {
    type boolean;
}
leaf b {
    type string;
    when "../a = 'true'";
}

Image Added

org.opendaylight.yangtools.yang.model.api.stmt.NoNo

When

When
leaf a {
    type boolean;
}
leaf b {
    type string;
    when "../a = 'true'";
}
Image RemovedWhenStatementNoNo

Extension

Extension declaration

extension store-state-ext {
argument duration;
description "An extension to enable
state-storage for any attribute.
Use duration to specify how long: nnn<h|d|y>";

}

Image Added


N/A
Extension usage leaf attribute-with-temporal-storage {
  type string;
  cm-notify-api:store-state-ext "3d";
// store state 3 days

}

Image Added

org.opendaylight.yangtools.yang.model.api.stmt

.WhenStatement
NoNo

Extension

Extension declaration

extension store-state-ext {
argument duration;
description "An extension to enable
state-storage for any attribute.
Use duration to specify how long: nnn<h|d|y>";

}

Image Removed

N/AExtension usage leaf attribute-with-temporal-storage {
  type string;
  cm-notify-api:store-state-ext "3d";
// store state 3 days

}

Image Removed

org.opendaylight.yangtools.yang.model.api.stmt.UnrecognizedStatement

.UnrecognizedStatement

which extends UnknownStatement:

public interface UnknownStatement<A> extends DeclaredStatement<A> {
default @Nullable A getArgument() {
return argument();
}
}
N/A

Augmentation


augment "server" {
  when "port = '8787'";
    leaf enable-debug {
      type boolean;
    }
}
}

Image Removed

Image Added

The additional leaf just appears in the SchemaTree (without any reference that it is an augmentation)N/A

RPC

rpc
rpc nbrlist-change-notification {
description
"RAN Neighbor List change notification to configure RuntimeDB";
input {
:
}
output {
:
}
}

Image RemovedImage Added


N/A
rpc input
 input {
leaf fap-service-number-of-entries-changed {
type uint64;
description
"Number of cells for which neighbor list has changed";
}
list fap-service {
key "alias";
leaf alias {
type string {
length "1..64";
}
}
leaf cid {
type string {
length "0..52";
}
}
uses x-0005b9-lte-g;
leaf lte-cell-number-of-entries {
type uint64;
description
"Number of cells in a neighbor list that was changed";
}
list lte-ran-neighbor-list-in-use-lte-cell-changed {
key "plmnid cid";
uses lte-ran-neighbor-list-in-use-lte-cell-g;
description
"Changed/Modified List of cells
in a neighbor list for this fap service";
     }
}
}

Image RemovedImage Added


N/A
rpc output
output {
uses cm-notification-response;
}

Image RemovedImage Added


N/A

Yang Data Parsing and Validation

...

  • As expected the parsing of string, originating form XML or JSON is done by the same code and the results are identical to those for XML Data Parsing

Conclusion

Pros

  1. EXTENSIVE - The YangTools model parser is comprehensive and covers all possible Yang Language elements we might require
  2. AVAILABLE - Extensively used throughout ONAP and ODL projects (able to convert to Java objects, code & API). These parsers are already used in many ONAP platform projects.
  3. MATURE CODE - Mature code, dates back to 2013 with contributions from many companies including Cisco and RedhatParsing and Redhat and Pantheon Tech. (No need for licenses, these are also open source Yang parser). ODL is open source.
  4. VALIDATION - Testing with parsing of JSON and XML data with validated for a a (parsed) model included. Files to objects and vice versa is possible. Model violation & compilation validation is available.
  5. OBJECTIVES - Meets our two high-level requirements & objectives. Parse models from SDC into Java objects relate to persistence of data. Parsing of documents compliant to those schemas.

Cons

  1. LEARNING CURVE - Due to its completeness it also is a complicated piece of software which will take some time to get familiar with.
  2. DOCUMENTATION - Documentation out of date, this page hopes to address that somewhat

...