Gaurav Agrawal
Committed by Gerrit Code Review

[Hummingbird - ONOS4647] Check for the standard l3vpn yang

Change-Id: I3008b9da2ed61c8902789abd064b8f77dfa73245
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.yangutils.ietfyang;
import org.apache.maven.plugin.MojoExecutionException;
import org.junit.Test;
import org.onosproject.yangutils.linker.impl.YangLinkerManager;
import org.onosproject.yangutils.parser.exceptions.ParserException;
import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
import org.onosproject.yangutils.plugin.manager.YangUtilManager;
import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
import java.io.IOException;
import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
/**
* Test cases for testing IETF YANG files.
*/
public class IetfYangFileTest {
private final YangUtilsParserManager manager = new YangUtilsParserManager();
private final YangUtilManager utilManager = new YangUtilManager();
private final YangLinkerManager yangLinkerManager = new YangLinkerManager();
/**
* Checks hierarchical intra with inter file type linking.
* Reference: https://datatracker.ietf.org/doc/draft-zha-l3sm-l3vpn-onos-deployment
*/
@Test
public void l3vpnserviceyang()
throws IOException, ParserException, MojoExecutionException {
String searchDir = "src/test/resources/ietfyang/l3vpnservice";
utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
utilManager.parseYangFileInfoSet();
utilManager.resolveDependenciesUsingLinker();
String userDir = System.getProperty("user.dir");
YangPluginConfig yangPluginConfig = new YangPluginConfig();
yangPluginConfig.setCodeGenDir("target/ietfyang/l3vpnservice/");
utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
deleteDirectory(userDir + "/target/ietfyang/");
}
}
module ietf-sd-onos-common-types {
namespace "urn:ietf:params:xml:ns:yang:ietf-sd-onos-common-types";
prefix types ;
/*
import ietf-inet-types{
prefix inet;
}
import ietf-yang-types {
prefix yang-types;
}
*/
organization "";
contact "";
description
"Defines common basic types of L3VPN.";
revision "2015-12-16" {
reference "";
}
typedef admin-status {
type enumeration {
enum admin-up {
value 0 ;
description "admin up, the operate-status is depend on the real
running status ." ;
}
enum admin-down {
value 1 ;
description "admin down,the operate-status is forced to down no
matter what the real status is" ;
}
enum config-up {
value 2 ;
description "the operate-status is forced to up no matter what
the real status is." ;
}
}
default admin-up;
description
"The administration status of the service.";
}
typedef notification-status {
type enumeration {
enum up {
value 0 ;
description "up." ;
}
enum down {
value 1 ;
description "down." ;
}
}
default up;
description
"The notification status of the service.";
}
typedef notification-type {
type enumeration {
enum ne{
value 0 ;
description "ncd change." ;
}
enum link{
value 1 ;
description "link change." ;
}
enum ltp{
value 2 ;
description "ltp change." ;
}
}
default ltp;
description
"The notification-type of the service.";
}
typedef operate-status {
type enumeration {
enum operate-up {
value 0 ;
description "operate up." ;
}
enum operate-down {
value 1 ;
description "operate down." ;
}
}
default operate-up;
description
"The operation status of the service.";
}
grouping command-result {
description
"Reusable container of the result of the command.";
container command-result {
description
"The result of the command.";
leaf result {
type int8;
description
"1 : success, 2 : failed, 3 : partly failed" ;
}
container success-resources {
description
"The resources those are available." ;
list success-resource-list {
description
"The resource list shows those are available." ;
leaf resource-id {
type string;
description
"The available resource id." ;
}
}
}
container failed-resources {
description
"The resources those are failed." ;
list failed-resource-list {
description
"The resources list shows those are failed." ;
leaf resource-id {
type string;
description
"The failed resources ids." ;
}
leaf error-code {
type string;
description
"The error code." ;
}
}
}
}
}
}
module ietf-sd-onos-service-l3vpn {
namespace "urn:ietf:params:xml:ns:yang:ietf-sd-onos-service-l3vpn";
prefix l3vpn ;
/*
import ietf-inet-types{
prefix inet;
}
import ietf-yang-types {
prefix yang-types;
}
*/
import ietf-sd-onos-service-types {
prefix service-types;
}
import ietf-sd-onos-common-types {
prefix types;
}
organization "";
contact "";
description
"L3vpn configuration model in ONOS.";
revision "2015-12-16" {
reference "";
}
grouping l3vpn {
description
"The configuration module of l3 vpn.";
leaf name {
type string ;
mandatory true;
description "name of snc eline." ;
}
leaf id {
type uint32 ;
mandatory true;
description "ID of snc eline." ;
}
leaf user-label {
type string ;
description "user label of snc eline." ;
}
leaf parent-ncd-id {
type string ;
description "parent ncd id." ;
}
leaf admin-status {
type types:admin-status;
description "administration status." ;
}
leaf operate-status {
type types:operate-status;
description "operation status." ;
}
uses service-type-grouping;
container acess-information {
description "access information of the l3 vpn." ;
uses service-types:l3-ac; }
container protect-policy{
description "L3VPN Service protect policy." ;
uses service-types:protect-policy;
}
container tunnel-service {
description "tunnel service." ;
uses service-types:tunnel-service;
}
}
grouping service-type-grouping {
description "Basic service type" ;
leaf service-topology {
type enumeration {
enum full-mesh {
value 1 ;
description "full-mesh." ;
}
enum hub-spoke {
value 2 ;
description "hub-spoke." ;
}
}
default full-mesh;
description "service topology type." ;
}
}
container service {
description
"Root level of L3vpn service module.";
container l3vpn-cfg {
description
"L3vpn configuration model in ONOS.";
list vpn-cfg {
key name;
description
"vpn configuration parameter list.";
uses l3vpn;
}
}
container service-paths {
description
"The service path of the l3 vpn.";
}
}
rpc create-l3vpn-instance {
description "Create l3vpn instance." ;
input {
container l3vpn-instance {
description "Create l3vpn instance." ;
uses l3vpn;
}
}
}
rpc delete-l3vpn-instance {
description "Delete l3vpn instance." ;
input {
leaf l3vpn-id {
type string;
description "vpn id." ;
}
}
}
rpc close-l3vpn {
description "Close l3vpn." ;
input {
leaf l3vpn-id {
type string;
description "vpn id." ;
}
container ac-status {
description "Access status of the vpn." ;
list acs{
key "id";
description "Access information." ;
leaf id {
type string;
description "Access id." ;
}
leaf admin-status {
type types:admin-status;
description "Administration status." ;
}
}
}
}
}
rpc modify-l3vpn-instance-basic {
description "Modify l3vpn instance basic information." ;
input {
leaf l3vpn-id {
type string;
description "vpn id." ;
}
leaf user-label {
type string ;
description "user label." ;
}
}
}
rpc modify-l3vpn-instance-ac-qos {
description "Modify l3vpn instance ac qos information." ;
input {
leaf l3vpn-id {
type string;
description "L3vpn ID." ;
}
container ac-qos {
description "ac qos information." ;
list acs{
key "id";
description "acs list." ;
leaf id {
type string;
description "acs ID." ;
}
container qos-policy {
description "qos policy." ;
container qos-if-cars {
description "cars qos policy." ;
uses service-types:qos-if-car;
}
}
}
}
}
}
rpc modify-l3vpn-instance-connection {
description "Modify a l3vpn connection." ;
input {
leaf l3vpn-id {
type string;
description "L3vpn ID." ;
}
container ac-connection {
description "ac connection." ;
list acs{
key "id";
description "acs ID." ;
leaf id {
type string ;
description "acs ID." ;
}
container connection {
description "CE to PE connection." ;
uses service-types:connection;
}
}
}
}
}
rpc inquire-l3vpn-instance-work-path {
description "Inquire a L3VPN instance work path." ;
input {
leaf service-id {
type string;
description "service ID." ;
}
leaf ingress-ne-id {
type string ;
description "ingress network element ID." ;
}
leaf destination-ne-id {
type string ;
description "destination network element ID." ;
}
leaf ingress-ac-id {
type string ;
description "ingress ac ID." ;
}
leaf destination-ac-id {
type string ;
description "destination ac ID." ;
}
leaf path-layer {
type string ;
description "path layer." ;
}
leaf path-role {
type string ;
description "path role." ;
}
}
output {
container service-path {
description "service path." ;
leaf service-id {
type string;
description "service ID." ;
}
leaf ingress-ne-id {
type string ;
description "ingress network element ID." ;
}
leaf destination-ne-id {
type string ;
description "destination network element ID." ;
}
leaf ingress-ac-id {
type string ;
description "ingress access circuit ID." ;
}
leaf destination-ac-id {
type string ;
description "destination access circuit ID." ;
}
leaf path-layer {
type string ;
description "path layer." ;
}
leaf path-role {
type string ;
description "path role." ;
}
list path-list {
key "ne-id";
description "path list." ;
leaf ne-id {
type string;
description "network element ID." ;
}
leaf ingress-ltp-id {
type string;
description "LTP ID." ;
}
leaf backward-peer-id {
type string;
description "backward peer ID." ;
}
leaf egress-ltp-id {
type string;
description "egress ltp ID." ;
}
leaf forward-peer-id {
type string;
description "forward peer ID." ;
}
}
}
}
}
}