virtualmachine

package
v1.9.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 44 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BackupVirtualMachine

func BackupVirtualMachine(opts BackupVirtualMachineOptions) (result error)

BackupVirtualMachine backs up the required data of a VM into its ExtraConfig. Currently, the following data is backed up: - VM Kubernetes resource in YAMl. - Additional VM-relevant Kubernetes resources in YAML, separated by "---". - PVC disk data in JSON format (if DiskUUIDToPVC is not empty).

func CPUQuantityToMhz

func CPUQuantityToMhz(q resource.Quantity, cpuFreqMhz uint64) int64

func ConfigSpecFromVMClassDevices

func ConfigSpecFromVMClassDevices(vmClassSpec *vmopv1.VirtualMachineClassSpec) vimtypes.VirtualMachineConfigSpec

ConfigSpecFromVMClassDevices creates a ConfigSpec that adds the standalone hardware devices from the VMClass if any. This ConfigSpec will be used as the class ConfigSpec to CreateConfigSpec, with the rest of the class fields - like CPU count - applied on top.

func CreateConfigSpec

CreateConfigSpec returns an initial ConfigSpec that is created by overlaying the base ConfigSpec with VM Class spec and other arguments. TODO: We eventually need to de-dupe much of this with the ConfigSpec manipulation that's later done in the "update" pre-power on path. That operates on a ConfigInfo so we'd need to populate that from the config we build here.

func CreateConfigSpecForPlacement

func CreateConfigSpecForPlacement(
	vmCtx pkgctx.VirtualMachineContext,
	configSpec vimtypes.VirtualMachineConfigSpec,
	storageClassesToIDs map[string]string) (vimtypes.VirtualMachineConfigSpec, error)

CreateConfigSpecForPlacement creates a ConfigSpec that is suitable for Placement. configSpec will likely be - or at least derived from - the ConfigSpec returned by CreateConfigSpec above.

func CreateInstanceStorageDiskDevices

func CreateInstanceStorageDiskDevices(isVolumes []vmopv1.VirtualMachineVolume) []vimtypes.BaseVirtualDevice

func CreatePCIDevicesFromConfigSpec

func CreatePCIDevicesFromConfigSpec(pciDevsFromConfigSpec []*vimtypes.VirtualPCIPassthrough) []vimtypes.BaseVirtualDevice

CreatePCIDevicesFromConfigSpec creates vim25 VirtualDevices from the specified list of PCI devices from the VM Class ConfigSpec.

func CreatePCIDevicesFromVMClass

func CreatePCIDevicesFromVMClass(pciDevicesFromVMClass vmopv1.VirtualDevices) []vimtypes.BaseVirtualDevice

CreatePCIDevicesFromVMClass creates vim25 VirtualDevices from the specified list of PCI devices from VM Class spec.

func CreatePCIPassThroughDevice

func CreatePCIPassThroughDevice(deviceKey int32, backingInfo vimtypes.BaseVirtualDeviceBackingInfo) vimtypes.BaseVirtualDevice

func DecryptWebMKS

func DecryptWebMKS(privKey *rsa.PrivateKey, ciphertext string) (string, error)

func DeleteVirtualMachine

func DeleteVirtualMachine(
	vmCtx pkgctx.VirtualMachineContext,
	vcVM *object.VirtualMachine) error

func EncryptWebMKS

func EncryptWebMKS(pubKey string, plaintext string) (string, error)

func ErrorVMPausedByAdmin

func ErrorVMPausedByAdmin() error

func GetDefaultDiskProvisioningType

func GetDefaultDiskProvisioningType(
	vmCtx pkgctx.VirtualMachineContext,
	vcClient *vcclient.Client,
	storageProfileID string) (string, error)

GetDefaultDiskProvisioningType gets the default disk provisioning type specified for the VM.

func GetExtraConfigGuestInfo

func GetExtraConfigGuestInfo(
	ctx context.Context,
	vm *object.VirtualMachine) (map[string]string, error)

func GetVMClusterComputeResource

func GetVMClusterComputeResource(
	ctx context.Context,
	vcVM *object.VirtualMachine) (*object.ClusterComputeResource, error)

GetVMClusterComputeResource returns the VM's ClusterComputeResource.

func GetWebConsoleTicket

func GetWebConsoleTicket(
	vmCtx pkgctx.VirtualMachineContext,
	vm *object.VirtualMachine,
	pubKey string) (string, error)

func MemoryQuantityToMb

func MemoryQuantityToMb(q resource.Quantity) int64

func UpdateCdromDeviceChanges

func UpdateCdromDeviceChanges(
	vmCtx pkgctx.VirtualMachineContext,
	restClient *rest.Client,
	k8sClient ctrlclient.Client,
	curDevices object.VirtualDeviceList) ([]vimtypes.BaseVirtualDeviceConfigSpec, error)

UpdateCdromDeviceChanges reconciles the desired CD-ROM devices specified in VM.Spec.Cdrom with the current CD-ROM devices in the VM. It returns a list of device changes required to update the CD-ROM devices.

func UpdateConfigSpecCdromDeviceConnection

func UpdateConfigSpecCdromDeviceConnection(
	vmCtx pkgctx.VirtualMachineContext,
	restClient *rest.Client,
	k8sClient ctrlclient.Client,
	config *vimtypes.VirtualMachineConfigInfo,
	configSpec *vimtypes.VirtualMachineConfigSpec) error

UpdateConfigSpecCdromDeviceConnection updates the connection state of the VM's existing CD-ROM devices to match what specifies in VM.Spec.Cdrom list.

Types

type BackupVirtualMachineOptions

type BackupVirtualMachineOptions struct {
	VMCtx               pkgctx.VirtualMachineContext
	VcVM                *object.VirtualMachine
	DiskUUIDToPVC       map[string]corev1.PersistentVolumeClaim
	AdditionalResources []client.Object
	BackupVersion       string
	ClassicDiskUUIDs    map[string]struct{}
}

BackupVirtualMachineOptions contains the options for BackupVirtualMachine.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL