summaryrefslogtreecommitdiffstats
path: root/cyborg_enhancement/mitaka_version/cyborg/doc/source/devdoc/specs/pike/approved/cyborg-api-proposal.rst
blob: 42ddad7ea83c4f965321a0f731e448628d186773 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
..
 This work is licensed under a Creative Commons Attribution 3.0 Unported
 License.

 http://creativecommons.org/licenses/by/3.0/legalcode

===================
Cyborg API proposal
===================

https://blueprints.launchpad.net/openstack-cyborg/+spec/cyborg-api

This spec proposes to provide the initial API design for Cyborg.

Problem description
===================

Cyborg as a common management framework for dedicated devices (hardware/
software accelerators, high-speed storage, etc) needs RESTful API to expose
the basic functionalities.

Use Cases
---------

* As a user I want to be able to spawn VM with dedicated hardware, so
that I can utilize provided hardware.
* As a compute service I need to know how requested resource should be
attached to the VM.
* As a scheduler service I'd like to know on which resource provider
requested resource can be found.

Proposed change
===============

In general we want to develop the APIs that support basic life cycle management
for Cyborg.

Life Cycle Management Phases
----------------------------

For cyborg, LCM phases include typical create, retrieve, update, delete operations.
One thing should be noted that deprovisioning mainly refers to detach(delete) operation
which deactivate an acceleration capability but preserve the resource itself
for future usage. For Cyborg, from functional point of view, the LCM includes provision,
attach,update,list, and detach. There is no notion of deprovisioning for Cyborg API
in a sense that we decomission or disconnect an entire accelerator device from
the bus.

Difference between Provision and Attach/Detach
----------------------------------------------

Noted that while the APIs support provisioning via CRUD operations, attach/detach
are considered different:

* Provision operations (create) will involve api->
conductor->agent->driver workflow, where as attach/detach (update/delete) could be taken
care of at the driver layer without the involvement of the pre-mentioned workflow. This
is similar to the difference between create a volume and attach/detach a volume in Cinder.

* The attach/detach in Cyborg API will mainly involved in DB status modification.

Difference between Attach/Detach To VM and Host
-----------------------------------------------

Moreover there are also differences when we attach an accelerator to a VM or
a host, similar to Cinder.

* When the attachment happens to a VM, we are expecting that Nova could call
the virt driver to perform the action for the instance. In this case Nova
needs to support the acc-attach and acc-detach action.

* When the attachment happens to a host, we are expecting that Cyborg could
take care of the action itself via Cyborg driver. Althrough currently there
is the generic driver to accomplish the job, we should consider a os-brick
like standalone lib for accelerator attach/detach operations.

Alternatives
------------

* For attaching an accelerator to a VM, we could let Cyborg perform the action
itself, however it runs into the risk of tight-coupling with Nova of which Cyborg
needs to get instance related information.
* For attaching an accelerator to a host, we could consider to use Ironic drivers
however it might not bode well with the standalone accelerator rack scenarios where
accelerators are not attached to server at all.

Data model impact
-----------------

A new table in the API database will be created::

    CREATE TABLE accelerators (
        accelerator_id INT NOT NULL,
        device_type STRING NOT NULL,
        acc_type STRING NOT NULL,
        acc_capability STRING NOT NULL,
        vendor_id STRING,
        product_id STRING,
        remotable INT,
    );

Note that there is an ongoing discussion on nested resource
provider new data structures that will impact Cyborg DB imp-
lementation. For code implementation it should be aligned
with resource provider db requirement as much as possible.


REST API impact
---------------

The API changes add resource endpoints to:

* `GET` a list of all the accelerators
* `GET` a single accelerator for a given id
* `POST` create a new accelerator resource
* `PUT` an update to an existing accelerator spec
* `PUT` attach an accelerator to a VM or a host
* `DELETE` detach an existing accelerator for a given id

The following new REST API call will be created:

'GET /accelerators'
*************************

Return a list of accelerators managed by Cyborg

Example message body of the response to the GET operation::

    200 OK
    Content-Type: application/json

    {
       "accelerator":[
        {
          "uuid":"8e45a2ea-5364-4b0d-a252-bf8becaa606e",
          "acc_specs":
          {
             "remote":0,
             "num":1,
             "device_type":"CRYPTO"
             "acc_capability":
             {
                "num":2
                "ipsec":
                {
                   "aes":
                   {
                      "3des":50,
                      "num":1,
                   }
                }
             }
           }
         },
         {
           "uuid":"eaaf1c04-ced2-40e4-89a2-87edded06d64",
           "acc_specs":
           {
              "remote":0,
              "num":1,
              "device_type":"CRYPTO"
              "acc_capability":
              {
                 "num":2
                 "ipsec":
                 {
                    "aes":
                    {
                       "3des":40,
                       "num":1,
                    }
                 }
              }
            }
          }
       ]
    }

