Gaurav Agrawal
Committed by Gerrit Code Review

[Hummingbird - ONOS4647] Check for the standard l3vpn yang

Change-Id: I3008b9da2ed61c8902789abd064b8f77dfa73245
(cherry picked from commit f6e6037b)
1 +/*
2 + * Copyright 2016-present Open Networking Laboratory
3 + *
4 + * Licensed under the Apache License, Version 2.0 (the "License");
5 + * you may not use this file except in compliance with the License.
6 + * You may obtain a copy of the License at
7 + *
8 + * http://www.apache.org/licenses/LICENSE-2.0
9 + *
10 + * Unless required by applicable law or agreed to in writing, software
11 + * distributed under the License is distributed on an "AS IS" BASIS,
12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 + * See the License for the specific language governing permissions and
14 + * limitations under the License.
15 + */
16 +
17 +package org.onosproject.yangutils.ietfyang;
18 +
19 +import org.apache.maven.plugin.MojoExecutionException;
20 +import org.junit.Test;
21 +import org.onosproject.yangutils.linker.impl.YangLinkerManager;
22 +import org.onosproject.yangutils.parser.exceptions.ParserException;
23 +import org.onosproject.yangutils.parser.impl.YangUtilsParserManager;
24 +import org.onosproject.yangutils.plugin.manager.YangUtilManager;
25 +import org.onosproject.yangutils.translator.tojava.utils.YangPluginConfig;
26 +import org.onosproject.yangutils.utils.io.impl.YangFileScanner;
27 +
28 +import java.io.IOException;
29 +
30 +import static org.onosproject.yangutils.utils.io.impl.YangIoUtils.deleteDirectory;
31 +
32 +/**
33 + * Test cases for testing IETF YANG files.
34 + */
35 +public class IetfYangFileTest {
36 +
37 + private final YangUtilsParserManager manager = new YangUtilsParserManager();
38 + private final YangUtilManager utilManager = new YangUtilManager();
39 + private final YangLinkerManager yangLinkerManager = new YangLinkerManager();
40 +
41 + /**
42 + * Checks hierarchical intra with inter file type linking.
43 + * Reference: https://datatracker.ietf.org/doc/draft-zha-l3sm-l3vpn-onos-deployment
44 + */
45 + @Test
46 + public void l3vpnserviceyang()
47 + throws IOException, ParserException, MojoExecutionException {
48 +
49 + String searchDir = "src/test/resources/ietfyang/l3vpnservice";
50 + utilManager.createYangFileInfoSet(YangFileScanner.getYangFiles(searchDir));
51 + utilManager.parseYangFileInfoSet();
52 + utilManager.resolveDependenciesUsingLinker();
53 +
54 + String userDir = System.getProperty("user.dir");
55 + YangPluginConfig yangPluginConfig = new YangPluginConfig();
56 + yangPluginConfig.setCodeGenDir("target/ietfyang/l3vpnservice/");
57 +
58 + utilManager.translateToJava(utilManager.getYangFileInfoSet(), yangPluginConfig);
59 +
60 + deleteDirectory(userDir + "/target/ietfyang/");
61 + }
62 +
63 +}
1 + module ietf-sd-onos-common-types {
2 + namespace "urn:ietf:params:xml:ns:yang:ietf-sd-onos-common-types";
3 + prefix types ;
4 + /*
5 + import ietf-inet-types{
6 + prefix inet;
7 + }
8 + import ietf-yang-types {
9 + prefix yang-types;
10 + }
11 + */
12 + organization "";
13 + contact "";
14 +
15 + description
16 + "Defines common basic types of L3VPN.";
17 +
18 + revision "2015-12-16" {
19 + reference "";
20 + }
21 +
22 + typedef admin-status {
23 + type enumeration {
24 + enum admin-up {
25 + value 0 ;
26 + description "admin up, the operate-status is depend on the real
27 + running status ." ;
28 + }
29 + enum admin-down {
30 + value 1 ;
31 + description "admin down,the operate-status is forced to down no
32 + matter what the real status is" ;
33 + }
34 + enum config-up {
35 + value 2 ;
36 + description "the operate-status is forced to up no matter what
37 + the real status is." ;
38 + }
39 + }
40 + default admin-up;
41 + description
42 + "The administration status of the service.";
43 + }
44 +
45 + typedef notification-status {
46 + type enumeration {
47 + enum up {
48 + value 0 ;
49 + description "up." ;
50 + }
51 + enum down {
52 + value 1 ;
53 + description "down." ;
54 + }
55 + }
56 + default up;
57 + description
58 + "The notification status of the service.";
59 + }
60 +
61 + typedef notification-type {
62 + type enumeration {
63 + enum ne{
64 + value 0 ;
65 + description "ncd change." ;
66 + }
67 + enum link{
68 + value 1 ;
69 + description "link change." ;
70 + }
71 + enum ltp{
72 + value 2 ;
73 + description "ltp change." ;
74 + }
75 + }
76 + default ltp;
77 + description
78 + "The notification-type of the service.";
79 + }
80 +
81 + typedef operate-status {
82 + type enumeration {
83 + enum operate-up {
84 + value 0 ;
85 + description "operate up." ;
86 + }
87 + enum operate-down {
88 + value 1 ;
89 + description "operate down." ;
90 + }
91 + }
92 + default operate-up;
93 + description
94 + "The operation status of the service.";
95 + }
96 +
97 + grouping command-result {
98 + description
99 + "Reusable container of the result of the command.";
100 + container command-result {
101 + description
102 + "The result of the command.";
103 + leaf result {
104 + type int8;
105 + description
106 + "1 : success, 2 : failed, 3 : partly failed" ;
107 + }
108 + container success-resources {
109 + description
110 + "The resources those are available." ;
111 + list success-resource-list {
112 + description
113 + "The resource list shows those are available." ;
114 + leaf resource-id {
115 + type string;
116 + description
117 + "The available resource id." ;
118 + }
119 + }
120 + }
121 + container failed-resources {
122 + description
123 + "The resources those are failed." ;
124 + list failed-resource-list {
125 + description
126 + "The resources list shows those are failed." ;
127 + leaf resource-id {
128 + type string;
129 + description
130 + "The failed resources ids." ;
131 + }
132 + leaf error-code {
133 + type string;
134 + description
135 + "The error code." ;
136 + }
137 + }
138 + }
139 + }
140 + }
141 + }
1 + module ietf-sd-onos-service-l3vpn {
2 + namespace "urn:ietf:params:xml:ns:yang:ietf-sd-onos-service-l3vpn";
3 + prefix l3vpn ;
4 + /*
5 + import ietf-inet-types{
6 + prefix inet;
7 + }
8 + import ietf-yang-types {
9 + prefix yang-types;
10 + }
11 + */
12 + import ietf-sd-onos-service-types {
13 + prefix service-types;
14 + }
15 + import ietf-sd-onos-common-types {
16 + prefix types;
17 + }
18 + organization "";
19 + contact "";
20 +
21 + description
22 + "L3vpn configuration model in ONOS.";
23 +
24 + revision "2015-12-16" {
25 + reference "";
26 + }
27 +
28 + grouping l3vpn {
29 + description
30 + "The configuration module of l3 vpn.";
31 + leaf name {
32 + type string ;
33 + mandatory true;
34 + description "name of snc eline." ;
35 + }
36 + leaf id {
37 + type uint32 ;
38 + mandatory true;
39 + description "ID of snc eline." ;
40 + }
41 + leaf user-label {
42 + type string ;
43 + description "user label of snc eline." ;
44 + }
45 + leaf parent-ncd-id {
46 + type string ;
47 + description "parent ncd id." ;
48 + }
49 +
50 + leaf admin-status {
51 + type types:admin-status;
52 + description "administration status." ;
53 + }
54 + leaf operate-status {
55 + type types:operate-status;
56 + description "operation status." ;
57 + }
58 +
59 + uses service-type-grouping;
60 + container acess-information {
61 + description "access information of the l3 vpn." ;
62 +
63 + uses service-types:l3-ac; }
64 +
65 + container protect-policy{
66 + description "L3VPN Service protect policy." ;
67 + uses service-types:protect-policy;
68 + }
69 + container tunnel-service {
70 + description "tunnel service." ;
71 + uses service-types:tunnel-service;
72 + }
73 +
74 + }
75 +
76 + grouping service-type-grouping {
77 + description "Basic service type" ;
78 + leaf service-topology {
79 + type enumeration {
80 + enum full-mesh {
81 + value 1 ;
82 + description "full-mesh." ;
83 + }
84 + enum hub-spoke {
85 + value 2 ;
86 + description "hub-spoke." ;
87 + }
88 + }
89 + default full-mesh;
90 + description "service topology type." ;
91 + }
92 + }
93 +
94 + container service {
95 + description
96 + "Root level of L3vpn service module.";
97 + container l3vpn-cfg {
98 + description
99 + "L3vpn configuration model in ONOS.";
100 + list vpn-cfg {
101 + key name;
102 + description
103 + "vpn configuration parameter list.";
104 + uses l3vpn;
105 + }
106 + }
107 + container service-paths {
108 + description
109 + "The service path of the l3 vpn.";
110 + }
111 + }
112 +
113 +
114 +
115 + rpc create-l3vpn-instance {
116 + description "Create l3vpn instance." ;
117 + input {
118 + container l3vpn-instance {
119 + description "Create l3vpn instance." ;
120 + uses l3vpn;
121 + }
122 + }
123 + }
124 +
125 + rpc delete-l3vpn-instance {
126 + description "Delete l3vpn instance." ;
127 + input {
128 + leaf l3vpn-id {
129 + type string;
130 + description "vpn id." ;
131 + }
132 + }
133 + }
134 +
135 + rpc close-l3vpn {
136 + description "Close l3vpn." ;
137 + input {
138 + leaf l3vpn-id {
139 + type string;
140 + description "vpn id." ;
141 + }
142 + container ac-status {
143 + description "Access status of the vpn." ;
144 + list acs{
145 + key "id";
146 + description "Access information." ;
147 + leaf id {
148 + type string;
149 + description "Access id." ;
150 + }
151 + leaf admin-status {
152 + type types:admin-status;
153 + description "Administration status." ;
154 + }
155 + }
156 + }
157 + }
158 + }
159 +
160 + rpc modify-l3vpn-instance-basic {
161 + description "Modify l3vpn instance basic information." ;
162 + input {
163 + leaf l3vpn-id {
164 + type string;
165 + description "vpn id." ;
166 + }
167 + leaf user-label {
168 + type string ;
169 + description "user label." ;
170 + }
171 + }
172 + }
173 +
174 + rpc modify-l3vpn-instance-ac-qos {
175 + description "Modify l3vpn instance ac qos information." ;
176 + input {
177 + leaf l3vpn-id {
178 + type string;
179 + description "L3vpn ID." ;
180 + }
181 + container ac-qos {
182 + description "ac qos information." ;
183 + list acs{
184 + key "id";
185 + description "acs list." ;
186 + leaf id {
187 + type string;
188 + description "acs ID." ;
189 + }
190 + container qos-policy {
191 + description "qos policy." ;
192 + container qos-if-cars {
193 + description "cars qos policy." ;
194 + uses service-types:qos-if-car;
195 +
196 + }
197 + }
198 + }
199 + }
200 + }
201 + }
202 + rpc modify-l3vpn-instance-connection {
203 + description "Modify a l3vpn connection." ;
204 + input {
205 + leaf l3vpn-id {
206 + type string;
207 + description "L3vpn ID." ;
208 + }
209 + container ac-connection {
210 + description "ac connection." ;
211 + list acs{
212 + key "id";
213 + description "acs ID." ;
214 + leaf id {
215 + type string ;
216 + description "acs ID." ;
217 + }
218 + container connection {
219 + description "CE to PE connection." ;
220 + uses service-types:connection;
221 + }
222 + }
223 + }
224 + }
225 + }
226 + rpc inquire-l3vpn-instance-work-path {
227 + description "Inquire a L3VPN instance work path." ;
228 + input {
229 + leaf service-id {
230 + type string;
231 + description "service ID." ;
232 + }
233 + leaf ingress-ne-id {
234 + type string ;
235 + description "ingress network element ID." ;
236 + }
237 + leaf destination-ne-id {
238 + type string ;
239 + description "destination network element ID." ;
240 + }
241 + leaf ingress-ac-id {
242 + type string ;
243 + description "ingress ac ID." ;
244 + }
245 + leaf destination-ac-id {
246 + type string ;
247 + description "destination ac ID." ;
248 + }
249 + leaf path-layer {
250 + type string ;
251 + description "path layer." ;
252 + }
253 + leaf path-role {
254 + type string ;
255 + description "path role." ;
256 + }
257 + }
258 + output {
259 + container service-path {
260 + description "service path." ;
261 + leaf service-id {
262 + type string;
263 + description "service ID." ;
264 + }
265 + leaf ingress-ne-id {
266 + type string ;
267 + description "ingress network element ID." ;
268 + }
269 + leaf destination-ne-id {
270 + type string ;
271 + description "destination network element ID." ;
272 + }
273 + leaf ingress-ac-id {
274 + type string ;
275 + description "ingress access circuit ID." ;
276 + }
277 + leaf destination-ac-id {
278 + type string ;
279 + description "destination access circuit ID." ;
280 + }
281 + leaf path-layer {
282 + type string ;
283 + description "path layer." ;
284 + }
285 + leaf path-role {
286 + type string ;
287 + description "path role." ;
288 + }
289 + list path-list {
290 + key "ne-id";
291 + description "path list." ;
292 + leaf ne-id {
293 + type string;
294 + description "network element ID." ;
295 + }
296 + leaf ingress-ltp-id {
297 + type string;
298 + description "LTP ID." ;
299 + }
300 + leaf backward-peer-id {
301 + type string;
302 + description "backward peer ID." ;
303 + }
304 + leaf egress-ltp-id {
305 + type string;
306 + description "egress ltp ID." ;
307 + }
308 + leaf forward-peer-id {
309 + type string;
310 + description "forward peer ID." ;
311 + }
312 + }
313 + }
314 + }
315 + }
316 + }