Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions api/v1alpha1/proxmoxmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,15 +140,17 @@ type Storage struct {
// to change the size of the boot volume.
// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="Value is immutable"
// +optional
BootVolume *DiskSize `json:"bootVolume,omitempty"`
BootVolume *DiskSpec `json:"bootVolume,omitempty"`

// TODO Intended to add handling for additional volumes,
// which will be added to the node.
// e.g. AdditionalVolumes []DiskSize.
// AdditionalVolumes defines additional volumes to be added to the virtual machine.
// +optional
AdditionalVolumes []DiskSpec `json:"additionalVolumes,omitempty"`
}

// DiskSize is contains values for the disk device and size.
type DiskSize struct {
// DiskSpec is contains values for the disk device and size.
type DiskSpec struct {
// Disk is the name of the disk device, that should be resized.
// Example values are: ide[0-3], scsi[0-30], sata[0-5].
Disk string `json:"disk"`
Expand Down Expand Up @@ -583,7 +585,7 @@ type ProxmoxMachine struct {
Status ProxmoxMachineStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// ProxmoxMachineList contains a list of ProxmoxMachine.
type ProxmoxMachineList struct {
Expand Down Expand Up @@ -632,7 +634,7 @@ func (r *ProxmoxMachine) GetNode() string {
}

// FormatSize returns the format required for the Proxmox API.
func (d *DiskSize) FormatSize() string {
func (d *DiskSpec) FormatSize() string {
return fmt.Sprintf("%dG", d.SizeGB)
}

Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/proxmoxmachine_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ func defaultMachine() *ProxmoxMachine {
},
},
Disks: &Storage{
BootVolume: &DiskSize{
BootVolume: &DiskSpec{
Disk: "scsi0",
SizeGB: 100,
},
Expand Down
15 changes: 10 additions & 5 deletions api/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,34 @@ spec:
Disks contains a set of disk configuration options,
which will be applied before the first startup.
properties:
additionalVolumes:
description: |-
which will be added to the node.
AdditionalVolumes defines additional volumes to be added to the virtual machine.
items:
description: DiskSpec is contains values for the disk
device and size.
properties:
disk:
description: |-
Disk is the name of the disk device, that should be resized.
Example values are: ide[0-3], scsi[0-30], sata[0-5].
type: string
sizeGb:
description: |-
Size defines the size in gigabyte.

As Proxmox does not support shrinking, the size
must be bigger than the already configured size in the
template.
format: int32
minimum: 5
type: integer
required:
- disk
- sizeGb
type: object
type: array
bootVolume:
description: |-
BootVolume defines the storage size for the boot volume.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,34 @@ spec:
Disks contains a set of disk configuration options,
which will be applied before the first startup.
properties:
additionalVolumes:
description: |-
which will be added to the node.
AdditionalVolumes defines additional volumes to be added to the virtual machine.
items:
description: DiskSpec is contains values for
the disk device and size.
properties:
disk:
description: |-
Disk is the name of the disk device, that should be resized.
Example values are: ide[0-3], scsi[0-30], sata[0-5].
type: string
sizeGb:
description: |-
Size defines the size in gigabyte.

As Proxmox does not support shrinking, the size
must be bigger than the already configured size in the
template.
format: int32
minimum: 5
type: integer
required:
- disk
- sizeGb
type: object
type: array
bootVolume:
description: |-
BootVolume defines the storage size for the boot volume.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,34 @@ spec:
Disks contains a set of disk configuration options,
which will be applied before the first startup.
properties:
additionalVolumes:
description: |-
which will be added to the node.
AdditionalVolumes defines additional volumes to be added to the virtual machine.
items:
description: DiskSpec is contains values for the disk device
and size.
properties:
disk:
description: |-
Disk is the name of the disk device, that should be resized.
Example values are: ide[0-3], scsi[0-30], sata[0-5].
type: string
sizeGb:
description: |-
Size defines the size in gigabyte.

As Proxmox does not support shrinking, the size
must be bigger than the already configured size in the
template.
format: int32
minimum: 5
type: integer
required:
- disk
- sizeGb
type: object
type: array
bootVolume:
description: |-
BootVolume defines the storage size for the boot volume.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,34 @@ spec:
Disks contains a set of disk configuration options,
which will be applied before the first startup.
properties:
additionalVolumes:
description: |-
which will be added to the node.
AdditionalVolumes defines additional volumes to be added to the virtual machine.
items:
description: DiskSpec is contains values for the disk
device and size.
properties:
disk:
description: |-
Disk is the name of the disk device, that should be resized.
Example values are: ide[0-3], scsi[0-30], sata[0-5].
type: string
sizeGb:
description: |-
Size defines the size in gigabyte.

As Proxmox does not support shrinking, the size
must be bigger than the already configured size in the
template.
format: int32
minimum: 5
type: integer
required:
- disk
- sizeGb
type: object
type: array
bootVolume:
description: |-
BootVolume defines the storage size for the boot volume.
Expand Down
4 changes: 2 additions & 2 deletions internal/service/vmservice/vm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,7 @@ func TestReconcileVirtualMachineConfigTags(t *testing.T) {
func TestReconcileDisks_RunningVM(t *testing.T) {
machineScope, _, _ := setupReconcilerTest(t)
machineScope.ProxmoxMachine.Spec.Disks = &infrav1alpha1.Storage{
BootVolume: &infrav1alpha1.DiskSize{Disk: "ide0", SizeGB: 100},
BootVolume: &infrav1alpha1.DiskSpec{Disk: "ide0", SizeGB: 100},
}
machineScope.SetVirtualMachine(newRunningVM())

Expand All @@ -506,7 +506,7 @@ func TestReconcileDisks_RunningVM(t *testing.T) {
func TestReconcileDisks_ResizeDisk(t *testing.T) {
machineScope, proxmoxClient, _ := setupReconcilerTest(t)
machineScope.ProxmoxMachine.Spec.Disks = &infrav1alpha1.Storage{
BootVolume: &infrav1alpha1.DiskSize{Disk: "ide0", SizeGB: 100},
BootVolume: &infrav1alpha1.DiskSpec{Disk: "ide0", SizeGB: 100},
}
vm := newStoppedVM()
machineScope.SetVirtualMachine(vm)
Expand Down
2 changes: 1 addition & 1 deletion internal/webhook/proxmoxmachine_webhook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func validProxmoxMachine(name string) infrav1.ProxmoxMachine {
NumCores: 1,
MemoryMiB: 1024,
Disks: &infrav1.Storage{
BootVolume: &infrav1.DiskSize{
BootVolume: &infrav1.DiskSpec{
Disk: "scsi[0]",
SizeGB: 10,
},
Expand Down
Loading