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