vmlifecycle

package
v1.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: Apache-2.0 Imports: 69 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// OvfEnvironmentTransportGuestInfo is the OVF transport type that uses
	// GuestInfo. The other valid type is "iso".
	OvfEnvironmentTransportGuestInfo = "com.vmware.guestInfo"

	// GOSCVCFAHashID is the VCFA ID key name in the GOSC customization extra config.
	GOSCVCFAHashID = "vcfaVmHashKey"
)

Variables

View Source
var (
	ErrBootstrapReconfigure = pkgerr.NoRequeueNoErr("bootstrap reconfigured vm")
	ErrBootstrapCustomize   = pkgerr.NoRequeueNoErr("bootstrap customized vm")
)
View Source
var CloudInitUserDataSecretKeys = []string{"user-data", "value"}

CloudInitUserDataSecretKeys are the Secret keys that in v1a1 we'd check for the userdata. Specifically, CAPBK uses "value" for its key, while "user-data" is the preferred key nowadays. The 'value' key lookup will eventually be deprecated.

Functions

func BootStrapCloudInitInstanceID

func BootStrapCloudInitInstanceID(
	vm *vmopv1.VirtualMachine,
	cloudInitSpec *vmopv1.VirtualMachineBootstrapCloudInitSpec) string

func CreateVirtualMachine

func CreateVirtualMachine(
	vmCtx pkgctx.VirtualMachineContext,
	k8sClient ctrlclient.Client,
	restClient *rest.Client,
	vimClient *vim25.Client,
	finder *find.Finder,
	createArgs *CreateArgs) (*vimtypes.ManagedObjectReference, error)

func GetCloudInitGuestInfoCustSpec

func GetCloudInitGuestInfoCustSpec(
	ctx context.Context,
	config *vimtypes.VirtualMachineConfigInfo,
	metadata, userdata string) (*vimtypes.VirtualMachineConfigSpec, error)

func GetCloudInitMetadata

func GetCloudInitMetadata(
	instanceID, hostName, domainName string,
	netplan *netplan.Network,
	sshPublicKeys string,
	waitOnNetwork4, waitOnNetwork6 *bool) (string, error)

func GetMergedvAppConfigSpec

func GetMergedvAppConfigSpec(
	keyVals map[string]string,
	inProps []vimtypes.VAppPropertyInfo) (vimtypes.BaseVmConfigSpec, error)

GetMergedvAppConfigSpec prepares a vApp VmConfigSpec which will set the provided key/value fields. Only fields marked userConfigurable and pre-existing on the VM (ie. originated from the OVF Image) will be set, and all others will be ignored.

func GetOVFVAppConfigForConfigSpec

func GetOVFVAppConfigForConfigSpec(
	config *vimtypes.VirtualMachineConfigInfo,
	vAppConfigSpec *vmopv1.VirtualMachineBootstrapVAppConfigSpec,
	vAppData map[string]string,
	vAppExData map[string]map[string]string,
	templateRenderFn TemplateRenderFunc) (vimtypes.BaseVmConfigSpec, error)

func IsCustomizationPendingExtraConfig

func IsCustomizationPendingExtraConfig(extraConfig []vimtypes.BaseOptionValue) bool

func MarkBootstrapCondition

func MarkBootstrapCondition(
	vm *vmopv1.VirtualMachine,
	extraConfig map[string]string)

func MarkCustomizationInfoCondition

func MarkCustomizationInfoCondition(vm *vmopv1.VirtualMachine, guestInfo *vimtypes.GuestInfo)

func MarkReconciliationCondition

func MarkReconciliationCondition(vm *vmopv1.VirtualMachine)

func MarkVMClassConfigurationSynced

func MarkVMClassConfigurationSynced(
	ctx context.Context,
	vm *vmopv1.VirtualMachine,
	k8sClient ctrlclient.Client)

func MarkVMToolsRunningStatusCondition

func MarkVMToolsRunningStatusCondition(
	vm *vmopv1.VirtualMachine,
	guestInfo *vimtypes.GuestInfo)

