|
32 | 32 | Hierarchy,
|
33 | 33 | PublishEvent,
|
34 | 34 | parse_node_obj,
|
| 35 | + KernelVersion, |
35 | 36 | )
|
36 | 37 | from .auth import Authentication
|
37 | 38 | from .db import Database
|
@@ -535,10 +536,24 @@ async def _verify_user_group_existence(user_groups: List[str]):
|
535 | 536 | detail=f"User group does not exist with name: {group_name}")
|
536 | 537 |
|
537 | 538 |
|
| 539 | +def _translate_version_fields(node: Node): |
| 540 | + """Translate Node version fields""" |
| 541 | + data = node.data |
| 542 | + if data: |
| 543 | + version = data.get('kernel_revision', {}).get('version') |
| 544 | + if version: |
| 545 | + version = KernelVersion.translate_version_fields(version) |
| 546 | + node.data['kernel_revision']['version'] = version |
| 547 | + return node |
| 548 | + |
| 549 | + |
538 | 550 | @app.post('/node', response_model=Node, response_model_by_alias=False)
|
539 | 551 | async def post_node(node: Node,
|
540 | 552 | current_user: User = Depends(get_current_user)):
|
541 | 553 | """Create a new node"""
|
| 554 | + # [TODO] Remove translation below once we can use it in the pipeline |
| 555 | + node = _translate_version_fields(node) |
| 556 | + |
542 | 557 | # Explicit pydantic model validation
|
543 | 558 | parse_node_obj(node)
|
544 | 559 |
|
@@ -576,6 +591,10 @@ async def put_node(node_id: str, node: Node,
|
576 | 591 | status_code=status.HTTP_404_NOT_FOUND,
|
577 | 592 | detail=f"Node not found with id: {node.id}"
|
578 | 593 | )
|
| 594 | + |
| 595 | + # [TODO] Remove translation below once we can use it in the pipeline |
| 596 | + node = _translate_version_fields(node) |
| 597 | + |
579 | 598 | # Sanity checks
|
580 | 599 | # Note: do not update node ownership fields, don't update 'state'
|
581 | 600 | # until we've checked the state transition is valid.
|
|
0 commit comments