[RIFT 16087] Backend changes to decouple storage semantics from user interface. Chang...
[osm/SO.git] / rwlaunchpad / plugins / yang / rw-pkg-mgmt.yang
1 /*
2  *
3  *   Copyright 2016 RIFT.IO Inc
4  *
5  *   Licensed under the Apache License, Version 2.0 (the "License");
6  *   you may not use this file except in compliance with the License.
7  *   You may obtain a copy of the License at
8  *
9  *       http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *   Unless required by applicable law or agreed to in writing, software
12  *   distributed under the License is distributed on an "AS IS" BASIS,
13  *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *   See the License for the specific language governing permissions and
15  *   limitations under the License.
16  *
17  *
18  */
19
20 /**
21  * @file rw-pkg-mgmt.yang
22  * @author Varun Prasad
23  * @date 2016/09/21
24  * @brief Pacakage Management Yang
25  */
26
27 module rw-pkg-mgmt
28 {
29   namespace "http://riftio.com/ns/riftware-1.0/rw-pkg-mgmt";
30   prefix "rw-pkg-mgmt";
31
32   import ietf-yang-types {
33     prefix "yang";
34   }
35
36   import rw-pb-ext {
37     prefix "rwpb";
38   }
39
40   import rw-cli-ext {
41     prefix "rwcli";
42   }
43
44   import rw-cloud {
45     prefix "rwcloud";
46   }
47
48   import rwcal {
49     prefix "rwcal";
50   }
51
52   import mano-types {
53     prefix "manotypes";
54   }
55
56   import rw-vnfd {
57     prefix "rwvnfd";
58   }
59   import rw-nsd {
60     prefix "rwnsd";
61   }
62
63   revision 2016-06-01 {
64     description
65       "Initial revision.";
66   }
67
68   typedef task-status {
69     type enumeration {
70       enum QUEUED;
71       enum IN_PROGRESS;
72       enum DOWNLOADING;
73       enum CANCELLED;
74       enum COMPLETED;
75       enum FAILED;
76     }
77   }
78
79   typedef package-file-type {
80     type enumeration {
81       enum ICONS;
82       enum CHARMS;
83       enum SCRIPTS;
84       enum IMAGES;
85       enum CLOUD_INIT;
86       enum README;
87     }
88   }
89
90   typedef vnfd-file-type {
91     type enumeration {
92       enum ICONS;
93       enum CHARMS;
94       enum SCRIPTS;
95       enum IMAGES;
96       enum CLOUD_INIT;
97       enum README;
98     }
99   }
100
101   typedef nsd-file-type {
102     type enumeration {
103       enum VNF_CONFIG;
104       enum NS_CONFIG;
105       enum ICONS;
106       enum SCRIPTS;
107     }
108   }
109
110   typedef export-schema {
111     type enumeration {
112       enum RIFT;
113       enum MANO;
114     }
115   }
116
117   typedef export-grammar {
118     type enumeration {
119       enum OSM;
120       enum TOSCA;
121     }
122   }
123
124   typedef export-format {
125     type enumeration {
126       enum YAML;
127       enum JSON;
128     }
129   }
130
131   grouping external-url-data {
132     leaf external-url {
133       description "Url to download";
134       type string;
135     }
136
137     leaf username {
138       description "username if the url uses authentication";
139       type string;
140     }
141
142     leaf password {
143       description "password if the url uses authentication";
144       type string;
145     }
146   }
147
148   grouping package-identifer {
149     leaf package-type {
150       description "Type of the package";
151       type manotypes:package-type;
152     }
153
154     leaf package-id {
155       description "Id of the package";
156       type string;
157     }
158   }
159
160   grouping package-file-identifer {
161     uses package-identifer;
162
163     leaf package-path {
164       description "Relative path in the package";
165       type string;
166     }
167   }
168
169   grouping download-task-status {
170     leaf status {
171       description "The status of the download task";
172       type task-status;
173       default QUEUED;
174     }
175
176     leaf detail {
177       description "Detailed download status message";
178       type string;
179     }
180
181     leaf progress-percent {
182       description "The download progress percentage (0-100)";
183       type uint8;
184       default 0;
185     }
186
187     leaf bytes_downloaded {
188       description "The number of bytes downloaded";
189       type uint64;
190       default 0;
191     }
192
193     leaf bytes_total {
194       description "The total number of bytes to write";
195       type uint64;
196       default 0;
197     }
198
199     leaf bytes_per_second {
200       description "The total number of bytes written per second";
201       type uint32;
202       default 0;
203     }
204
205     leaf start-time {
206       description "start time (unix epoch)";
207       type uint32;
208     }
209
210     leaf stop-time {
211       description "stop time (unix epoch)";
212       type uint32;
213     }
214   }
215
216   grouping copy-task-status {
217     leaf status {
218       description "The status of the copy task";
219       type task-status;
220       default QUEUED;
221     }
222   }
223
224   container download-jobs {
225     rwpb:msg-new DownloadJobs;
226     description "Download jobs";
227     config false;
228
229     list job {
230       rwpb:msg-new DownloadJob;
231       key "download-id";
232
233       leaf download-id {
234         description "Unique UUID";
235         type string;
236       }
237
238       leaf url {
239         description "URL of the download";
240         type string;
241       }
242
243       uses package-file-identifer;
244       uses download-task-status;
245     }
246   }
247
248   container copy-jobs {
249     rwpb:msg-new CopyJobs;
250     description "Copy jobs";
251     config false;
252
253     list job {
254       rwpb:msg-new CopyJob;
255       key "transaction-id";
256
257       leaf transaction-id {
258         description "Unique UUID";
259         type string;
260       }
261
262       uses copy-task-status;
263     }
264   }
265
266   rpc get-package-endpoint {
267     description "Retrieves the endpoint for the descriptor";
268
269     input {
270       uses package-identifer;
271     }
272
273     output {
274      leaf endpoint {
275         description "Endpoint that contains all the package-related data";
276         type string;
277       }
278     }
279   }
280
281   rpc package-copy {
282     description "Copies the package specified in input and returns the copied package id";
283
284     input {
285       uses package-identifer;
286
287       leaf package-name {
288         description "Name of destination package";
289         type string;
290       }
291     }
292
293     output {
294      leaf transaction-id {
295         description "Valid ID to track the status of the task";
296         type string;
297       }
298
299      uses package-identifer;
300     }
301   }
302
303   rpc get-package-schema {
304     description "Retrieves the schema for the package type";
305
306     input {
307       leaf package-type {
308         description "Type of the package";
309         type manotypes:package-type;
310       }
311     }
312
313     output {
314       leaf-list schema {
315         description "List of all top level directories for the package.";
316         type string;
317       }
318     }
319   }
320
321   rpc package-create {
322     description "Creates a new package";
323
324     input {
325       uses package-identifer;
326       uses external-url-data;
327     }
328
329     output {
330      leaf transaction-id {
331         description "Valid ID to track the status of the task";
332         type string;
333       }
334     }
335   }
336
337   rpc package-update {
338     description "Creates a new package";
339
340     input {
341       uses package-identifer;
342       uses external-url-data;
343     }
344
345     output {
346      leaf transaction-id {
347         description "Valid ID to track the status of the task";
348         type string;
349       }
350     }
351   }
352
353   rpc package-export {
354     description "Export a package";
355
356     input {
357       uses package-identifer;
358
359       leaf export-schema {
360         description "Schema to export";
361         type export-schema;
362         default RIFT;
363       }
364
365       leaf export-grammar {
366         description "Schema to export";
367         type export-grammar;
368         default OSM;
369       }
370
371       leaf export-format {
372         description "Format to export";
373         type export-format;
374         default YAML;
375       }
376
377     }
378
379     output {
380      leaf transaction-id {
381         description "Valid ID to track the status of the task";
382         type string;
383       }
384
385      leaf filename {
386         description "Valid ID to track the status of the task";
387         type string;
388       }
389     }
390   }
391
392   rpc package-file-add {
393     description "Retrieves the file from the URL and store it in the package";
394
395     input {
396       uses package-file-identifer;
397       uses external-url-data;
398
399       choice catalog-type {
400           mandatory true;
401           case VNFD {
402             leaf vnfd-file-type { 
403                 description "Type of vnfd file being added to the package"; 
404                 type vnfd-file-type; 
405             }
406           }
407           case NSD {
408             leaf nsd-file-type { 
409                 description "Type of nsd file being added to the package"; 
410                 type nsd-file-type; 
411             }
412           }
413       }
414       
415     }
416
417     output {
418      leaf task-id {
419         description "Valid ID to track the status of the task";
420         type string;
421       }
422     }
423   }
424
425   rpc package-file-delete {
426     description "Retrieves the file from the URL and store it in the package";
427
428     input {
429       uses package-file-identifer;
430       choice catalog-type {
431           case VNFD {
432             leaf vnfd-file-type { 
433                 description "Type of file being removed from the vnfd package"; 
434                 type vnfd-file-type; 
435             }
436           }
437           case NSD {
438             leaf nsd-file-type { 
439                 description "Type of file being removed from the nsd package"; 
440                 type nsd-file-type; 
441             }
442           }
443       }
444       
445     }
446
447     output {
448      leaf status {
449         description "Status of the delte operation";
450         type string;
451       }
452
453       leaf error-trace {
454         description "Trace in case of a failure";
455         type string;
456       }
457
458     }
459   }
460
461 }