vmopv1

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: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrInvalidHostName is returned by ValidateHostAndDomainName if
	// either the provided host name does not adhere to RFC-1123.
	ErrInvalidHostName = "host name must adhere to RFC-1123"

	// ErrInvalidDomainName is returned by ValidateHostAndDomainName if
	// either the provided domain name does not adhere to RFC-1123.
	ErrInvalidDomainName = "domain name must adhere to RFC-1123"

	// ErrInvalidHostNameIPWithDomainName is returned by
	// ValidateHostAndDomainName if the provided host name is an IP4 or IP6
	// address and the provided domain name is non-empty.
	ErrInvalidHostNameIPWithDomainName = "host name may not be IP address when domain name is non-empty" //nolint:gosec

	// ErrInvalidHostNameWindows is returned by ValidateHostAndDomainName if the
	// provided host name exceeds 15 characters and the guest is Windows.
	ErrInvalidHostNameWindows = "host name may not exceed 15 characters for Windows"

	// ErrInvalidHostAndDomainName is returned by ValidateHostAndDomainName if
	// the provided host name and domain name, combined, exceed 255 characters.
	ErrInvalidHostAndDomainName = "host name and domain name combined exceed 255 characters"
)
View Source
const KubernetesNodeLabelKey = "cluster.x-k8s.io/cluster-name"

KubernetesNodeLabelKey is the name of the label key used to identify a Kubernetes cluster node.

View Source
const (
	// LastResizedAnnotationKey denotes the VM Class that the VM was last resized from.
	LastResizedAnnotationKey = vmopv1.GroupName + "/last-resized-vm-class"
)

Variables

View Source
var ErrImageNotSynced = errors.New("image not synced")

ErrImageNotSynced is returned from GetImageInfo when the underlying content library item is not synced.

Functions

func DetermineHardwareVersion

DetermineHardwareVersion returns the hardware version recommended for the provided VirtualMachine based on its own spec.minHardwareVersion, as well as the hardware in the provided ConfigSpec and requirements of the given VirtualMachineImage.

func EncryptionClassToVirtualMachineMapper

func EncryptionClassToVirtualMachineMapper(
	ctx context.Context,
	k8sClient client.Client) handler.MapFunc

EncryptionClassToVirtualMachineMapper returns a mapper function used to enqueue reconcile requests for VMs in response to an event on the EncryptionClass resource.

func FilterInstanceStorageVolumes

func FilterInstanceStorageVolumes(vm *vmopv1.VirtualMachine) []vmopv1.VirtualMachineVolume

FilterInstanceStorageVolumes returns instance storage volumes present in VM spec.

func GetContextWithWorkloadDomainIsolation

func GetContextWithWorkloadDomainIsolation(
	ctx context.Context,
	vm vmopv1.VirtualMachine) context.Context

GetContextWithWorkloadDomainIsolation gets a new context with the WorkloadDomainIsolation capability set to a value based on the provided VM.

func GetImage

func GetImage(
	ctx context.Context,
	k8sClient ctrlclient.Client,
	imgRef vmopv1.VirtualMachineImageRef,
	namespace string) (vmopv1.VirtualMachineImage, error)

GetImage returns the VirtualMachineImage or ClusterVirtualMachineImage for the provided image reference.

func GetLastResizedAnnotation

func GetLastResizedAnnotation(vm vmopv1.VirtualMachine) (string, string, int64, bool)

GetLastResizedAnnotation returns the VM Class Name, UID, Generation, and true from the last resize annotation if present. Otherwise returns false.

func GetStorageURIsForLibraryItemDisks

func GetStorageURIsForLibraryItemDisks(
	item imgregv1a1.ContentLibraryItem) ([]string, error)

GetStorageURIsForLibraryItemDisks returns the paths to the VMDK files from the provided library item.

func HasPVC

func HasPVC(vm vmopv1.VirtualMachine) bool

HasPVC returns true if any of spec.volumes contains a PVC.

func ImageRefsEqual

func ImageRefsEqual(ref1, ref2 *vmopv1.VirtualMachineImageRef) bool

ImageRefsEqual returns true if the two image refs match.

func IsClasslessVM

func IsClasslessVM(vm vmopv1.VirtualMachine) bool

IsClasslessVM returns true if the provided VM was not deployed from a VM class.

func IsImageOVF