func ReconcileStatus added in v1.10.0

func ReconcileStatus(
	vmCtx pkgctx.VirtualMachineContext,
	k8sClient ctrlclient.Client,
	vcVM *object.VirtualMachine,
	data ReconcileStatusData) error

func SyncVMSnapshotTreeStatus added in v1.10.0

func SyncVMSnapshotTreeStatus(
	vmCtx pkgctx.VirtualMachineContext,
	k8sClient ctrlclient.Client) error

SyncVMSnapshotTreeStatus syncs whole snapshot tree by recursively updating snapshots' childrenList status and updates the VM's current and root snapshots status.

func UpdateNetworkStatusConfig

func UpdateNetworkStatusConfig(vm *vmopv1.VirtualMachine, args BootstrapArgs)

UpdateNetworkStatusConfig updates the provided VM's status.network.config field with information from the provided bootstrap arguments. This is useful for folks booting VMs without bootstrap engines who may wish to manually configure the VM's networking with the valid IP configuration for this VM.

Types

type BootstrapArgs

type BootstrapArgs struct {
	BootstrapData

	TemplateRenderFn TemplateRenderFunc
	NetworkResults   network.NetworkInterfaceResults
	DomainName       string
	HostName         string
	DNSServers       []string
	SearchSuffixes   []string
}

func GetBootstrapArgs

func GetBootstrapArgs(
	ctx pkgctx.VirtualMachineContext,
	k8sClient ctrlclient.Client,
	networkResults network.NetworkInterfaceResults,
	bootstrapData BootstrapData) (BootstrapArgs, error)

GetBootstrapArgs returns the information used to bootstrap the VM via one of the many, possible bootstrap engines.

type BootstrapData

type BootstrapData struct {
	Data       map[string]string
	VAppData   map[string]string
	VAppExData map[string]map[string]string

	CloudConfig *cloudinit.CloudConfigSecretData
	Sysprep     *sysprep.SecretData
	LinuxPrep   *linuxprep.SecretData
}

type CDROMIssues added in v1.10.0

type CDROMIssues struct {
	Missing             []pkgutil.DevicePlacement
	Unexpected          []pkgutil.DevicePlacement
	IncompletePlacement []string
	FailedResolution    []string
}

CDROMIssues stores CD-ROM device configuration issues found during verification. The missing and unexpected CD-ROM devices are sorted. The incomplete placement CD-ROMs and CD-ROM failed resolution are appended in order when looping through the spec list.

func (*CDROMIssues) HasIssues added in v1.10.0

func (c *CDROMIssues) HasIssues() bool

HasIssues returns true if there are any issues to report.

func (*CDROMIssues) Message added in v1.10.0

func (c *CDROMIssues) Message() string

Message formats all issues into a human-readable message. Each issue type is on a separate line, and items are formatted as comma-separated lists for better readability.

type CloudInitMetadata

type CloudInitMetadata struct {
	InstanceID    string          `json:"instance-id,omitempty"`
	LocalHostname string          `json:"local-hostname,omitempty"`
	Hostname      string          `json:"hostname,omitempty"`
	Network       netplan.Network `json:"network,omitempty"`
	PublicKeys    string          `json:"public-keys,omitempty"`
	WaitOnNetwork *WaitOnNetwork  `json:"wait-on-network,omitempty"`
}

type ControllerIssues added in v1.10.0

type ControllerIssues struct {
	Missing    []pkgutil.ControllerID
	Unexpected []pkgutil.ControllerID
}

ControllerIssues stores controller configuration issues found during verification. The missing and unexpected controllers are sorted.

func (*ControllerIssues) HasIssues added in v1.10.0

func (c *ControllerIssues) HasIssues() bool

HasIssues returns true if there are any issues to report.

func (*ControllerIssues) Message added in v1.10.0

func (c *ControllerIssues) Message() string

Message formats all issues into a human-readable message. Each issue type is on a separate line, and items are formatted as comma-separated lists for better readability.