'GET /accelerators/{uuid}'
*************************

Retrieve a certain accelerator info indetified by '{uuid}'

Example GET Request::

    GET /accelerators/8e45a2ea-5364-4b0d-a252-bf8becaa606e

    200 OK
    Content-Type: application/json

    {
       "uuid":"8e45a2ea-5364-4b0d-a252-bf8becaa606e",
       "acc_specs":{
          "remote":0,
          "num":1,
          "device_type":"CRYPTO"
          "acc_capability":{
             "num":2
             "ipsec":{
                 "aes":{
                   "3des":50,
                   "num":1,
                 }
             }
          }
        }
    }

If the accelerator does not exist a `404 Not Found` must be
returned.

'POST /accelerators/{uuid}'
*******************

Create a new accelerator

Example POST Request::

    Content-type: application/json

    {
        "name": "IPSec Card",
        "uuid": "8e45a2ea-5364-4b0d-a252-bf8becaa606e"
    }

The body of the request must match the following JSONSchema document::

    {
        "type": "object",
        "properties": {
            "name": {
                "type": "string"
            },
            "uuid": {
                "type": "string",
                "format": "uuid"
            }
        },
        "required": [
            "name"
        ]
        "additionalProperties": False
    }

The response body is empty. The headers include a location header
pointing to the created accelerator resource::

    201 Created
    Location: /accelerators/8e45a2ea-5364-4b0d-a252-bf8becaa606e

A `409 Conflict` response code will be returned if another accelerator
exists with the provided name.

'PUT /accelerators/{uuid}/{acc_spec}'
*************************

Update the spec for the accelerator identified by `{uuid}`.

Example::

    PUT /accelerator/8e45a2ea-5364-4b0d-a252-bf8becaa606e

    Content-type: application/json

    {
        "acc_specs":{
           "remote":0,
           "num":1,
           "device_type":"CRYPTO"
           "acc_capability":{
              "num":2
              "ipsec":{
                 "aes":{
                   "3des":50,
                   "num":1,
                 }
              }
           }
         }
    }

The returned HTTP response code will be one of the following:

* `200 OK` if the spec is successfully updated
* `404 Not Found` if the accelerator identified by `{uuid}` was
  not found
* `400 Bad Request` for bad or invalid syntax
* `409 Conflict` if another process updated the same spec.


'PUT /accelerators/{uuid}'
*************************

Attach the accelerator identified by `{uuid}`.

Example::

    PUT /accelerator/8e45a2ea-5364-4b0d-a252-bf8becaa606e

    Content-type: application/json

    {
        "name": "IPSec Card",
        "uuid": "8e45a2ea-5364-4b0d-a252-bf8becaa606e"
    }

The returned HTTP response code will be one of the following:

* `200 OK` if the accelerator is successfully attached
* `404 Not Found` if the accelerator identified by `{uuid}` was
  not found
* `400 Bad Request` for bad or invalid syntax
* `409 Conflict` if another process attach the same accelerator.


'DELETE /accelerator/{uuid}'
****************************

Detach the accelerator identified by `{uuid}`.

The body of the request and the response is empty.

The returned HTTP response code will be one of the following:

* `204 No Content` if the request was successful and the accelerator was detached.
* `404 Not Found` if the accelerator identified by `{uuid}` was
  not found.
* `409 Conflict` if there exist allocations records for any of the
  accelerator resource that would be detached as a result of detaching the accelerator.


Security impact
---------------

None

Notifications impact
--------------------

None

Other end user impact
---------------------

None

Performance Impact
------------------

None

Other deployer impact
---------------------

None

Developer impact
----------------

Developers can use this REST API after it has been implemented.

Implementation
==============

Assignee(s)
-----------

Primary assignee:
  zhipengh <huangzhipeng@huawei.com>

Work Items
----------

* Implement the APIs specified in this spec
* Proposal to Nova about the new accelerator
attach/detach api
* Implement the DB specified in this spec


Dependencies
============

None.

Testing
=======

* Unit tests will be added to Cyborg API.

Documentation Impact
====================

None

References
==========

None

History
=======


.. list-table:: Revisions
   :header-rows: 1

   * - Release
     - Description
   * - Pike
     - Introduced