c5689906a58df510db70bd134c036413d6706883
[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   augment "/rw-project:project" {
200     container download-jobs {
201       rwpb:msg-new DownloadJobs;
202       description "Download jobs";
203       config false;
204
205       list job {
206         rwpb:msg-new DownloadJob;
207         key "download-id";
208
209         leaf download-id {
210           description "Unique UUID";
211           type string;
212         }
213
214         leaf url {
215           description "URL of the download";
216           type string;
217         }
218
219         uses package-file-identifer;
220         uses download-task-status;
221       }
222     }
223   }
224
225   rpc get-package-endpoint {
226     description "Retrieves the endpoint for the descriptor";
227
228     input {
229       uses package-identifer;
230       uses manotypes:rpc-project-name;
231     }
232
233     output {
234      leaf endpoint {
235         description "Endpoint that contains all the package-related data";
236         type string;
237       }
238     }
239   }
240
241   rpc get-package-schema {
242     description "Retrieves the schema for the package type";
243
244     input {
245       leaf package-type {
246         description "Type of the package";
247         type manotypes:package-type;
248       }
249
250       uses manotypes:rpc-project-name;
251     }
252
253     output {
254       leaf-list schema {
255         description "List of all top level directories for the package.";
256         type string;
257       }
258     }
259   }
260
261   rpc package-create {
262     description "Creates a new package";
263
264     input {
265       uses package-identifer;
266       uses external-url-data;
267       uses manotypes:rpc-project-name;
268     }
269
270     output {
271      leaf transaction-id {
272         description "Valid ID to track the status of the task";
273         type string;
274       }
275       uses manotypes:rpc-project-name;
276     }
277   }
278
279   rpc package-update {
280     description "Creates a new package";
281
282     input {
283       uses package-identifer;
284       uses external-url-data;
285       uses manotypes:rpc-project-name;
286     }
287
288     output {
289      leaf transaction-id {
290         description "Valid ID to track the status of the task";
291         type string;
292       }
293       uses manotypes:rpc-project-name;
294     }
295   }
296
297   rpc package-export {
298     description "Export a package";
299
300     input {
301       uses package-identifer;
302       uses manotypes:rpc-project-name;
303
304       leaf export-schema {
305         description "Schema to export";
306         type export-schema;
307         default RIFT;
308       }
309
310       leaf export-grammar {
311         description "Schema to export";
312         type export-grammar;
313         default OSM;
314       }
315
316       leaf export-format {
317         description "Format to export";
318         type export-format;
319         default YAML;
320       }
321     }
322
323     output {
324      leaf transaction-id {
325         description "Valid ID to track the status of the task";
326         type string;
327       }
328
329      leaf filename {
330         description "Valid ID to track the status of the task";
331         type string;
332       }
333
334       uses manotypes:rpc-project-name;
335     }
336   }
337
338   rpc package-file-add {
339     description "Retrieves the file from the URL and store it in the package";
340
341     input {
342       uses package-file-identifer;
343       uses external-url-data;
344       uses manotypes:rpc-project-name;
345     }
346
347     output {
348      leaf task-id {
349         description "Valid ID to track the status of the task";
350         type string;
351       }
352       uses manotypes:rpc-project-name;
353     }
354   }
355
356   rpc package-file-delete {
357     description "Retrieves the file from the URL and store it in the package";
358
359     input {
360       uses package-file-identifer;
361       uses manotypes:rpc-project-name;
362     }
363
364     output {
365      leaf status {
366         description "Status of the delte operation";
367         type string;
368       }
369
370       leaf error-trace {
371         description "Trace in case of a failure";
372         type string;
373       }
374
375       uses manotypes:rpc-project-name;
376     }
377   }
378
379 }