Modify nemo template model.
[nemo.git] / nemo-api / src / main / yang / nemo-intent.yang
1 /*\r
2  * Copyright (c) 2015 Huawei, Inc. and others. All rights reserved.\r
3  *\r
4  * This program and the accompanying materials are made available under the\r
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,\r
6  * and is available at http://www.eclipse.org/legal/epl-v10.html\r
7  */\r
8 \r
9 module nemo-intent {\r
10     yang-version 1;\r
11 \r
12     namespace "urn:opendaylight:params:xml:ns:yang:nemo:intent";\r
13     prefix "nemo-intent";\r
14 \r
15     import nemo-common {prefix nemo-common;}\r
16     import nemo-object {prefix nemo-object;}\r
17     import nemo-operation {prefix nemo-operation;}\r
18     import nemo-template {prefix nemo-template;}\r
19     import nemo-user {prefix nemo-user;}\r
20 \r
21     revision "2015-10-10" {\r
22         description\r
23             "Initial revision.";\r
24     }\r
25 \r
26     grouping user-intent {\r
27         description\r
28             "User intent refers to a purpose in getting an ultimate result\r
29              or performing some specific operation on some objects.";\r
30 \r
31         container objects {\r
32             description\r
33                 "The element could be operated and managed by users.\r
34                  It inludes resources to construct users' virtual network,\r
35                  and the services in this network.In NEMO project, it is\r
36                  abstracted into node, connection and flow";\r
37 \r
38             list node {\r
39                 key "node-id";\r
40                 uses nemo-object:node-instance;\r
41             }\r
42 \r
43             list connection {\r
44                 key "connection-id";\r
45                 uses nemo-object:connection-instance;\r
46             }\r
47 \r
48             list flow {\r
49                 key "flow-id";\r
50                 uses nemo-object:flow-instance;\r
51             }\r
52         }\r
53 \r
54         container operations {\r
55             description\r
56                 "The operation is to dynamically adjust the behavior of network,\r
57                  and it is applied on objects, that is, node, connection and flow";\r
58 \r
59             list operation {\r
60                 key "operation-id";\r
61                 uses nemo-operation:operation-instance;\r
62             }\r
63         }\r
64 \r
65         container results {\r
66             // TBD\r
67         }\r
68 \r
69         container template-definitions {\r
70             description\r
71                 "Contains all templates that the user defined. A\r
72                  template defines a reusable function which could\r
73                  be used many times.";\r
74 \r
75             list template-definition {\r
76                 key "template-name";\r
77                 uses nemo-template:template-definition-grouping;\r
78             }\r
79         }\r
80 \r
81         container template-instances {\r
82             description\r
83                 "Contains all template instances that the user configured.\r
84                  A template instance is to put specific values in the\r
85                  parameter list of the definition.";\r
86 \r
87             list template-instance {\r
88                 key "template-instance-id";\r
89                 uses nemo-template:template-instance-grouping;\r
90             }\r
91         }\r
92     }\r
93 \r
94     container users {\r
95         description\r
96             "The list of all known users";\r
97 \r
98         list user {\r
99             description\r
100                 "A user is an administrative domain which is\r
101                  logically separated from other users, and each\r
102                  intent is specified by a particular user.";\r
103 \r
104             key "user-id";\r
105             uses nemo-user:user-instance;\r
106             uses user-intent;\r
107         }\r
108     }\r
109 \r
110     container query-condition-definitions {\r
111         description\r
112             "Contains the definitions for all advanced query, which means\r
113              they are the query with conditions supported by the NEMO engine.\r
114              User will fetch all results which meet the condition.";\r
115 \r
116         list query-condition-definition {\r
117             description\r
118                 "Define the query with condition. For example, user may\r
119                  intent to query all connection's name whose utilization is\r
120                  beyond 80%. That is a query with condition.";\r
121 \r
122             key "query-condition-name query-intent-type";\r
123             leaf query-condition-name {\r
124                 description\r
125                     "A user-visible name for the query condition definition.\r
126                      The query condition name is usually to specify the\r
127                      attribute or property of some kind of intent.\r
128                      For the above example, the query-condition-name is utility.";\r
129                 type nemo-common:query-condition-name;\r
130                 mandatory true;\r
131             }\r
132 \r
133             leaf query-intent-type {\r
134                 description\r
135                     "The target for the query, and its attributes will be checked out\r
136                      if meet the condition. In the above example, connection is the\r
137                      target. So, connection will be the query-intent-type here.";\r
138                 type enumeration {\r
139                     enum node;\r
140                     enum connection;\r
141                     enum flow;\r
142                     enum operation;\r
143                     enum result;\r
144                 }\r
145             }\r
146 \r
147             leaf query-condition-value-type {\r
148                 description\r
149                     "The type of the target value for the query condition.\r
150                      For the above example, the target-value is 80(%),\r
151                      so the query-condition-value-type will be int.";\r
152                 default string;\r
153                 type enumeration {\r
154                     enum string {\r
155                         description\r
156                             "A string-valued target value.";\r
157                     }\r
158                     enum int {\r
159                         description\r
160                             "An integer-valued target value.";\r
161                     }\r
162                     enum range {\r
163                         description\r
164                             "An integer-range target value.";\r
165                     }\r
166                 }\r
167             }\r
168 \r
169             container query-condition-match-patterns {\r
170                 description\r
171                     "The relationship between the value of query-condition-name\r
172                      and query-condition-target-value. If an intent's attribute\r
173                      or property specified by the query condition name matches\r
174                      to the target value by the match pattern, this intent meets\r
175                      the condition. For the above example, the condition's\r
176                      query-condition-match-patterns could be less-than, not-less-than,\r
177                      equal, not-equal, greater-than, not-greater-than, between.";\r
178 \r
179                 leaf-list query-condition-match-pattern {\r
180                     type enumeration {\r
181                         enum less-than;\r
182                         enum not-less-than;\r
183                         enum equal;\r
184                         enum not-equal;\r
185                         enum greater-than;\r
186                         enum not-greater-than;\r
187                         enum between;\r
188                     }\r
189                 }\r
190             }\r
191         }\r
192     }\r
193 \r
194     grouping common-rpc-result {\r
195         description\r
196             "Common return result for all defined RPCs.";\r
197 \r
198         leaf result-code {\r
199             description\r
200                 "Result code which is convenient for processing in a program.";\r
201             type enumeration {\r
202                 enum ok {\r
203                     description\r
204                         "The invoked RPC was executed successfully";\r
205                 }\r
206                 enum error {\r
207                     description\r
208                         "There's an error while executing the RPC";\r
209                 }\r
210             }\r
211         }\r
212 \r
213         leaf message {\r
214             description\r
215                 "A human-readable message for an error or exception";\r
216             type string;\r
217         }\r
218     }\r
219 \r
220     grouping query-condition-instance {\r
221         description\r
222             "A query condition instance generated according to\r
223              a specified query condition definition.";\r
224 \r
225         leaf query-condition-id {\r
226             description\r
227                 "A unique ID for a query condition instance.";\r
228             type nemo-common:query-condition-id;\r
229             mandatory true;\r
230         }\r
231 \r
232         leaf query-condition-name {\r
233             description\r
234                 "The name of the query condition definition.";\r
235             type nemo-common:query-condition-name;\r
236             mandatory true;\r
237         }\r
238 \r
239         leaf query-intent-type {\r
240             description\r
241                 "The type of the intents that the user wants to query from through\r
242                  the condition instance.";\r
243             type enumeration {\r
244                 enum node;\r
245                 enum connection;\r
246                 enum flow;\r
247                 enum operation;\r
248                 enum result;\r
249             }\r
250         }\r
251 \r
252         leaf query-condition-match-pattern {\r
253             description\r
254                 "The match pattern the condition instance will use.";\r
255             type enumeration {\r
256                 enum less-than;\r
257                 enum not-less-than;\r
258                 enum equal;\r
259                 enum not-equal;\r
260                 enum greater-than;\r
261                 enum not-greater-than;\r
262                 enum between;\r
263             }\r
264         }\r
265 \r
266         container query-condition-target-value {\r
267             description\r
268                 "The target value used to compare with the attribute\r
269                  or property of the intents.";\r
270 \r
271             leaf string-value {\r
272                 type string;\r
273             }\r
274 \r
275             leaf int-value {\r
276                 type int64;\r
277             }\r
278 \r
279             container range-value {\r
280                 leaf min {\r
281                     type int64;\r
282                     mandatory true;\r
283                 }\r
284 \r
285                 leaf max {\r
286                     type int64;\r
287                     mandatory true;\r
288                 }\r
289             }\r
290         }\r
291     }\r
292 \r
293     rpc register-user {\r
294         description\r
295             "Register a user to the user repository.";\r
296 \r
297         input {\r
298             uses nemo-user:user-instance;\r
299         }\r
300 \r
301         output {\r
302             uses common-rpc-result;\r
303         }\r
304     }\r
305 \r
306     rpc begin-transaction {\r
307         description\r
308             "Begin a transaction for the user";\r
309 \r
310         input {\r
311             uses nemo-user:user-instance;\r
312         }\r
313 \r
314         output {\r
315             uses common-rpc-result;\r
316         }\r
317     }\r
318 \r
319     rpc end-transaction {\r
320         description\r
321             "Commit the user's current transaction";\r
322 \r
323         input {\r
324             uses nemo-user:user-instance;\r
325         }\r
326 \r
327         output {\r
328             uses common-rpc-result;\r
329         }\r
330     }\r
331 \r
332     rpc language-style-nemo-request {\r
333         description\r
334             "Create, update or delete an intent of a user through an NEMO statement";\r
335 \r
336         input {\r
337             uses nemo-user:user-instance;\r
338 \r
339             leaf nemo-statement {\r
340                 type string;\r
341             }\r
342         }\r
343 \r
344         output {\r
345             uses common-rpc-result;\r
346         }\r
347     }\r
348 \r
349     rpc structure-style-nemo-update {\r
350         description\r
351             "Create or update all or a part of the user's intents,\r
352              which are described as json or xml format.";\r
353 \r
354         input {\r
355             uses nemo-user:user-instance;\r
356             uses user-intent;\r
357         }\r
358 \r
359         output {\r
360             uses common-rpc-result;\r
361         }\r
362     }\r
363 \r
364     rpc structure-style-nemo-delete {\r
365         description\r
366             "Delete some intents of a user from the user repository";\r
367 \r
368         input {\r
369             uses nemo-user:user-instance;\r
370 \r
371             container objects {\r
372                 leaf-list node {\r
373                     type nemo-common:node-id;\r
374                 }\r
375 \r
376                 leaf-list connection {\r
377                     type nemo-common:connection-id;\r
378                 }\r
379 \r
380                 leaf-list flow {\r
381                     type nemo-common:flow-id;\r
382                 }\r
383             }\r
384 \r
385             container operations {\r
386                 leaf-list operation {\r
387                     type nemo-common:operation-id;\r
388                 }\r
389             }\r
390 \r
391             container results {\r
392                 // TBD\r
393             }\r
394         }\r
395 \r
396         output {\r
397             uses common-rpc-result;\r
398         }\r
399     }\r
400 \r
401     rpc advanced-nemo-query {\r
402         description\r
403             "Query some intents of a user from the user repository\r
404              according to several advanced query conditions.";\r
405 \r
406         input {\r
407             uses nemo-user:user-instance;\r
408 \r
409             list query-condition {\r
410                 key "query-condition-id";\r
411                 uses query-condition-instance;\r
412             }\r
413         }\r
414 \r
415         output {\r
416             uses common-rpc-result;\r
417             uses user-intent;\r
418         }\r
419     }\r
420 }\r