update from RIFT as of 696b75d2fe9fb046261b08c616f1bcf6c0b54a9b second try
[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-cli-ext {
37     prefix "rwcli";
38   }
39
40   import rw-cloud {
41     prefix "rw-cloud";
42   }
43
44   import rwcal {
45     prefix "rwcal";
46   }
47
48   import rw-project {
49     prefix "rw-project";
50   }
51
52   import rw-project-mano {
53     prefix "rw-project-mano";
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       description "Image upload jobs";
172       config false;
173
174       list job {
175         key "id";
176
177         leaf id {
178           description "Unique image upload job-id";
179           type uint32;
180         }
181
182         leaf status {
183           description "Current job status";
184           type job-status;
185         }
186
187         leaf start-time {
188           description "The job start time (unix epoch)";
189           type uint32;
190         }
191
192         leaf stop-time {
193           description "The job stop time (unix epoch)";
194           type uint32;
195         }
196
197         list upload-tasks {
198           description "The upload tasks that are part of this job";
199           uses upload-task;
200         }
201       }
202     }
203   }
204
205   rpc create-upload-job {
206     input {
207       
208       uses mano-types:rpc-project-name;
209
210       choice image-selection {
211         case onboarded-image {
212           description "Use an image previously onboarded in the image catalog";
213           container onboarded-image {
214             uses image-upload-info;
215           }
216         }
217
218         case external-url {
219           description "Use an HTTP URL to pull the image from";
220
221           container external-url {
222             leaf image-url {
223               description "The image HTTP URL to pull the image from";
224               type string;
225             }
226
227             uses image-upload-info;
228
229             leaf disk-format {
230               description "Format of the Disk";
231               type rwcal:disk-format;
232             }
233
234             leaf container-format {
235               description "Format of the container";
236               type rwcal:container-format;
237               default "bare";
238             }
239           }
240         }
241       }
242
243       leaf-list cloud-account {
244         description "List of cloud accounts to upload the image to";
245         type leafref {
246           path "/rw-project:project[rw-project:name=current()/.." +
247             "/project-name]/rw-cloud:cloud/rw-cloud:account/rw-cloud:name";
248         }
249       }
250     }
251
252     output {
253       leaf job-id {
254         description "The upload job-id to cancel";
255         type uint32;
256       }
257     }
258   }
259
260   rpc cancel-upload-job {
261     input {
262       leaf job-id {
263         type uint32;
264       }
265
266       uses mano-types:rpc-project-name;
267     }
268   }
269 }