...
| YANG Construct | Supported/Planned version |
|---|---|
| anyxml | Not planned |
| argument | Not planned |
| augment | Goldeneye |
| base | Hummingbird |
| belongs-to | Goldeneye |
| bit | Goldeneye |
| case | Goldeneye |
| choice | Goldeneye |
| config | Falcon |
| contact | Goldeneye Enhancement in Hummingbird |
| container | Falcon |
| default | Goldeneye Enhancement in Humminbird |
| description | Goldeneye Enhancement in Hummingbird |
| deviate | Not planned |
| deviation | Not planned |
| enum | Goldeneye |
| error-app-tag | Not planned |
| error-message | Not planned |
| extension | Not planned |
| feature | Hummingbird |
| fraction-digits | Goldeneye |
| grouping | Goldeneye |
| identity | Hummingbird |
| if-feature | Hummingbird |
| import | Goldeneye Enhancement in Hummingbird |
| include | Goldeneye Enhancement in Hummingbird |
| input | Goldeneye |
| key | Goldeneye |
| leaf | Falcon |
| leaf-list | Falcon |
| length | Goldeneye |
| list | Falcon |
| mandatory | Falcon |
| max-elements | Goldeneye |
| min-elements | Goldeneye |
| module | Falcon |
| must | Hummingbird |
| namespace | Goldeneye |
| notification | Goldeneye |
| ordered-by | Not planned |
| organization | Goldeneye Enhancement in Hummingbird |
| output | Goldeneye |
| path | Hummingbird |
| pattern | Goldeneye |
| position | Goldeneye |
| prefix | Goldeneye |
| presence | Goldeneye |
| range | Goldeneye |
| reference | Goldeneye Enhancement in Hummingbird |
| refine | Not planned |
| require-instance | Not planned |
| revision | Goldeneye Enhancement in Hummingbird |
| revision-date | Goldeneye |
| rpc | Goldeneye |
| status | Goldeneye Enhancement in Hummingbird |
| submodule | Goldeneye |
| type | Goldeneye |
| typedef | Goldeneye |
| unique | Not Planned |
| units | Goldeneye |
| uses | Goldeneye |
| value | Goldeneye |
| when | Hummingbird |
| yang-version | Goldeneye |
| yin-element | Not Planned |
Built-in YANG data types support/plan
| Binary | Goldeneye Enhancement in Hummingbird |
| Bits | Goldeneye Enhancement in Hummingbird |
| boolean | Goldeneye |
| decimal64 | Goldeneye Enhancement in Hummingbird |
| empty | Goldeneye |
| enumeration | Goldeneye |
| identityref | Hummingbird |
| instance-identifier | Hummingbird |
| int8 | Goldeneye |
| int16 | Goldeneye |
| int32 | Goldeneye |
| int64 | Goldeneye |
| leafref | Hummingbird |
| string | Falcon |
| uint8 | Goldeneye |
| uint16 | Goldeneye |
| uint32 | Goldeneye |
| uint64 | Goldeneye |
| union | Goldeneye |
...
Submodule mapping to java is same as module and files with be generated in module’s namespace.
Example
| Code Block | ||
|---|---|---|
| ||
File : acme-system.yang
module acme-system {
namespace "http://yang-central.org/ns/example/acme";
prefix acme;
include "acme-types";
leaf id {
type string;
}
}
File : acme-types.yang
submodule acme-types {
yang-version 1;
belongs-to "acme-system" {
prefix "acme";
}
leaf access-timeout {
type uint32;
}
leaf retries {
type uint8;
}
} |
| Code Block | ||
|---|---|---|
| ||
File : AcmeSystemManager.java
package org.onosproject.yang.gen.v1.http.yang.central.org.ns.example.acme.rev20160526;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
import static org.slf4j.LoggerFactory.getLogger;
@Component (immediate = true)
@Service
public class AcmeSystemManager implements AcmeSystemService {
private final Logger log = getLogger(getClass());
@Activate
public void activate() {
//TODO: YANG utils generated code
log.info("Started");
}
@Deactivate
public void deactivate() {
//TODO: YANG utils generated code
log.info("Stopped");
}
@Override
public String getId() {
//TODO: YANG utils generated code
return null;
}
@Override
public void setId(String id) {
//TODO: YANG utils generated code
}
}
File : AcmeSystemService.java
package org.onosproject.yang.gen.v1.http.yang.central.org.ns.example.acme.rev20160526;
public interface AcmeSystemService {
String getId();
void setId(String id);
}
File : AcmeTypesManager.java
package org.onosproject.yang.gen.v1.http.yang.central.org.ns.example.acme.rev20160526;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Deactivate;
import org.apache.felix.scr.annotations.Service;
import org.slf4j.Logger;
import static org.slf4j.LoggerFactory.getLogger;
@Component (immediate = true)
@Service
public class AcmeTypesManager implements AcmeTypesService {
private final Logger log = getLogger(getClass());
@Activate
public void activate() {
//TODO: YANG utils generated code
log.info("Started");
}
@Deactivate
public void deactivate() {
//TODO: YANG utils generated code
log.info("Stopped");
}
@Override
public long getAccessTimeout() {
//TODO: YANG utils generated code
return 0;
}
@Override
public short getRetries() {
//TODO: YANG utils generated code
return 0;
}
@Override
public void setAccessTimeout(long accessTimeout) {
//TODO: YANG utils generated code
}
@Override
public void setRetries(short retries) {
//TODO: YANG utils generated code
}
}
File : AcmeTypesService.java
package org.onosproject.yang.gen.v1.http.yang.central.org.ns.example.acme.rev20160526;
public interface AcmeTypesService {
long getAccessTimeout();
short getRetries();
void setAccessTimeout(long accessTimeout);
void setRetries(short retries);
} |
...
Prefix
Overview
Prefix is used to define prefix associated with module. It is used as a hint to other module developers when they import our module.
...
A module can import definitions from other module or submodule by using import statement. It takes an argument, the name of the module or submodule followed by sub statements prefix and revision statement. Multiple import statements may be specified to import from different modules. Prefix statement inside import is mandatory and its scope is within the imported module or sub-module.
JAVA mapping
Example
Include
Overview
A module uses a include statement to include sub-module that belongs to module. The argument is the name of sub-module. Modules are only allowed to include sub-module that belongs to module, as defined by belongs-to statement. When a module includes a submodule, it incorporates the contents of the submodule into the node hierarchy of the module.
JAVA mapping
Example
Organization
When imported YANG file is used in any of the nodes in current YANG file, then Java code will genereted for imported YANG file. If it is imported YANG file is not used in any of the node in current YANG file then Java code for imported file will not be genereted.
Example
| Code Block | ||
|---|---|---|
| ||
File : flow-classifier.yang
module flow-classifier {
yang-version 1;
namespace "sfc.flowclassifier";
prefix "flow-classifier";
import "ietf-yang-types" {
prefix "yang";
}
organization "ON-LAB";
description "This submodule defines for flow classifier.";
revision "2016-05-24" {
description "Initial revision.";
}
leaf id {
type yang:uuid;
}
}
File : ietf-yang-types.yang
module ietf-yang-types {
namespace "urn:ietf:params:xml:ns:yang:ietf-yang-types";
prefix "yang";
organization
"IETF NETMOD (NETCONF Data Modeling Language) Working Group";
contact
"WG Web: <http://tools.ietf.org/wg/netmod/>
WG List: <mailto:netmod@ietf.org>
WG Chair: David Kessens
<mailto:david.kessens@nsn.com>
WG Chair: Juergen Schoenwaelder
<mailto:j.schoenwaelder@jacobs-university.de>
Editor: Juergen Schoenwaelder
<mailto:j.schoenwaelder@jacobs-university.de>";
description
"This module contains a collection of generally useful derived
YANG data types.
Copyright (c) 2013 IETF Trust and the persons identified as
authors of the code. All rights reserved.
Redistribution and use in source and binary forms, with or
without modification, is permitted pursuant to, and subject
to the license terms contained in, the Simplified BSD License
set forth in Section 4.c of the IETF Trust's Legal Provisions
Relating to IETF Documents
(http://trustee.ietf.org/license-info).
This version of this YANG module is part of RFC 6991; see
the RFC itself for full legal notices.";
revision 2013-07-15 {
description
"This revision adds the following new data types:
- yang-identifier
- hex-string
- uuid
- dotted-quad";
reference
"RFC 6991: Common YANG Data Types";
}
revision 2010-09-24 {
description
"Initial revision.";
reference
"RFC 6021: Common YANG Data Types";
}
typedef uuid {
type string {
pattern '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-'
+ '[0-9a-fA-F]{4}-[0-9a-fA-F]{12}';
}
description
"A Universally Unique IDentifier in the string representation
defined in RFC 4122. The canonical representation uses
lowercase characters.
The following is an example of a UUID in string representation:
f81d4fae-7dec-11d0-a765-00a0c91e6bf6
";
reference
"RFC 4122: A Universally Unique IDentifier (UUID) URN
Namespace";
}
} |
package org.onosproject.yang.gen.v1.sfc.flowclassifier.rev20160524;import org.onosproject.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev20100924.ietfyangtypes.Uuid;/** * Abstraction of an entity which represents the functionality of flowClassifierService. */public interface FlowClassifierService { /** * Returns the attribute id. * * @return value of id */ Uuid getId(); /** * Sets the value to attribute id. * * @param id value of id */ void setId(Uuid id);}
| Code Block | ||
|---|---|---|
| ||
|
Include
Overview
A module uses a include statement to include sub-module that belongs to module. The argument is the name of sub-module. Modules are only allowed to include sub-module that belongs to module, as defined by belongs-to statement. When a module includes a submodule, it incorporates the contents of the submodule into the node hierarchy of the module.
JAVA mapping
There is no java mapping for include statement.
Example
Please refer submodule example
Organization
Overview
The "organization" statement defines the party responsible for this module. The argument is a string that is used to specify a textual description of the organization(s) under whose auspices this module was developed.
...