Merge "Fix failures in v1 accelerator API. Updated documentation"
This commit is contained in:
commit
89f1869950
|
@ -13,6 +13,7 @@
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
|
|
||||||
|
from oslo_log import log
|
||||||
import pecan
|
import pecan
|
||||||
from six.moves import http_client
|
from six.moves import http_client
|
||||||
import wsme
|
import wsme
|
||||||
|
@ -28,6 +29,8 @@ from cyborg.common import exception
|
||||||
from cyborg.common import policy
|
from cyborg.common import policy
|
||||||
from cyborg import objects
|
from cyborg import objects
|
||||||
|
|
||||||
|
LOG = log.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class Accelerator(base.APIBase):
|
class Accelerator(base.APIBase):
|
||||||
"""API representation of a accelerator.
|
"""API representation of a accelerator.
|
||||||
|
@ -80,19 +83,10 @@ class Accelerator(base.APIBase):
|
||||||
# white_list named _wsme_attributes. See wsme.types.list_attributes.
|
# white_list named _wsme_attributes. See wsme.types.list_attributes.
|
||||||
# Attribute which is not in the list will be ignored.
|
# Attribute which is not in the list will be ignored.
|
||||||
# We have no disscussion about it, so just left it here now.
|
# We have no disscussion about it, so just left it here now.
|
||||||
for field in objects.Accelerator.fields:
|
|
||||||
self.fields.append(field)
|
|
||||||
setattr(self, field, kwargs.get(field, wtypes.Unset))
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def convert_with_links(cls, obj_acc):
|
def convert_with_links(cls, obj_acc):
|
||||||
api_acc = cls(**obj_acc.as_dict())
|
api_acc = cls()
|
||||||
url = pecan.request.public_url
|
|
||||||
api_acc.links = [
|
|
||||||
link.Link.make_link('self', url, 'accelerators', api_acc.uuid),
|
|
||||||
link.Link.make_link('bookmark', url, 'accelerators', api_acc.uuid,
|
|
||||||
bookmark=True)
|
|
||||||
]
|
|
||||||
return api_acc
|
return api_acc
|
||||||
|
|
||||||
|
|
||||||
|
@ -105,8 +99,6 @@ class AcceleratorCollection(base.APIBase):
|
||||||
@classmethod
|
@classmethod
|
||||||
def convert_with_links(cls, obj_accs):
|
def convert_with_links(cls, obj_accs):
|
||||||
collection = cls()
|
collection = cls()
|
||||||
collection.accelerators = [Accelerator.convert_with_links(obj_acc)
|
|
||||||
for obj_acc in obj_accs]
|
|
||||||
return collection
|
return collection
|
||||||
|
|
||||||
|
|
||||||
|
@ -127,7 +119,6 @@ class AcceleratorsControllerBase(base.CyborgController):
|
||||||
_resource = None
|
_resource = None
|
||||||
|
|
||||||
def _get_resource(self, uuid):
|
def _get_resource(self, uuid):
|
||||||
self._resource = objects.Accelerator.get(pecan.request.context, uuid)
|
|
||||||
return self._resource
|
return self._resource
|
||||||
|
|
||||||
|
|
||||||
|
@ -144,12 +135,8 @@ class AcceleratorsController(AcceleratorsControllerBase):
|
||||||
|
|
||||||
:param acc: an accelerator within the request body.
|
:param acc: an accelerator within the request body.
|
||||||
"""
|
"""
|
||||||
context = pecan.request.context
|
new_acc = None
|
||||||
obj_acc = objects.Accelerator(context, **acc)
|
LOG.warning("v1 APIs for accelerator objects are deprecated.")
|
||||||
new_acc = pecan.request.conductor_api.accelerator_create(context,
|
|
||||||
obj_acc)
|
|
||||||
# Set the HTTP Location Header
|
|
||||||
pecan.response.location = link.build_url('accelerators', new_acc.uuid)
|
|
||||||
return Accelerator.convert_with_links(new_acc)
|
return Accelerator.convert_with_links(new_acc)
|
||||||
|
|
||||||
@policy.authorize_wsgi("cyborg:accelerator", "get")
|
@policy.authorize_wsgi("cyborg:accelerator", "get")
|
||||||
|
@ -159,7 +146,8 @@ class AcceleratorsController(AcceleratorsControllerBase):
|
||||||
|
|
||||||
:param uuid: UUID of an accelerator.
|
:param uuid: UUID of an accelerator.
|
||||||
"""
|
"""
|
||||||
obj_acc = self._resource or self._get_resource(uuid)
|
obj_acc = None
|
||||||
|
LOG.warning("v1 APIs for accelerator objects are deprecated.")
|
||||||
return Accelerator.convert_with_links(obj_acc)
|
return Accelerator.convert_with_links(obj_acc)
|
||||||
|
|
||||||
@expose.expose(AcceleratorCollection, int, types.uuid, wtypes.text,
|
@expose.expose(AcceleratorCollection, int, types.uuid, wtypes.text,
|
||||||
|
@ -185,17 +173,8 @@ class AcceleratorsController(AcceleratorsControllerBase):
|
||||||
the accelerators associated with the calling
|
the accelerators associated with the calling
|
||||||
tenant are included in the response.
|
tenant are included in the response.
|
||||||
"""
|
"""
|
||||||
context = pecan.request.context
|
LOG.warning("v1 APIs for accelerator objects are deprecated.")
|
||||||
project_only = True
|
obj_accs = AcceleratorCollection()
|
||||||
if context.is_admin and all_tenants:
|
|
||||||
project_only = False
|
|
||||||
|
|
||||||
marker_obj = None
|
|
||||||
if marker:
|
|
||||||
marker_obj = objects.Accelerator.get(context, marker)
|
|
||||||
|
|
||||||
obj_accs = objects.Accelerator.list(context, limit, marker_obj,
|
|
||||||
sort_key, sort_dir, project_only)
|
|
||||||
return AcceleratorCollection.convert_with_links(obj_accs)
|
return AcceleratorCollection.convert_with_links(obj_accs)
|
||||||
|
|
||||||
@policy.authorize_wsgi("cyborg:accelerator", "update")
|
@policy.authorize_wsgi("cyborg:accelerator", "update")
|
||||||
|
@ -206,36 +185,15 @@ class AcceleratorsController(AcceleratorsControllerBase):
|
||||||
:param uuid: UUID of an accelerator.
|
:param uuid: UUID of an accelerator.
|
||||||
:param patch: a json PATCH document to apply to this accelerator.
|
:param patch: a json PATCH document to apply to this accelerator.
|
||||||
"""
|
"""
|
||||||
obj_acc = self._resource or self._get_resource(uuid)
|
LOG.warning("v1 APIs for accelerator objects are deprecated.")
|
||||||
try:
|
return None
|
||||||
api_acc = Accelerator(
|
|
||||||
**api_utils.apply_jsonpatch(obj_acc.as_dict(), patch))
|
|
||||||
except api_utils.JSONPATCH_EXCEPTIONS as e:
|
|
||||||
raise exception.PatchError(patch=patch, reason=e)
|
|
||||||
|
|
||||||
# Update only the fields that have changed
|
|
||||||
for field in objects.Accelerator.fields:
|
|
||||||
try:
|
|
||||||
patch_val = getattr(api_acc, field)
|
|
||||||
except AttributeError:
|
|
||||||
# Ignore fields that aren't exposed in the API
|
|
||||||
continue
|
|
||||||
if patch_val == wtypes.Unset:
|
|
||||||
patch_val = None
|
|
||||||
if obj_acc[field] != patch_val:
|
|
||||||
obj_acc[field] = patch_val
|
|
||||||
|
|
||||||
context = pecan.request.context
|
|
||||||
new_acc = pecan.request.conductor_api.accelerator_update(context,
|
|
||||||
obj_acc)
|
|
||||||
return Accelerator.convert_with_links(new_acc)
|
|
||||||
|
|
||||||
@policy.authorize_wsgi("cyborg:accelerator", "delete")
|
@policy.authorize_wsgi("cyborg:accelerator", "delete")
|
||||||
@expose.expose(None, types.uuid, status_code=http_client.NO_CONTENT)
|
@expose.expose(Accelerator, types.uuid, status_code=http_client.NO_CONTENT)
|
||||||
def delete(self, uuid):
|
def delete(self, uuid):
|
||||||
"""Delete an accelerator.
|
"""Delete an accelerator.
|
||||||
:param uuid: UUID of an accelerator.
|
:param uuid: UUID of an accelerator.
|
||||||
"""
|
"""
|
||||||
|
LOG.warning("v1 APIs for accelerator objects are deprecated.")
|
||||||
context = pecan.request.context
|
context = pecan.request.context
|
||||||
obj_acc = self._resource or self._get_resource(uuid)
|
obj_acc = self._resource or self._get_resource(uuid)
|
||||||
pecan.request.conductor_api.accelerator_delete(context, obj_acc)
|
|
||||||
|
|
|
@ -5,30 +5,30 @@ General Information
|
||||||
===================
|
===================
|
||||||
|
|
||||||
This document describes the basic REST API operation that Cyborg supports
|
This document describes the basic REST API operation that Cyborg supports
|
||||||
for Rocky release::
|
for Stein release::
|
||||||
|
|
||||||
+--------+-----------------------------------------+-----------------------------------------------------------+
|
+--------+-----------------------------------------+-----------------------------------------------------------------------+
|
||||||
| Verb | URI | Description |
|
| Verb | URI | Description |
|
||||||
+========+=========================================+===========================================================+
|
+========+=========================================+=======================================================================+
|
||||||
| GET | /accelerators | Return a list of accelerators |
|
| GET | /accelerators | Return a list of accelerators (Deprecated) |
|
||||||
+--------+-----------------------------------------+-----------------------------------------------------------+
|
+--------+-----------------------------------------+-----------------------------------------------------------------------+
|
||||||
| GET | /accelerators/{uuid} | Retrieve a certain accelerator info identified by `{uuid}`|
|
| GET | /accelerators/{uuid} | Retrieve a certain accelerator info identified by `{uuid}` (Deprecated)|
|
||||||
+--------+-----------------------------------------+-----------------------------------------------------------+
|
+--------+-----------------------------------------+-----------------------------------------------------------------------+
|
||||||
| POST | /accelerators | Create a new accelerator |
|
| POST | /accelerators | Create a new accelerator (Deprecated) |
|
||||||
+--------+-----------------------------------------+-----------------------------------------------------------+
|
+--------+-----------------------------------------+-----------------------------------------------------------------------+
|
||||||
| PUT | /accelerators/{uuid} | Update the spec for the accelerator identified by `{uuid}`|
|
| PUT | /accelerators/{uuid} | Update the spec for the accelerator identified by `{uuid}` (Deprecated)|
|
||||||
+--------+-----------------------------------------+-----------------------------------------------------------+
|
+--------+-----------------------------------------+-----------------------------------------------------------------------+
|
||||||
| DELETE | /accelerators/{uuid} | Delete the accelerator identified by `{uuid}` |
|
| DELETE | /accelerators/{uuid} | Delete the accelerator identified by `{uuid}` (Deprecated) |
|
||||||
+--------+-----------------------------------------+-----------------------------------------------------------+
|
+--------+-----------------------------------------+-----------------------------------------------------------------------+
|
||||||
| GET | /accelerators/deployables/ | Return a list of deployables |
|
| GET | /accelerators/deployables/ | Return a list of deployables |
|
||||||
+--------+-----------------------------------------+-----------------------------------------------------------+
|
+--------+-----------------------------------------+-----------------------------------------------------------------------+
|
||||||
| GET | /accelerators/deployables/{uuid} | Retrieve a certain deployable info identified by `{uuid}` |
|
| GET | /accelerators/deployables/{uuid} | Retrieve a certain deployable info identified by `{uuid}` |
|
||||||
+--------+-----------------------------------------+-----------------------------------------------------------+
|
+--------+-----------------------------------------+-----------------------------------------------------------------------+
|
||||||
| POST | /accelerators/deployables/ | Create a new deployable |
|
| POST | /accelerators/deployables/ | Create a new deployable |
|
||||||
+--------+-----------------------------------------+-----------------------------------------------------------+
|
+--------+-----------------------------------------+-----------------------------------------------------------------------+
|
||||||
| PATCH | /accelerators/deployables/{uuid}/program| Program a new deployable(FPGA) |
|
| PATCH | /accelerators/deployables/{uuid}/program| Program a new deployable(FPGA) |
|
||||||
+--------+-----------------------------------------+-----------------------------------------------------------+
|
+--------+-----------------------------------------+-----------------------------------------------------------------------+
|
||||||
| PATCH | /accelerators/deployables/{uuid} | Update the spec for the deployable identified by `{uuid}` |
|
| PATCH | /accelerators/deployables/{uuid} | Update the spec for the deployable identified by `{uuid}` |
|
||||||
+--------+-----------------------------------------+-----------------------------------------------------------+
|
+--------+-----------------------------------------+-----------------------------------------------------------------------+
|
||||||
| DELETE | /accelerators/deployables/{uuid} | Delete the deployable identified by `{uuid}` |
|
| DELETE | /accelerators/deployables/{uuid} | Delete the deployable identified by `{uuid}` |
|
||||||
+--------+-----------------------------------------+-----------------------------------------------------------+
|
+--------+-----------------------------------------+-----------------------------------------------------------------------+
|
||||||
|
|
Loading…
Reference in New Issue