ee3b7d18ad1309017c122cf034c64200b2a284e4
[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-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
60   import rw-nsd {
61     prefix "rwnsd";
62   }
63
64   import rw-project {
65     prefix "rw-project";
66   }
67
68   import rw-project-mano {
69     prefix "rw-project-mano";
70   }
71
72   revision 2017-02-08 {
73     description
74       "Update model to support projects.";
75   }
76
77   revision 2016-06-01 {
78     description
79       "Initial revision.";
80   }
81
82   typedef task-status {
83     type enumeration {
84       enum QUEUED;
85       enum IN_PROGRESS;
86       enum DOWNLOADING;
87       enum CANCELLED;
88       enum COMPLETED;
89       enum FAILED;
90     }
91   }
92
93   typedef export-schema {
94     type enumeration {
95       enum RIFT;
96       enum MANO;
97     }
98   }
99
100   typedef export-grammar {
101     type enumeration {
102       enum OSM;
103       enum TOSCA;
104     }
105   }
106
107   typedef export-format {
108     type enumeration {
109       enum YAML;
110       enum JSON;
111     }
112   }
113
114   grouping external-url-data {
115     leaf external-url {
116       description "Url to download";
117       type string;
118     }
119
120     leaf username {
121       description "username if the url uses authentication";
122       type string;
123     }
124
125     leaf password {
126       description "password if the url uses authentication";
127       type string;
128     }
129   }
130
131   grouping package-identifer {
132     leaf package-type {
133       description "Type of the package";
134       type manotypes:package-type;
135     }
136
137     leaf package-id {
138       description "Id of the package";
139       type string;
140     }
141   }
142
143   grouping package-file-identifer {
144     uses package-identifer;
145
146     leaf package-path {
147       description "Relative path in the package";
148       type string;
149     }
150   }
151
152   grouping download-task-status {
153     leaf status {
154       description "The status of the download task";
155       type task-status;
156       default QUEUED;
157     }
158
159     leaf detail {
160       description "Detailed download status message";
161       type string;
162     }
163
164     leaf progress-percent {
165       description "The download progress percentage (0-100)";
166       type uint8;
167       default 0;
168     }
169
170     leaf bytes_downloaded {
171       description "The number of bytes downloaded";
172       type uint64;
173       default 0;
174     }
175
176     leaf bytes_total {
177       description "The total number of bytes to write";
178       type uint64;
179       default 0;
180     }
181
182     leaf bytes_per_second {
183       description "The total number of bytes written per second";
184       type uint32;
185       default 0;
186     }
187
188     leaf start-time {
189       description "start time (unix epoch)";
190       type uint32;
191     }
192
193     leaf stop-time {
194       description "stop time (unix epoch)";
195       type uint32;
196     }
197   }
198
199   grouping copy-task-status {
200     leaf status {
201       description "The status of the copy task";
202       type task-status;
203       default QUEUED;
204     }
205   }
206
207   augment "/rw-project:project" {
208     container download-jobs {
209       rwpb:msg-new DownloadJobs;
210       description "Download jobs";
211       config false;
212
213       list job {
214         rwpb:msg-new DownloadJob;
215         key "download-id";
216
217         leaf download-id {
218           description "Unique UUID";
219           type string;
220         }
221
222         leaf url {
223           description "URL of the download";
224           type string;
225         }
226
227         uses package-file-identifer;
228         uses download-task-status;
229       }
230     }
231
232     container copy-jobs {
233       rwpb:msg-new CopyJobs;
234       description "Copy jobs";
235       config false;
236
237       list job {
238         rwpb:msg-new CopyJob;
239         key "transaction-id";
240
241         leaf transaction-id {
242           description "Unique UUID";
243           type string;
244         }
245
246         uses copy-task-status;
247       }
248     }
249   }
250
251   rpc get-package-endpoint {
252     description "Retrieves the endpoint for the descriptor";
253
254     input {
255       uses package-identifer;
256       uses manotypes:rpc-project-name;
257     }
258
259     output {
260      leaf endpoint {
261         description "Endpoint that contains all the package-related data";
262         type string;
263       }
264     }
265   }
266
267   rpc package-copy {
268     description "Copies the package specified in input and returns the copied package id";
269
270     input {
271       uses package-identifer;
272
273       leaf package-name {
274         description "Name of destination package";
275         type string;
276       }
277
278       uses manotypes:rpc-project-name;
279     }
280
281     output {
282      leaf transaction-id {
283         description "Valid ID to track the status of the task";
284         type string;
285       }
286
287      uses package-identifer;
288     }
289   }
290
291   rpc get-package-schema {
292     description "Retrieves the schema for the package type";
293
294     input {
295       leaf package-type {
296         description "Type of the package";
297         type manotypes:package-type;
298       }
299
300       uses manotypes:rpc-project-name;
301     }
302
303     output {
304       leaf-list schema {
305         description "List of all top level directories for the package.";
306         type string;
307       }
308     }
309   }
310
311   rpc package-create {
312     description "Creates a new package";
313
314     input {
315       uses package-identifer;
316       uses external-url-data;
317       uses manotypes:rpc-project-name;
318     }
319
320     output {
321      leaf transaction-id {
322         description "Valid ID to track the status of the task";
323         type string;
324       }
325       uses manotypes:rpc-project-name;
326     }
327   }
328
329   rpc package-update {
330     description "Creates a new package";
331
332     input {
333       uses package-identifer;
334       uses external-url-data;
335       uses manotypes:rpc-project-name;
336     }
337
338     output {
339      leaf transaction-id {
340         description "Valid ID to track the status of the task";
341         type string;
342       }
343       uses manotypes:rpc-project-name;
344     }
345   }
346
347   rpc package-export {
348     description "Export a package";
349
350     input {
351       uses package-identifer;
352       uses manotypes:rpc-project-name;
353
354       leaf export-schema {
355         description "Schema to export";
356         type export-schema;
357         default RIFT;
358       }
359
360       leaf export-grammar {
361         description "Schema to export";
362         type export-grammar;
363         default OSM;
364       }
365
366       leaf export-format {
367         description "Format to export";
368         type export-format;
369         default YAML;
370       }
371     }
372
373     output {
374      leaf transaction-id {
375         description "Valid ID to track the status of the task";
376         type string;
377       }
378
379      leaf filename {
380         description "Valid ID to track the status of the task";
381         type string;
382       }
383
384       uses manotypes:rpc-project-name;
385     }
386   }
387
388   rpc package-file-add {
389     description "Retrieves the file from the URL and store it in the package";
390
391     input {
392       uses package-file-identifer;
393       uses external-url-data;
394       uses manotypes:rpc-project-name;
395     }
396
397     output {
398      leaf task-id {
399         description "Valid ID to track the status of the task";
400         type string;
401       }
402       uses manotypes:rpc-project-name;
403     }
404   }
405
406   rpc package-file-delete {
407     description "Retrieves the file from the URL and store it in the package";
408
409     input {
410       uses package-file-identifer;
411       uses manotypes:rpc-project-name;
412     }
413
414     output {
415      leaf status {
416         description "Status of the delte operation";
417         type string;
418       }
419
420       leaf error-trace {
421         description "Trace in case of a failure";
422         type string;
423       }
424
425       uses manotypes:rpc-project-name;
426     }
427   }
428
429 }