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