Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: yaroslavborbat <[email protected]>
  • Loading branch information
yaroslavborbat committed Jan 17, 2025
1 parent 6391a85 commit c94b18d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions api/subresources/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ type VirtualMachineAddVolume struct {
VolumeKind string
PVCName string
Image string
AsCdrom bool
}

// +genclient
Expand Down
1 change: 1 addition & 0 deletions api/subresources/v1alpha2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ type VirtualMachineAddVolume struct {
VolumeKind string `json:"volumeKind"`
PVCName string `json:"pvcName"`
Image string `json:"image"`
AsCdrom bool `json:"asCdrom"`
}

// +genclient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,16 +103,23 @@ func (r AddVolumeREST) requestFromKubevirt(opts *subresources.VirtualMachineAddV
}

func (r AddVolumeREST) genMutateRequestHook(opts *subresources.VirtualMachineAddVolume) (mutateRequestHook, error) {
var dd virtv1.DiskDevice
if opts.AsCdrom {
dd.CDRom = &virtv1.CDRomTarget{
Bus: virtv1.DiskBusSATA,
}
} else {
dd.Disk = &virtv1.DiskTarget{
Bus: virtv1.DiskBusSCSI,
}
}

hotplugRequest := AddVolumeOptions{
Name: opts.Name,
Disk: &virtv1.Disk{
Name: opts.Name,
DiskDevice: virtv1.DiskDevice{
Disk: &virtv1.DiskTarget{
Bus: "scsi",
},
},
Serial: opts.Name,
Name: opts.Name,
DiskDevice: dd,
Serial: opts.Name,
},
}
switch opts.VolumeKind {
Expand Down

0 comments on commit c94b18d

Please sign in to comment.