vmlifecycle

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: 56 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"
)

Variables

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.

View Source
var (
	// VMStatusPropertiesSelector is the minimum properties needed to be
	// retrieved in order to populate the Status. Callers may provide a MO with
	// more. This often saves us a second round trip in the common steady state.
	VMStatusPropertiesSelector = []string{
		"config.changeTrackingEnabled",
		"config.extraConfig",
		"config.hardware.device",
		"config.keyId",
		"layoutEx",
		"guest",
		"resourcePool",
		"runtime",
		"summary",
	}
)

Functions

func BootStrapCloudInitInstanceID

func BootStrapCloudInitInstanceID(
	vmCtx pkgctx.VirtualMachineContext,
	cloudInitSpec *vmopv1.VirtualMachineBootstrapCloudInitSpec) string

func BytesToResourceGiB

func BytesToResourceGiB(b int64) *resource.Quantity

BytesToResourceGiB returns the resource.Quantity GiB value for the specified number of bytes.

func CreateVirtualMachine

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

func GetCloudInitGuestInfoCustSpec

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

func GetCloudInitMetadata

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

func GetMergedvAppConfigSpec

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

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,
	configInfo *vimtypes.VirtualMachineConfigInfo)

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 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.

func UpdateStatus

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

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
}

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"`
}

type CreateArgs

type CreateArgs struct {
	UseContentLibrary bool
	ProviderItemID    string

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

CreateArgs contains the arguments needed to create a VM.

type DatastoreRef

type DatastoreRef struct {
	Name                             string
	MoRef                            vimtypes.ManagedObjectReference
	URL                              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 TemplateRenderFunc

type TemplateRenderFunc func(string, string) string

func GetTemplateRenderFunc

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

Jump to

Keyboard shortcuts

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