Skip to content

Commit

Permalink
feat: add updateVM and deleteVM operations
Browse files Browse the repository at this point in the history
  • Loading branch information
dariusbakunas committed Nov 15, 2022
1 parent 7221395 commit 1d6c5a3
Show file tree
Hide file tree
Showing 14 changed files with 2,120 additions and 1,521 deletions.
6 changes: 4 additions & 2 deletions .openapi-generator/FILES
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,13 @@ docs/ShareSMB.md
docs/SharingApi.md
docs/UpdateDatasetParams.md
docs/UpdateUserParams.md
docs/UpdateVMParams.md
docs/User.md
docs/UserApi.md
docs/UserGroup.md
docs/VM.md
docs/VMDevice.md
docs/VMDeviceCreate.md
docs/VMDevicesInner.md
docs/VMStatus.md
docs/VmApi.md
git_push.sh
Expand Down Expand Up @@ -80,11 +81,12 @@ model_share_nfs.go
model_share_smb.go
model_update_dataset_params.go
model_update_user_params.go
model_update_vm_params.go
model_user.go
model_user_group.go
model_vm.go
model_vm_device.go
model_vm_device_create.go
model_vm_devices_inner.go
model_vm_status.go
response.go
test/api_cronjob_test.go
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,10 @@ Class | Method | HTTP request | Description
*UserApi* | [**ListUsers**](docs/UserApi.md#listusers) | **Get** /user |
*UserApi* | [**UpdateUser**](docs/UserApi.md#updateuser) | **Put** /user/id/{id} |
*VmApi* | [**CreateVM**](docs/VmApi.md#createvm) | **Post** /vm |
*VmApi* | [**DeleteVM**](docs/VmApi.md#deletevm) | **Delete** /vm/id/{id} |
*VmApi* | [**GetVM**](docs/VmApi.md#getvm) | **Get** /vm/id/{id} |
*VmApi* | [**ListVMS**](docs/VmApi.md#listvms) | **Get** /vm |
*VmApi* | [**UpdateVM**](docs/VmApi.md#updatevm) | **Put** /vm/id/{id} |


## Documentation For Models
Expand Down Expand Up @@ -144,11 +146,12 @@ Class | Method | HTTP request | Description
- [ShareSMB](docs/ShareSMB.md)
- [UpdateDatasetParams](docs/UpdateDatasetParams.md)
- [UpdateUserParams](docs/UpdateUserParams.md)
- [UpdateVMParams](docs/UpdateVMParams.md)
- [User](docs/User.md)
- [UserGroup](docs/UserGroup.md)
- [VM](docs/VM.md)
- [VMDevice](docs/VMDevice.md)
- [VMDeviceCreate](docs/VMDeviceCreate.md)
- [VMDevicesInner](docs/VMDevicesInner.md)
- [VMStatus](docs/VMStatus.md)


Expand Down
263 changes: 236 additions & 27 deletions api/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,26 @@ paths:
tags:
- vm
/vm/id/{id}:
delete:
description: Delete a VM.
operationId: deleteVM
parameters:
- explode: false
in: path
name: id
required: true
schema:
type: integer
style: simple
responses:
"200":
description: Operation succeeded
"401":
description: No authorization for this endpoint
security:
- bearerAuth: []
tags:
- vm
get:
description: Get VM details
operationId: getVM
Expand Down Expand Up @@ -1402,6 +1422,44 @@ paths:
- bearerAuth: []
tags:
- vm
put:
description: |-
Update all information of a specific VM.
`devices` is a list of virtualized hardware to attach to the virtual machine. If `devices` is not present,
no change is made to devices. If either the device list order or data stored by the device changes when the
attribute is passed, these actions are taken:
1) If there is no device in the `devices` list which was previously attached to the VM, that device is
removed from the virtual machine.
2) Devices are updated in the `devices` list when they contain a valid `id` attribute that corresponds to
an existing device.
3) Devices that do not have an `id` attribute are created and attached to `id` VM.
operationId: updateVM
parameters:
- explode: false
in: path
name: id
required: true
schema:
type: integer
style: simple
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/UpdateVMParams'
responses:
"200":
content:
application/json:
schema:
$ref: '#/components/schemas/VM'
description: List of VMs
"401":
description: No authorization for this endpoint
tags:
- vm
components:
responses:
NotFound:
Expand Down Expand Up @@ -1448,6 +1506,144 @@ components:
items:
$ref: '#/components/schemas/Dataset'
type: array
UpdateVMParams:
example:
machine_type: machine_type
memory: 5
devices:
- vm: 3
dtype: NIC
attributes:
key: ""
id: 7
order: 9
- vm: 3
dtype: NIC
attributes:
key: ""
id: 7
order: 9
arch_type: arch_type
shutdown_timeout: 5
description: description
threads: 1
vcpus: 0
autostart: true
uuid: uuid
ensure_display_device: true
cores: 6
hide_from_msr: false
cpu_model: cpu_model
bootloader: UEFI
name: name
cpu_mode: CUSTOM
time: LOCAL
properties:
name:
type: string
cpu_mode:
default: CUSTOM
enum:
- CUSTOM
- HOST-MODEL
- HOST-PASSTHROUGH
type: string
cpu_model:
nullable: true
type: string
description:
type: string
vcpus:
default: 1
description: |-
Maximum of 16 guest virtual CPUs are allowed. By default, every virtual CPU is configured as a
separate package. Multiple cores can be configured per CPU by specifying `cores` attributes.
`vcpus` specifies total number of CPU sockets. `cores` specifies number of cores per socket. `threads`
specifies number of threads per core.
type: integer
cores:
default: 1
description: |-
Maximum of 16 guest virtual CPUs are allowed. By default, every virtual CPU is configured as a
separate package. Multiple cores can be configured per CPU by specifying `cores` attributes.
`vcpus` specifies total number of CPU sockets. `cores` specifies number of cores per socket. `threads`
specifies number of threads per core.
type: integer
threads:
default: 1
description: |-
Maximum of 16 guest virtual CPUs are allowed. By default, every virtual CPU is configured as a
separate package. Multiple cores can be configured per CPU by specifying `cores` attributes.
`vcpus` specifies total number of CPU sockets. `cores` specifies number of cores per socket. `threads`
specifies number of threads per core.
type: integer
memory:
format: int64
type: integer
bootloader:
default: UEFI
enum:
- UEFI
- UEFI_CSM
type: string
devices:
description: |-
`devices` is a list of virtualized hardware to add to the newly created Virtual Machine.
Failure to attach a device destroys the VM and any resources allocated by the VM devices.
items:
$ref: '#/components/schemas/VMDevice'
type: array
autostart:
default: true
type: boolean
hide_from_msr:
default: false
description: |-
`hide_from_msr` is a boolean which when set will hide the KVM hypervisor from standard MSR based discovery and
is useful to enable when doing GPU passthrough.
type: boolean
ensure_display_device:
default: true
description: |-
`ensure_display_device` when set ( the default ) will ensure that the guest always has access to a video device.
For headless installations like ubuntu server this is required for the guest to operate properly. However
for cases where consumer would like to use GPU passthrough and does not want a display device added should set
this to `false`.
type: boolean
time:
default: LOCAL
enum:
- LOCAL
- UTC
title: time
type: string
shutdown_timeout:
default: 90
description: |-
`shutdown_timeout` indicates the time in seconds the system waits for the VM to cleanly shutdown. During system
shutdown, if the VM hasn't exited after a hardware shutdown signal has been sent by the system within
`shutdown_timeout` seconds, system initiates poweroff for the VM to stop it.
type: integer
arch_type:
description: |-
`arch_type` refers to architecture type and can be specified for the guest. By default the value is `null` and
system in this case will choose a reasonable default based on host.
`machine_type` refers to machine type of the guest based on the architecture type selected with `arch_type`.
By default the value is `null` and system in this case will choose a reasonable default based on `arch_type`
configuration.
nullable: true
type: string
machine_type:
description: |-
`machine_type` refers to machine type of the guest based on the architecture type selected with `arch_type`.
By default the value is `null` and system in this case will choose a reasonable default based on `arch_type`
configuration.
nullable: true
type: string
uuid:
nullable: true
type: string
type: object
CreateVMParams:
additionalProperties: false
default: {}
Expand Down Expand Up @@ -1518,6 +1714,7 @@ components:
specifies number of threads per core.
type: integer
memory:
format: int64
type: integer
bootloader:
default: UEFI
Expand Down Expand Up @@ -2858,6 +3055,38 @@ components:
- id
- username
type: object
VMDevice:
example:
vm: 3
dtype: NIC
attributes:
key: ""
id: 7
order: 9
properties:
id:
type: integer
dtype:
enum:
- NIC
- DISK
- CDROM
- PCI
- DISPLAY
- RAW
type: string
order:
type: integer
vm:
type: integer
attributes:
additionalProperties: true
properties: {}
type: object
required:
- dtype
- id
type: object
VMDeviceCreate:
example:
dtype: NIC
Expand Down Expand Up @@ -2899,13 +3128,15 @@ components:
memory: 1
devices:
- vm: 3
dtype: dtype
attributes: "{}"
dtype: NIC
attributes:
key: ""
id: 7
order: 9
- vm: 3
dtype: dtype
attributes: "{}"
dtype: NIC
attributes:
key: ""
id: 7
order: 9
shutdown_timeout: 2
Expand Down Expand Up @@ -2947,7 +3178,7 @@ components:
type: integer
devices:
items:
$ref: '#/components/schemas/VM_devices_inner'
$ref: '#/components/schemas/VMDevice'
type: array
status:
$ref: '#/components/schemas/VM_status'
Expand Down Expand Up @@ -3038,28 +3269,6 @@ components:
bsdgrp_smb:
type: bool
type: object
VM_devices_inner:
example:
vm: 3
dtype: dtype
attributes: "{}"
id: 7
order: 9
properties:
id:
type: integer
dtype:
type: string
order:
type: integer
vm:
type: integer
attributes:
type: object
required:
- dtype
- id
type: object
VM_status:
example:
domain_state: domain_state
Expand Down
Loading

0 comments on commit 1d6c5a3

Please sign in to comment.