type CreateArgs

type CreateArgs struct {
	UseContentLibrary bool
	ProviderItemID    string

	ConfigSpec                vimtypes.VirtualMachineConfigSpec
	StorageProvisioning       string
	DatacenterMoID            string
	FolderMoID                string
	ResourcePoolMoID          string
	HostMoID                  string
	StorageProfileID          string
	IsEncryptedStorageProfile bool
	DatastoreMoID             string // gce2e only: used only if StorageProfileID is unset
	Datastores                []DatastoreRef
	DiskPaths                 []string
	FilePaths                 []string
	ZoneName                  string
}

CreateArgs contains the arguments needed to create a VM.

type DatastoreRef

type DatastoreRef struct {
	Name                             string
	MoRef                            vimtypes.ManagedObjectReference
	URL                              string
	DiskFormats                      []string
	TopLevelDirectoryCreateSupported bool

	// ForDisk is false if the recommendation is for the VM's home directory and
	// true if for a disk. DiskKey is only valid if ForDisk is true.
	ForDisk bool
	DiskKey int32
}

type HardwareConfigIssues added in v1.10.0

type HardwareConfigIssues struct {
	ControllerIssues ControllerIssues
	VolumeIssues     VolumeIssues
	CDROMIssues      CDROMIssues
}

HardwareConfigIssues stores all hardware device configuration issues found during verification. This is kept for backward compatibility and can be used to aggregate all device-specific issues.

func (*HardwareConfigIssues) HasIssues added in v1.10.0

func (h *HardwareConfigIssues) HasIssues() bool

HasIssues returns true if there are any issues to report.

func (*HardwareConfigIssues) Message added in v1.10.0

func (h *HardwareConfigIssues) Message() string

Message formats all issues into a concise summary message. Following Kubernetes best practices, this provides a concise summary rather than duplicating all detailed messages. The message references the specific condition types where detailed information is available. Example output: "Hardware configuration issues detected. See VirtualMachineHardwareControllersVerified, VirtualMachineHardwareVolumesVerified conditions for details.".

type IssueReporter added in v1.10.0

type IssueReporter interface {
	// HasIssues returns true if there are any issues to report.
	HasIssues() bool
	// Message formats all issues into a human-readable message.
	Message() string
}

IssueReporter defines the common interface for hardware validation issues. This interface allows polymorphic handling of different issue types.

type ReconcileStatusData added in v1.10.0

type ReconcileStatusData struct {
	// NetworkDeviceKeysToSpecIdx maps the network device's DeviceKey to its
	// corresponding index in the VM's Spec.Network.Interfaces[].
	NetworkDeviceKeysToSpecIdx map[int32]int
}

type TemplateRenderFunc

type TemplateRenderFunc func(string, string) string

func GetTemplateRenderFunc

func GetTemplateRenderFunc(
	vmCtx pkgctx.VirtualMachineContext,
	bsArgs *BootstrapArgs,
) TemplateRenderFunc

type VolumeIssues added in v1.10.0

type VolumeIssues struct {
	Missing             []pkgutil.DevicePlacement
	Unexpected          []pkgutil.DevicePlacement
	IncompletePlacement []string
}

VolumeIssues stores volume configuration issues found during verification. The missing and unexpected volumes are sorted. The incomplete placement volumes are appended in order when looping through the spec list.

func (*VolumeIssues) HasIssues added in v1.10.0

func (v *VolumeIssues) HasIssues() bool

HasIssues returns true if there are any issues to report.

func (*VolumeIssues) Message added in v1.10.0

func (v *VolumeIssues) Message() string

Message formats all issues into a human-readable message. Each issue type is on a separate line, and items are formatted as comma-separated lists for better readability.

type WaitOnNetwork added in v1.10.0

type WaitOnNetwork struct {
	IPv4 bool `json:"ipv4,omitempty"`
	IPv6 bool `json:"ipv6,omitempty"`
}

Jump to

Keyboard shortcuts

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