update from RIFT as of 696b75d2fe9fb046261b08c616f1bcf6c0b54a9b second try
[osm/SO.git] / rwlaunchpad / plugins / yang / rw-pkg-mgmt.yang
1 /*
2  *
3  *   Copyright 2016-2017 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-cli-ext {
37     prefix "rwcli";
38   }
39
40   import rw-cloud {
41     prefix "rwcloud";
42   }
43
44   import rwcal {
45     prefix "rwcal";
46   }
47
48   import mano-types {
49     prefix "manotypes";
50   }
51
52   import rw-vnfd {
53     prefix "rwvnfd";
54   }
55
56   import rw-nsd {
57     prefix "rwnsd";
58   }
59
60   import rw-project-vnfd {
61     prefix "rw-project-vnfd";
62   }
63
64   import rw-project-nsd {
65     prefix "rw-project-nsd";
66   }
67
68   import rw-project {
69     prefix "rw-project";
70   }
71
72   import rw-project-mano {
73     prefix "rw-project-mano";
74   }
75
76   revision 2017-02-08 {
77     description
78       "Update model to support projects.";
79   }
80
81   revision 2016-06-01 {
82     description
83       "Initial revision.";
84   }
85
86   typedef task-status {
87     type enumeration {
88       enum QUEUED;
89       enum IN_PROGRESS;
90       enum DOWNLOADING;
91       enum CANCELLED;
92       enum COMPLETED;
93       enum FAILED;
94     }
95   }
96
97   typedef package-file-type {
98     type enumeration {
99       enum ICONS;
100       enum CHARMS;
101       enum SCRIPTS;
102       enum IMAGES;
103       enum CLOUD_INIT;
104       enum README;
105     }
106   }
107
108   typedef vnfd-file-type {
109     type enumeration {
110       enum ICONS;
111       enum CHARMS;
112       enum SCRIPTS;
113       enum IMAGES;
114       enum CLOUD_INIT;
115       enum README;
116       enum DOC;
117       enum TEST;
118     }
119   }
120
121   typedef nsd-file-type {
122     type enumeration {
123       enum VNF_CONFIG;
124       enum NS_CONFIG;
125       enum ICONS;
126       enum SCRIPTS;
127     }
128   }
129
130   typedef export-schema {
131     type enumeration {
132       enum RIFT;
133       enum MANO;
134     }
135   }
136
137   typedef export-grammar {
138     type enumeration {
139       enum OSM;
140       enum TOSCA;
141     }
142   }
143
144   typedef export-format {
145     type enumeration {
146       enum YAML;
147       enum JSON;
148     }
149   }
150
151   grouping external-url-data {
152     leaf external-url {
153       description "Url to download";
154       type string;
155     }
156
157     leaf username {
158       description "username if the url uses authentication";
159       type string;
160     }
161
162     leaf password {
163       description "password if the url uses authentication";
164       type string;
165     }
166   }
167
168   grouping package-identifer {
169     leaf package-type {
170       description "Type of the package";
171       type manotypes:package-type;
172     }
173
174     leaf package-id {
175       description "Id of the package";
176       type string;
177     }
178   }
179
180   grouping package-file-identifer {
181     uses package-identifer;
182
183     leaf package-path {
184       description "Relative path in the package";
185       type string;
186     }
187   }
188
189   grouping download-task-status {
190     leaf status {
191       description "The status of the download task";
192       type task-status;
193       default QUEUED;
194     }
195
196     leaf detail {
197       description "Detailed download status message";
198       type string;
199     }
200
201     leaf progress-percent {
202       description "The download progress percentage (0-100)";
203       type uint8;
204       default 0;
205     }
206
207     leaf bytes_downloaded {
208       description "The number of bytes downloaded";
209       type uint64;
210       default 0;
211     }
212
213     leaf bytes_total {
214       description "The total number of bytes to write";
215       type uint64;
216       default 0;
217     }
218
219     leaf bytes_per_second {
220       description "The total number of bytes written per second";
221       type uint32;
222       default 0;
223     }
224
225     leaf start-time {
226       description "start time (unix epoch)";
227       type uint32;
228     }
229
230     leaf stop-time {
231       description "stop time (unix epoch)";
232       type uint32;
233     }
234   }
235
236   grouping copy-task-status {
237     leaf status {
238       description "The status of the copy task";
239       type task-status;
240       default QUEUED;
241     }
242   }
243
244   augment "/rw-project:project" {
245     container download-jobs {
246       description "Download jobs";
247       config false;
248
249       list job {
250         key "download-id";
251
252         leaf download-id {
253           description "Unique UUID";
254           type string;
255         }
256
257         leaf url {
258           description "URL of the download";
259           type string;
260         }
261
262         uses package-file-identifer;
263         uses download-task-status;
264       }
265     }
266
267     container copy-jobs {
268       description "Copy jobs";
269       config false;
270
271       list job {
272         key "transaction-id";
273
274         leaf transaction-id {
275           description "Unique UUID";
276           type string;
277         }
278
279         uses copy-task-status;
280       }
281     }
282
283     container create-jobs {
284       description "Create jobs";
285       config false;
286
287       list job {
288         key "transaction-id";
289
290         leaf transaction-id {
291           description "Unique UUID";
292           type string;
293         }
294
295         uses copy-task-status;
296       }
297     }
298
299     container update-jobs {
300       description "Update jobs";
301       config false;
302
303       list job {
304         key "transaction-id";
305
306         leaf transaction-id {
307           description "Unique UUID";
308           type string;
309         }
310
311         uses copy-task-status;
312       }
313     }
314   }
315
316
317   rpc get-package-endpoint {
318     description "Retrieves the endpoint for the descriptor";
319
320     input {
321       uses package-identifer;
322       uses manotypes:rpc-project-name;
323     }
324
325     output {
326      leaf endpoint {
327         description "Endpoint that contains all the package-related data";
328         type string;
329       }
330     }
331   }
332
333   rpc package-copy {
334     description "Copies the package specified in input and returns the copied package id";
335
336     input {
337       uses package-identifer;
338
339       leaf package-name {
340         description "Name of destination package";
341         type string;
342       }
343
344       uses manotypes:rpc-project-name;
345     }
346
347     output {
348      leaf transaction-id {
349         description "Valid ID to track the status of the task";
350         type string;
351       }
352
353      uses package-identifer;
354     }
355   }
356
357   rpc get-package-schema {
358     description "Retrieves the schema for the package type";
359
360     input {
361       leaf package-type {
362         description "Type of the package";
363         type manotypes:package-type;
364       }
365
366       uses manotypes:rpc-project-name;
367     }
368
369     output {
370       leaf-list schema {
371         description "List of all top level directories for the package.";
372         type string;
373       }
374     }
375   }
376
377   rpc package-create {
378     description "Creates a new package";
379
380     input {
381       uses package-identifer;
382       uses external-url-data;
383       uses manotypes:rpc-project-name;
384     }
385
386     output {
387      leaf transaction-id {
388         description "Valid ID to track the status of the task";
389         type string;
390       }
391       uses manotypes:rpc-project-name;
392     }
393   }
394
395   rpc package-update {
396     description "Creates a new package";
397
398     input {
399       uses package-identifer;
400       uses external-url-data;
401       uses manotypes:rpc-project-name;
402     }
403
404     output {
405      leaf transaction-id {
406         description "Valid ID to track the status of the task";
407         type string;
408       }
409       uses manotypes:rpc-project-name;
410     }
411   }
412
413   rpc package-export {
414     description "Export a package";
415
416     input {
417       uses package-identifer;
418       uses manotypes:rpc-project-name;
419
420       leaf export-schema {
421         description "Schema to export";
422         type export-schema;
423         default RIFT;
424       }
425
426       leaf export-grammar {
427         description "Schema to export";
428         type export-grammar;
429         default OSM;
430       }
431
432       leaf export-format {
433         description "Format to export";
434         type export-format;
435         default YAML;
436       }
437     }
438
439     output {
440      leaf transaction-id {
441         description "Valid ID to track the status of the task";
442         type string;
443       }
444
445      leaf filename {
446         description "Valid ID to track the status of the task";
447         type string;
448       }
449
450       uses manotypes:rpc-project-name;
451     }
452   }
453
454   rpc package-file-add {
455     description "Retrieves the file from the URL and store it in the package";
456
457     input {
458       uses package-file-identifer;
459       uses external-url-data;
460       uses manotypes:rpc-project-name;
461
462       choice catalog-type {
463           mandatory true;
464           case VNFD {
465             leaf vnfd-file-type { 
466                 description "Type of vnfd file being added to the package"; 
467                 type vnfd-file-type; 
468             }
469           }
470           case NSD {
471             leaf nsd-file-type { 
472                 description "Type of nsd file being added to the package"; 
473                 type nsd-file-type; 
474             }
475           }
476       }
477     }
478
479     output {
480      leaf task-id {
481         description "Valid ID to track the status of the task";
482         type string;
483       }
484       uses manotypes:rpc-project-name;
485     }
486   }
487
488   rpc package-file-delete {
489     description "Retrieves the file from the URL and store it in the package";
490
491     input {
492       uses package-file-identifer;
493       uses manotypes:rpc-project-name;
494
495       choice catalog-type {
496           case VNFD {
497             leaf vnfd-file-type { 
498                 description "Type of file being removed from the vnfd package"; 
499                 type vnfd-file-type; 
500             }
501           }
502           case NSD {
503             leaf nsd-file-type { 
504                 description "Type of file being removed from the nsd package"; 
505                 type nsd-file-type; 
506             }
507           }
508       }
509     }
510
511     output {
512      leaf status {
513         description "Status of the delte operation";
514         type string;
515       }
516
517       leaf error-trace {
518         description "Trace in case of a failure";
519         type string;
520       }
521
522       uses manotypes:rpc-project-name;
523     }
524   }
525
526 }