27eab2e0870e21480db43821e0e810218a7815a3
[osm/SO.git] / rwlaunchpad / plugins / yang / rw-image-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-image-mgmt.yang
22  * @author Austin Cormier
23  * @date 2016/06/01
24  * @brief Image Management Yang
25  */
26
27 module rw-image-mgmt
28 {
29   namespace "http://riftio.com/ns/riftware-1.0/rw-image-mgmt";
30   prefix "rw-image-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 "rw-cloud";
46   }
47
48   import rwcal {
49     prefix "rwcal";
50   }
51
52   import rw-project {
53     prefix "rw-project";
54   }
55
56   import mano-types {
57     prefix "mano-types";
58   }
59
60   revision 2017-02-08 {
61     description
62       "Update model to support projects.";
63   }
64
65   revision 2016-06-01 {
66     description
67       "Initial revision.";
68   }
69
70   typedef job-status {
71     type enumeration {
72       enum QUEUED;
73       enum IN_PROGRESS;
74       enum CANCELLING;
75       enum CANCELLED;
76       enum COMPLETED;
77       enum FAILED;
78     }
79   }
80
81   typedef upload-task-status {
82     type enumeration {
83       enum QUEUED;
84       enum CHECK_IMAGE_EXISTS;
85       enum UPLOADING;
86       enum CANCELLING;
87       enum CANCELLED;
88       enum COMPLETED;
89       enum FAILED;
90     }
91   }
92
93   grouping image-upload-info {
94     leaf image-id {
95       description "The image id that exists in the image catalog";
96       type string;
97     }
98
99     leaf image-name {
100       description "The image name that exists in the image catalog";
101       type string;
102     }
103
104     leaf image-checksum {
105       description "The image md5 checksum";
106       type string;
107     }
108   }
109
110   grouping upload-task-status {
111     leaf status {
112       description "The status of the upload task";
113       type upload-task-status;
114       default QUEUED;
115     }
116
117     leaf detail {
118       description "Detailed upload status message";
119       type string;
120     }
121
122     leaf progress-percent {
123       description "The image upload progress percentage (0-100)";
124       type uint8;
125       default 0;
126     }
127
128     leaf bytes_written {
129       description "The number of bytes written";
130       type uint64;
131       default 0;
132     }
133
134     leaf bytes_total {
135       description "The total number of bytes to write";
136       type uint64;
137       default 0;
138     }
139
140     leaf bytes_per_second {
141       description "The total number of bytes written per second";
142       type uint32;
143       default 0;
144     }
145
146     leaf start-time {
147       description "The image upload start time (unix epoch)";
148       type uint32;
149     }
150
151     leaf stop-time {
152       description "The image upload stop time (unix epoch)";
153       type uint32;
154     }
155   }
156
157   grouping upload-task {
158     leaf cloud-account {
159       description "The cloud account to upload the image to";
160       type leafref {
161         path "../../../../rw-cloud:cloud/rw-cloud:account/rw-cloud:name";
162       }
163     }
164
165     uses image-upload-info;
166     uses upload-task-status;
167   }
168
169   augment "/rw-project:project" {
170     container upload-jobs {
171       rwpb:msg-new UploadJobs;
172       description "Image upload jobs";
173       config false;
174
175       list job {
176         rwpb:msg-new UploadJob;
177         key "id";
178
179         leaf id {
180           description "Unique image upload job-id";
181           type uint32;
182         }
183
184         leaf status {
185           description "Current job status";
186           type job-status;
187         }
188
189         leaf start-time {
190           description "The job start time (unix epoch)";
191           type uint32;
192         }
193
194         leaf stop-time {
195           description "The job stop time (unix epoch)";
196           type uint32;
197         }
198
199         list upload-tasks {
200           rwpb:msg-new UploadTask;
201           description "The upload tasks that are part of this job";
202           uses upload-task;
203         }
204       }
205     }
206   }
207
208   rpc create-upload-job {
209     input {
210       rwpb:msg-new CreateUploadJob;
211
212       uses mano-types:rpc-project-name;
213
214       choice image-selection {
215         case onboarded-image {
216           description "Use an image previously onboarded in the image catalog";
217           container onboarded-image {
218             uses image-upload-info;
219           }
220         }
221
222         case external-url {
223           description "Use an HTTP URL to pull the image from";
224
225           container external-url {
226             leaf image-url {
227               description "The image HTTP URL to pull the image from";
228               type string;
229             }
230
231             uses image-upload-info;
232
233             leaf disk-format {
234               description "Format of the Disk";
235               type rwcal:disk-format;
236             }
237
238             leaf container-format {
239               description "Format of the container";
240               type rwcal:container-format;
241               default "bare";
242             }
243           }
244         }
245       }
246
247       leaf-list cloud-account {
248         description "List of cloud accounts to upload the image to";
249         type leafref {
250           path "/rw-project:project[rw-project:name=current()/.." +
251             "/project-name]/rw-cloud:cloud/rw-cloud:account/rw-cloud:name";
252         }
253       }
254     }
255
256     output {
257       rwpb:msg-new CreateUploadJobOutput;
258       leaf job-id {
259         description "The upload job-id to cancel";
260         type uint32;
261       }
262     }
263   }
264
265   rpc cancel-upload-job {
266     input {
267       rwpb:msg-new CancelUploadJob;
268
269       leaf job-id {
270         type uint32;
271       }
272
273       uses mano-types:rpc-project-name;
274     }
275   }
276 }