func IsImageOVF(img vmopv1.VirtualMachineImage) error

func IsImageProviderReady

func IsImageProviderReady(img vmopv1.VirtualMachineImage) error

func IsImageReady

func IsImageReady(img vmopv1.VirtualMachineImage) error

func IsImagelessVM

func IsImagelessVM(vm vmopv1.VirtualMachine) bool

IsImagelessVM returns true if the provided VM was not deployed from a VM image.

func IsInstanceStoragePresent

func IsInstanceStoragePresent(vm *vmopv1.VirtualMachine) bool

IsInstanceStoragePresent checks if VM Spec has instance volumes added to its Volumes list.

func IsInsufficientQuota

func IsInsufficientQuota(err error) bool

func IsKubernetesNode

func IsKubernetesNode(vm vmopv1.VirtualMachine) bool

IsKubernetesNode returns true if the provided VM has the label cluster.x-k8s.io/cluster-name.

func IsLibraryItemSynced

func IsLibraryItemSynced(item imgregv1a1.ContentLibraryItem) error

func MustSetLastResizedAnnotation

func MustSetLastResizedAnnotation(
	vm *vmopv1.VirtualMachine,
	vmClass vmopv1.VirtualMachineClass)

MustSetLastResizedAnnotation sets the resize annotation to match the given class. Panic if fails.

func OverwriteAlwaysResizeConfigSpec

OverwriteAlwaysResizeConfigSpec applies any set fields in the VM Spec or changes required from the current VM state to the ConfigSpec. These are fields that change without the VM Class.

func OverwriteResizeConfigSpec

OverwriteResizeConfigSpec applies any set fields in the VM Spec or changes required from the current VM state to the ConfigSpec. These are fields that we can change without the VM Class.

func ResizeNeeded

func ResizeNeeded(
	vm vmopv1.VirtualMachine,
	vmClass vmopv1.VirtualMachineClass) bool

func ResolveImageName

func ResolveImageName(
	ctx context.Context,
	k8sClient client.Client,
	namespace, imgName string) (client.Object, error)

ResolveImageName resolves the provided name of a VM image either to a VirtualMachineImage resource or ClusterVirtualMachineImage resource.

func SetLastResizedAnnotation

func SetLastResizedAnnotation(
	vm *vmopv1.VirtualMachine,
	vmClass vmopv1.VirtualMachineClass) error

SetLastResizedAnnotation sets the resize annotation to match the given class.

func SetLastResizedAnnotationClassName

func SetLastResizedAnnotationClassName(
	vm *vmopv1.VirtualMachine,
	className string) error

SetLastResizedAnnotationClassName sets the resize annotation to just of the class name.

func SyncStorageUsageForNamespace

func SyncStorageUsageForNamespace(
	ctx context.Context,
	namespace, storageClass string)

SyncStorageUsageForNamespace updates the StoragePolicyUsage resource for the given namespace and storage class with the reported usage information for VMs in that namespace that use the specified storage class.

func ValidateHostAndDomainName

func ValidateHostAndDomainName(vm vmopv1.VirtualMachine) *field.Error

ValidateHostAndDomainName returns nil if the provided host and domain names are valid; otherwise an error is returned. If the isWindows parameter is true, then the host name may not exceed 15 characters.

Types

type ErrImageNotFound

type ErrImageNotFound struct {
	// contains filtered or unexported fields
}

ErrImageNotFound is returned from ResolveImageName if the image cannot be found at the namespace or cluster scopes. This type will return true when provided to the apierrors.IsNotFound function.

func (ErrImageNotFound) Error

func (e ErrImageNotFound) Error() string

func (ErrImageNotFound) Status

func (e ErrImageNotFound) Status() metav1.Status

type ImageDiskInfo

type ImageDiskInfo struct {
	ItemID             string
	ItemContentVersion string
	DiskURIs           []string
}

ImageDiskInfo contains information about a VM image that is used to create a VM.

func GetImageDiskInfo

func GetImageDiskInfo(
	ctx context.Context,
	k8sClient ctrlclient.Client,
	imgRef vmopv1.VirtualMachineImageRef,
	namespace string) (ImageDiskInfo, error)

GetImageDiskInfo returns the information about a VM image's disks, used to create a VM. This method returns an error for images that are not OVFs.

Jump to

Keyboard shortcuts

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