Update API spec to support multi-tenants
[multicloud/framework.git] / docs / specs / multicloud_infra_workload.rst
1 .. This work is licensed under a Creative Commons Attribution 4.0 International License.
2 .. http://creativecommons.org/licenses/by/4.0
3 .. Copyright (c) 2017-2018 Intel, Inc.
4
5 ===============================
6 MultiCloud infra_workload API
7 ===============================
8
9 We have two purposes for this API:
10
11 #. Integrate SO and Multicloud.
12 #. Generic API for SO to talk to different Multicloud plugins.
13
14
15 Problem Description
16 ===================
17
18 Currently HPA flavors are returned by OOF to SO and SO copies these flavors in
19 the Heat template before sending the Heat template to Multicloud. In Casablanca
20 instead of SO making changes in the Heat template the flavor information will be
21 provided to Multicloud and Multicloud will pass this as parameters to HEAT
22 command line.
23 For further detailed design, please refer to https://wiki.onap.org/display/DW/SO+Casablanca+HPA+Design
24
25
26 Propose Change
27 ==============
28
29 Multi-Tenant Support
30 --------------------
31
32 Request Headers:
33 >>>>>>>>>>>>>>>>
34
35 To support multi-tenants over the same cloud region, all APIs defined below
36 should support to accept the following optional headers which are used to
37 specify a tenant other than the default one associated with the cloud region.
38
39 ::
40
41   "Project"   : Tenant/Project ID or Name specified by API consumer, Optional
42
43
44 Example 1:
45 ::
46
47   "Project: tenant1"
48
49 Example 2:
50 ::
51
52   "Project: fcca3cc49d5e42caae15459e27103efc"
53
54
55
56 Add infrastructure workload
57 ---------------------------
58
59 API URL: POST http://{msb IP}:{msb port}/api/multicloud/v1/{cloud-owner}/{cloud-region-id}/infra_workload
60
61 Request Body:
62 >>>>>>>>>>>>>
63 ::
64
65   {
66      "generic-vnf-id":"<generic-vnf-id>",
67      "vf-module-id":"<vf-module-id>",
68      "oof_directives":{},
69      "sdnc_directives":{},
70      "template_type":"<heat/tosca/etc.>",
71      "template_data":{}
72   }
73
74 oof_directives:
75 :::::::::::::::
76 ::
77
78       "directives":[
79          {
80            "id":"<ID of VNFC>",
81            "type": "vnfc",
82            "directives":[
83              {
84                "type":"<flavor_directive>",
85                "attributes":[
86                  {
87                    "attribute_name":"<name of attribute, such as flavor label>",
88                    "attribute_value":"<value such as cloud specific flavor>"
89                  }
90                ]
91              }
92            ]
93          },
94          {
95            "id":"<ID of VNF>",
96            "type": "vnf",
97            "directives":[
98              {
99                "type":"<Name of directive>",
100                "attributes":[
101                  {
102                    "attribute_name":"<name of attribute>",
103                    "attribute_value":"<value>"
104                  }
105                ]
106              }
107            ]
108          }
109       ]
110
111 Heat examples
112 :::::::::::::
113 ::
114
115   "template_type":"heat",
116   "template_data":{
117      "files":{  },
118      "disable_rollback":true,
119      "parameters":{
120         "flavor":"m1.heat"
121      },
122      "stack_name":"teststack",
123      "template":{
124         "heat_template_version":"2013-05-23",
125         "description":"Simple template to test heat commands",
126         "parameters":
127         {
128            "flavor":{
129               "default":"m1.tiny",
130               "type":"string"
131            }
132         },
133         "resources":{
134            "hello_world":{
135               "type":"OS::Nova::Server",
136               "properties":{
137                  "key_name":"heat_key",
138                  "flavor":{
139                     "get_param":"flavor"
140                  },
141                  "image":"40be8d1a-3eb9-40de-8abd-43237517384f",
142                  "user_data":"#!/bin/bash -xv\necho \"hello world\" &gt; /root/hello-world.txt\n"
143               }
144            }
145         }
146      },
147      "timeout_mins":60
148   }
149
150 Response:
151 >>>>>>>>>
152
153 Response Codes
154 ::::::::::::::
155 Success
156 .......
157
158 +--------------------+----------------------------------------------------------------------+
159 | Code               | Reason                                                               |
160 +====================+======================================================================+
161 | 201 - Created      | Resource was created and is ready to use.                            |
162 +--------------------+----------------------------------------------------------------------+
163
164 Error
165 .....
166
167 +--------------------+----------------------------------------------------------------------+
168 | Code               | Reason                                                               |
169 +====================+======================================================================+
170 | 400 - Bad Request  | Some content in the request was invalid.                             |
171 +--------------------+----------------------------------------------------------------------+
172 | 401 - Unauthorized | User must authenticate before making a request.                      |
173 +--------------------+----------------------------------------------------------------------+
174 | 409 - Conflict     | This operation conflicted with another operation on this resource.   |
175 +--------------------+----------------------------------------------------------------------+
176
177 Response Body
178 :::::::::::::
179 ::
180
181     {
182         "template_type":"heat",
183         "workload_id": "<The ID of infrastructure workload resource>"
184         "template_response":
185         {
186             "stack": {
187             "id": "<The UUID of stack>",
188             "links": [
189                 {
190                      "href": "<A list of URLs for the stack>",
191                      "rel": "self"
192                 }
193             ]
194         }
195     }
196
197 Delete infrastructure workload
198 ------------------------------
199
200 API DELETE URL: http://{msb IP}:{msb port}/api/multicloud/v1/{cloud-owner}/{cloud-region-id}/infra_workload/{workload-id}
201
202 Response:
203 >>>>>>>>>
204
205 Response Codes
206 ::::::::::::::
207 Success
208 .......
209
210 +--------------------+----------------------------------------------------------------------+
211 | Code               | Reason                                                               |
212 +====================+======================================================================+
213 | 204 - No Content   | The server has fulfilled the request by deleting the resource.       |
214 +--------------------+----------------------------------------------------------------------+
215
216 Error
217 .....
218
219 +--------------------+----------------------------------------------------------------------+
220 | Code               | Reason                                                               |
221 +====================+======================================================================+
222 | 400 - Bad Request  | Some content in the request was invalid.                             |
223 +--------------------+----------------------------------------------------------------------+
224 | 401 - Unauthorized | User must authenticate before making a request.                      |
225 +--------------------+----------------------------------------------------------------------+
226 | 404 - Not Found    | The requested resource could not be found.                           |
227 +--------------------+----------------------------------------------------------------------+
228 | 500 - Internal     | Something went wrong inside the service. This should not happen      |
229 |       Server Error | usually. If it does happen, it means the server has experienced      |
230 |                    | some serious problems.                                               |
231 +--------------------+----------------------------------------------------------------------+
232
233 Response Body
234 :::::::::::::
235 This request does not return anything in the response body.
236
237 Get infrastructure workload
238 ----------------------------
239
240 API GET URL: http://{msb IP}:{msb port}/api/multicloud/v1/{cloud-owner}/{cloud-region-id}/infra_workload/{workload-id}
241
242 Response:
243 >>>>>>>>>
244
245 Response Codes
246 ::::::::::::::
247 Success
248 .......
249
250 +--------------------+----------------------------------------------------------------------+
251 | Code               | Reason                                                               |
252 +====================+======================================================================+
253 | 200 - OK           | Request was successful.                                              |
254 +--------------------+----------------------------------------------------------------------+
255
256 Error
257 .....
258
259 +--------------------+----------------------------------------------------------------------+
260 | Code               | Reason                                                               |
261 +====================+======================================================================+
262 | 400 - Bad Request  | Some content in the request was invalid.                             |
263 +--------------------+----------------------------------------------------------------------+
264 | 401 - Unauthorized | User must authenticate before making a request.                      |
265 +--------------------+----------------------------------------------------------------------+
266 | 404 - Not Found    | The requested resource could not be found.                           |
267 +--------------------+----------------------------------------------------------------------+
268 | 500 - Internal     | Something went wrong inside the service. This should not happen      |
269 |       Server Error | usually. If it does happen, it means the server has experienced      |
270 |                    | some serious problems.                                               |
271 +--------------------+----------------------------------------------------------------------+
272
273 Response Body
274 :::::::::::::
275 ::
276
277     {
278         "template_type":"<heat/tosca/etc.>",
279         "workload_id": "<The ID of infrastructure workload resource>",
280         "workload_status":"CREATE_IN_PROCESS/CREATE_COMPLETE/DELETE_IN_PROCESS/etc"
281     }
282
283 Work Items
284 ==========
285
286 #. Work with SO.
287 #. Work with OOF team for oof_directive form.
288 #. Work with SDNC team for sdc_directive form.
289 #. Expose API by broker and each plugin.
290
291 Tests
292 =====
293
294 #. Unit Tests with tox.
295 #. Pairwise test with SO project.
296 #. Integration test with vCPE HPA test.
297 #. CSIT Tests, the input/ouput of broker and each plugin see API design above.