Documentation
¶
Index ¶
- Constants
- func Base64Decode(src []byte) ([]byte, error)
- func CNSAttachmentNameForVolume(vmName, volumeName string) string
- func CNSBatchAttachmentNameForVM(vmName string) string
- func CopyStorageControllersAndDisks(dst *vimtypes.VirtualMachineConfigSpec, src vimtypes.VirtualMachineConfigSpec, ...)
- func DatastoreFileExists(ctx context.Context, vimClient *vim25.Client, name string, ...) error
- func DatastoreNameFromStorageURI(s string) string
- func Dedupe[T comparable](slice []T) []T
- func DevicesFromConfigSpec(configSpec *vimtypes.VirtualMachineConfigSpec) []vimtypes.BaseVirtualDevice
- func DiffSets[T interface{ ... }](expected, actual sets.Set[T]) (missing, extra []T)
- func EncodeGzipBase64(s string) (string, error)
- func EnsureDisksHaveControllers(configSpec *vimtypes.VirtualMachineConfigSpec, ...) error
- func EnsureMinHardwareVersionInConfigSpec(configSpec *vimtypes.VirtualMachineConfigSpec, minVersion int32)
- func FormatValue(str string) (string, error)
- func GeneratePVCName(prefix, suffix string) string
- func GetBootstrapConditionValues(extraConfig map[string]string) (bool, string, string, bool)
- func GetCnsDiskModeFromDiskMode(diskMode vmopv1.VolumeDiskMode) (cnsv1alpha1.DiskMode, error)
- func GetCnsNodeVMAttachmentsForVM(ctx context.Context, k8sClient ctrlclient.Client, vm *vmopv1.VirtualMachine) (map[string]cnsv1alpha1.CnsNodeVmAttachment, error)
- func GetCnsSharingModeFromSharingMode(sharingMode vmopv1.VolumeSharingMode) (cnsv1alpha1.SharingMode, error)
- func GetPreferredDiskFormat[T string | vimtypes.DatastoreSectorFormat](diskFormats ...T) vimtypes.DatastoreSectorFormat
- func GetSecretData(ctx context.Context, k8sClient ctrlclient.Client, ...) error
- func GetSecretResource(ctx context.Context, k8sClient ctrlclient.Client, ...) (*corev1.Secret, error)
- func GetVolumeDiskModeFromDiskMode(diskMode vimtypes.VirtualDiskMode) (vmopv1.VolumeDiskMode, error)
- func GetVolumeSharingModeFromDiskSharing(diskSharing vimtypes.VirtualDiskSharing) (vmopv1.VolumeSharingMode, error)
- func HasDeviceChangeDeviceByType[T vimtypes.BaseVirtualDevice](deviceChanges []vimtypes.BaseVirtualDeviceConfigSpec) bool
- func HasVirtualPCIPassthroughDeviceChange(devices []vimtypes.BaseVirtualDeviceConfigSpec) bool
- func IsDeviceDynamicDirectPathIO(dev vimtypes.BaseVirtualDevice) bool
- func IsDeviceNvidiaVgpu(dev vimtypes.BaseVirtualDevice) bool
- func IsEthernetCard(dev vimtypes.BaseVirtualDevice) bool
- func IsNotFoundError(err error) bool
- func IsOnlinePromoteDisksSupported(configSpec vimtypes.VirtualMachineConfigSpec) bool
- func IsValidDomainName(s string) bool
- func IsValidHostName(s string) bool
- func MarshalConfigSpecToJSON(configSpec vimtypes.VirtualMachineConfigSpec) ([]byte, error)
- func MarshalConfigSpecToXML(configSpec vimtypes.VirtualMachineConfigSpec) ([]byte, error)
- func MustFormatValue(str string) string
- func ParseIP(s string) (net.IP, *net.IPNet, error)
- func RemoveDevicesFromConfigSpec(configSpec *vimtypes.VirtualMachineConfigSpec, ...)
- func SHA1Sum17(s string) string
- func SafeConfigSpecToString(in *vimtypes.VirtualMachineConfigSpec) (s string)
- func SanitizeCNSErrorMessage(msg string) string
- func SanitizeVMClassConfigSpec(ctx context.Context, configSpec *vimtypes.VirtualMachineConfigSpec)
- func SelectDevices[T vimtypes.BaseVirtualDevice](devices []vimtypes.BaseVirtualDevice, selectorFns ...SelectDeviceFn[T]) []T
- func SelectDevicesByBackingType[B vimtypes.BaseVirtualDeviceBackingInfo](devices []vimtypes.BaseVirtualDevice) []vimtypes.BaseVirtualDevice
- func SelectDevicesByDeviceAndBackingType[T vimtypes.BaseVirtualDevice, B vimtypes.BaseVirtualDeviceBackingInfo](devices []vimtypes.BaseVirtualDevice) []T
- func SelectDevicesByType[T vimtypes.BaseVirtualDevice](devices []vimtypes.BaseVirtualDevice) []T
- func SelectDevicesByTypes(devices []vimtypes.BaseVirtualDevice, ...) []vimtypes.BaseVirtualDevice
- func SelectDynamicDirectPathIO(devices []vimtypes.BaseVirtualDevice) []*vimtypes.VirtualPCIPassthrough
- func SelectNvidiaVgpu(devices []vimtypes.BaseVirtualDevice) []*vimtypes.VirtualPCIPassthrough
- func SelectVirtualPCIPassthrough(devices []vimtypes.BaseVirtualDevice) []*vimtypes.VirtualPCIPassthrough
- func TryToDecodeBase64Gzip(data []byte) (string, error)
- func UnmarshalConfigSpecFromBase64XML(src []byte) (vimtypes.VirtualMachineConfigSpec, error)
- func UnmarshalConfigSpecFromJSON(data []byte) (vimtypes.VirtualMachineConfigSpec, error)
- func UnmarshalConfigSpecFromXML(data []byte) (vimtypes.VirtualMachineConfigSpec, error)
- func VMIName(itemID string) string
- func WithVAPIActivationID(ctx context.Context, client *rest.Client, id string) context.Context
- type Cache
- type CacheItem
- type CachePutResult
- type ControllerID
- type DevicePlacement
- type HardwareInfo
- type LockPool
- type OptionValues
- func (ov OptionValues) Additions(in ...vimtypes.BaseOptionValue) OptionValues
- func (ov OptionValues) Append(in ...vimtypes.BaseOptionValue) OptionValues
- func (ov OptionValues) Delete(key string) OptionValues
- func (ov OptionValues) Diff(in ...vimtypes.BaseOptionValue) OptionValues
- func (ov OptionValues) Get(key string) (any, bool)
- func (ov OptionValues) GetString(key string) (string, bool)
- func (ov OptionValues) Map() map[string]any
- func (ov OptionValues) Merge(in ...vimtypes.BaseOptionValue) OptionValues
- func (ov OptionValues) StringMap() map[string]string
- type SelectDeviceFn
- type Sortable
- type VirtualCdromInfo
- type VirtualDiskInfo
Constants ¶
const GuestInfoBootstrapCondition = "guestinfo.vmservice.bootstrap.condition"
GuestInfoBootstrapCondition is the ExtraConfig key at which possible info about the bootstrap status may be stored.
const (
// XsiNamespace indicates the XML schema instance namespace.
XsiNamespace = "http://www.w3.org/2001/XMLSchema-instance"
)
Variables ¶
This section is empty.
Functions ¶
func Base64Decode ¶
Base64Decode returns a byte slice decoded from a base64 byte slice.
func CNSAttachmentNameForVolume ¶ added in v1.8.6
CNSAttachmentNameForVolume returns the name of the CnsNodeVmAttachment based on the VM and Volume name. This matches the naming used in previous code but there are situations where we may get a collision between VMs and Volume names. I'm not sure if there is an absolute way to avoid that: the same situation can happen with the claimName. Ideally, we would use GenerateName, but we lack the back-linkage to match Volumes and CnsNodeVmAttachment up. The VM webhook validate that this result will be a valid k8s name.
func CNSBatchAttachmentNameForVM ¶ added in v1.10.0
CNSBatchAttachmentNameForVM returns the name of the CnsNodeVMBatchAttachment based on the VM name.
func CopyStorageControllersAndDisks ¶ added in v1.9.0
func CopyStorageControllersAndDisks( dst *vimtypes.VirtualMachineConfigSpec, src vimtypes.VirtualMachineConfigSpec, storagePolicyID string)
CopyStorageControllersAndDisks copies the storage controllers and disks from the source spec to the destination. This function does not attempt to handle any conflicts -- it is a blind copy. If the provided storagePolicyID is non-empty, it is assigned to any all the copied disks.
func DatastoreFileExists ¶ added in v1.10.0
func DatastoreFileExists( ctx context.Context, vimClient *vim25.Client, name string, datacenter *object.Datacenter) error
DatastoreFileExists returns nil if name exists in the given Datacenter. If the file can be checked and does not exist, os.ErrNotExist is returned.
func DatastoreNameFromStorageURI ¶ added in v1.9.0
DatastoreNameFromStorageURI returns the datastore name from a storage URI, ex.: [my-datastore-1] vm-name/vm-name.vmx. The previous URI would return the value "my-datastore-1". An empty string is returned if there is no match.
func Dedupe ¶ added in v1.9.0
func Dedupe[T comparable](slice []T) []T
func DevicesFromConfigSpec ¶
func DevicesFromConfigSpec( configSpec *vimtypes.VirtualMachineConfigSpec, ) []vimtypes.BaseVirtualDevice
DevicesFromConfigSpec returns a slice of devices from the ConfigSpec's DeviceChange property.
func DiffSets ¶ added in v1.10.0
func DiffSets[T interface {
comparable
Sortable[T]
}](expected, actual sets.Set[T]) (missing, extra []T)
DiffSets compares expected and actual sets and returns sorted lists of missing and extra items. The type T must be comparable and implement Sortable[T] to provide a Compare method for sorting.
func EncodeGzipBase64 ¶ added in v1.8.5
EncodeGzipBase64 compresses the input string using gzip and then encodes it using base64.
func EnsureDisksHaveControllers ¶ added in v1.9.0
func EnsureDisksHaveControllers( configSpec *vimtypes.VirtualMachineConfigSpec, existingDevices ...vimtypes.BaseVirtualDevice) error
EnsureDisksHaveControllers ensures that all disks in the provided ConfigSpec point to a controller. If no controller exists, new (in order of preference) PVSCSI, AHCI, or NVME controllers are added to the ConfigSpec as necessary for the disks.
Please note the following table for the number of controllers of each type that are supported as well as how many disks (per controller) each supports:
SATA
- controllers 4
- disks 30
SCSI
- controllers 4
- disks (non-paravirtual) 16
- disks (paravirtual, hardware version <14) 16
- disks (paravirtual, hardware version >=14) 256
NVME
- controllers 4
- disks (hardware version <20) 15
- disks (hardware version >=21) 255
IDE
- controllers 2
- disks 4
Please note, while this function supports matching IDE controllers in the ConfigSpec, this function will not create *new* IDE controllers if a new controller is required.
func EnsureMinHardwareVersionInConfigSpec ¶ added in v1.8.5
func EnsureMinHardwareVersionInConfigSpec( configSpec *vimtypes.VirtualMachineConfigSpec, minVersion int32)
EnsureMinHardwareVersionInConfigSpec ensures that the hardware version in the ConfigSpec is at least equal to the passed minimum hardware version value.
func FormatValue ¶ added in v1.9.0
func GeneratePVCName ¶ added in v1.10.0
GeneratePVCName generates a DNS-safe PVC name by concatenating a prefix, a hyphen, and the first eight characters of the xxhash of a suffix.
Please see https://xxhash.com/ for more information on xxhash.
func GetBootstrapConditionValues ¶ added in v1.8.6
GetBootstrapConditionValues returns the bootstrap condition values from a VM if the data is present.
func GetCnsDiskModeFromDiskMode ¶ added in v1.10.0
func GetCnsDiskModeFromDiskMode(diskMode vmopv1.VolumeDiskMode) (cnsv1alpha1.DiskMode, error)
GetCnsDiskModeFromDiskMode maps a volume disk mode to CNS disk mode. Returns the converted disk mode or an an error if not supported.
func GetCnsNodeVMAttachmentsForVM ¶ added in v1.10.0
func GetCnsNodeVMAttachmentsForVM( ctx context.Context, k8sClient ctrlclient.Client, vm *vmopv1.VirtualMachine, ) (map[string]cnsv1alpha1.CnsNodeVmAttachment, error)
GetCnsNodeVMAttachmentsForVM returns the existing CnsNodeVmAttachments for the specified VM by filtering attachments that match the VM's BiosUUID.
The function queries CnsNodeVmAttachment objects in the VM's namespace using the VM's BiosUUID (spec.nodeuuid field in the attachment) to find all attachments belonging to this VM. This includes both active and orphaned attachments.
Returns a map where the key is the attachment name and the value is the CnsNodeVmAttachment object.
func GetCnsSharingModeFromSharingMode ¶ added in v1.10.0
func GetCnsSharingModeFromSharingMode(sharingMode vmopv1.VolumeSharingMode) (cnsv1alpha1.SharingMode, error)
GetCnsSharingModeFromSharingMode maps a volume sharing mode to CNS sharing mode. Returns the converted sharing mode or an an error if not supported.
func GetPreferredDiskFormat ¶ added in v1.10.0
func GetPreferredDiskFormat[T string | vimtypes.DatastoreSectorFormat]( diskFormats ...T) vimtypes.DatastoreSectorFormat
GetPreferredDiskFormat gets the preferred disk format. This function returns native 512 if available, 4k if available, an empty value if no formats are provided, else the first available format is returned. Per the vSphere API, when a datastore supports both native_512 and native_4k, native_512 is the default.
func GetSecretData ¶ added in v1.8.6
func GetSecretResource ¶ added in v1.8.6
func GetVolumeDiskModeFromDiskMode ¶ added in v1.10.0
func GetVolumeDiskModeFromDiskMode(diskMode vimtypes.VirtualDiskMode) (vmopv1.VolumeDiskMode, error)
GetVolumeDiskModeFromDiskMode maps a disk mode to Volume disk mode. Returns the converted disk mode or an an error if not supported.
func GetVolumeSharingModeFromDiskSharing ¶ added in v1.10.0
func GetVolumeSharingModeFromDiskSharing(diskSharing vimtypes.VirtualDiskSharing) (vmopv1.VolumeSharingMode, error)
GetVolumeSharingModeFromDiskSharing maps a disk sharing mode to Volume sharing mode. Returns the converted sharing mode or an an error if not supported.
func HasDeviceChangeDeviceByType ¶ added in v1.8.6
func HasDeviceChangeDeviceByType[T vimtypes.BaseVirtualDevice]( deviceChanges []vimtypes.BaseVirtualDeviceConfigSpec, ) bool
HasDeviceChangeDeviceByType returns true of one of the device change's dev is that of type T.
func HasVirtualPCIPassthroughDeviceChange ¶ added in v1.8.6
func HasVirtualPCIPassthroughDeviceChange( devices []vimtypes.BaseVirtualDeviceConfigSpec, ) bool
HasVirtualPCIPassthroughDeviceChange returns true if any of the device changes are for a passthrough device.
func IsDeviceDynamicDirectPathIO ¶
func IsDeviceDynamicDirectPathIO(dev vimtypes.BaseVirtualDevice) bool
IsDeviceDynamicDirectPathIO returns true if the provided device is a dynamic direct path I/O device.
func IsDeviceNvidiaVgpu ¶ added in v1.8.3
func IsDeviceNvidiaVgpu(dev vimtypes.BaseVirtualDevice) bool
IsDeviceNvidiaVgpu returns true if the provided device is an Nvidia vGPU.
func IsEthernetCard ¶
func IsEthernetCard(dev vimtypes.BaseVirtualDevice) bool
func IsNotFoundError ¶ added in v1.8.6
func IsOnlinePromoteDisksSupported ¶ added in v1.10.0
func IsOnlinePromoteDisksSupported( configSpec vimtypes.VirtualMachineConfigSpec) bool
IsOnlinePromoteDisksSupported returns true if the provided configSpec would create a VM that supports online disk promotion.
func IsValidDomainName ¶ added in v1.9.0
IsValidDomainName returns true if the provided value adheres to the format for DNS names specified in RFC-1034, Section 3.5:
- must not exceed 255 characters in length when combined with the host name
- individual segments must be 63 characters or less.
- the top-level domain( ex. ".com"), is at least two letters with no special characters.
- underscores are not allowed.
- dashes are permitted, but not at the start or end of the value.
- long, top-level domain names (ex. ".london") are permitted.
- symbol unicode points, such as emoji, are disallowed in the top-level domain.
Please refer to the comments for the IsValidHostName function for information on why both functions were defined as part of this project instead of using existing functions from the Kubernetes API machinery project or OpenAPI's validation utility functions.
func IsValidHostName ¶ added in v1.9.0
IsValidHostName returns true if the provided value adheres to the format of an RFC-1123 DNS label, which may be:
- an IP4 address
- an IP6 address
- a string of alpha-numeric characters that:
- must not exceed 63 characters in length
- may begin with a digit
- may contain dashes except as the first or last character
- must not contain underscores
- may contain symbol-point unicode, (ex. emoji)
The IsValidHostName and IsValidDomainName functions are defined as part of this project because the similar functions from the Kubernetes API machinery and OpenAPI projects were different enough to not be compatible with the type of required validation.
The IsFullyQualifiedDomainName function from https://github.com/kubernetes/apimachinery/blob/d5c9711b77ee5a0dde0fef41c9ca86a67f5ddb4e/pkg/util/validation/validation.go#L92-L115: -- requires a minimum of two segments -- does not permit IP4 or IP6 addresses -- does not permit upper-case characters -- does not permit symbol-point unicode
The IsDNS1123Label function from https://github.com/kubernetes/apimachinery/blob/d5c9711b77ee5a0dde0fef41c9ca86a67f5ddb4e/pkg/util/validation/validation.go#L185-L202: -- does not permit IP4 or IP6 addresses -- does not permit upper-case characters -- does not permit symbol-point unicode
The IsHostName function from https://github.com/go-openapi/strfmt/blob/f065ed8a46434a6407610166cd707c170cf1e483/default.go#L92-L112: -- does not permit IP4 or IP6 addresses -- does not distinguish between a host name and an FQDN
Since none of the above, upstream functions could be re-used as-is, instead the regular expression HostnamePattern from https://github.com/go-openapi/strfmt/blob/f065ed8a46434a6407610166cd707c170cf1e483/default.go#L33-L60C21 was used as the basis for this file's hostNameFormat and fqdnFormat regular expressions. Additionally, the level of testing in network_test.go for both the IsValidHostName and IsValidDomainName functions far exceeds the testing for the aforementioned, upstream functions.
func MarshalConfigSpecToJSON ¶
func MarshalConfigSpecToJSON( configSpec vimtypes.VirtualMachineConfigSpec) ([]byte, error)
MarshalConfigSpecToJSON returns a byte slice of the provided ConfigSpec marshaled to a JSON string.
func MarshalConfigSpecToXML ¶
func MarshalConfigSpecToXML( configSpec vimtypes.VirtualMachineConfigSpec) ([]byte, error)
MarshalConfigSpecToXML returns a byte slice of the provided ConfigSpec marshalled to an XML string.
func MustFormatValue ¶ added in v1.9.0
MustFormatValue returns the passed value if it meets the standards for a Kubernetes label value. Otherwise, it returns a hash which meets the requirements. A copy of the method used by cluster-api for MachineSets.
func ParseIP ¶ added in v1.10.0
ParseIP returns the parsed IP address and optional network. Please note, this function supports parsing IP addresses with or without the network length.
func RemoveDevicesFromConfigSpec ¶
func RemoveDevicesFromConfigSpec(configSpec *vimtypes.VirtualMachineConfigSpec, fn func(vimtypes.BaseVirtualDevice) bool)
RemoveDevicesFromConfigSpec removes devices from config spec device changes based on the matcher function.
func SHA1Sum17 ¶ added in v1.10.0
SHA1Sum17 returns the first 17 characters of the base64-encoded, SHA1 sum created from the provided string.
func SafeConfigSpecToString ¶ added in v1.9.0
func SafeConfigSpecToString( in *vimtypes.VirtualMachineConfigSpec) (s string)
SafeConfigSpecToString returns the string-ified version of the provided ConfigSpec, first trying to use the special JSON encoder, then defaulting to the normal JSON encoder.
Please note, this function is not intended to replace marshaling the data to JSON using the normal workflows. This function is for when a string-ified version of the data is needed for things like logging.
func SanitizeCNSErrorMessage ¶ added in v1.10.0
SanitizeCNSErrorMessage checks if error message contains opId, if yes, Only extract the prefix before first ":" and return it. The CSI controller sometimes puts the serialized SOAP error into the CnsNodeVmAttachment/CnsNodeVMBatchAttachment error field, which contains things like OpIds and pointers that change on every failed reconcile attempt. Using this error as-is causes VM object churn, so try to avoid that here. The full error message is always available in the CnsNodeVmAttachment/CnsNodeVMBatchAttachment.
Issue tracked in CSI repo for them to sanitize the error so we could get rid of this func: https://github.com/kubernetes-sigs/vsphere-csi-driver/issues/3663.
func SanitizeVMClassConfigSpec ¶
func SanitizeVMClassConfigSpec( ctx context.Context, configSpec *vimtypes.VirtualMachineConfigSpec)
SanitizeVMClassConfigSpec clears fields in the class ConfigSpec that are not allowed or supported.
func SelectDevices ¶
func SelectDevices[T vimtypes.BaseVirtualDevice]( devices []vimtypes.BaseVirtualDevice, selectorFns ...SelectDeviceFn[T], ) []T
SelectDevices returns a slice of the devices that match at least one of the provided selector functions.
func SelectDevicesByBackingType ¶
func SelectDevicesByBackingType[B vimtypes.BaseVirtualDeviceBackingInfo]( devices []vimtypes.BaseVirtualDevice, ) []vimtypes.BaseVirtualDevice
SelectDevicesByBackingType returns a slice of the devices that have a backing of type B.
func SelectDevicesByDeviceAndBackingType ¶
func SelectDevicesByDeviceAndBackingType[ T vimtypes.BaseVirtualDevice, B vimtypes.BaseVirtualDeviceBackingInfo, ]( devices []vimtypes.BaseVirtualDevice, ) []T
SelectDevicesByDeviceAndBackingType returns a slice of the devices that are of type T with a backing of type B.
func SelectDevicesByType ¶
func SelectDevicesByType[T vimtypes.BaseVirtualDevice]( devices []vimtypes.BaseVirtualDevice, ) []T
SelectDevicesByType returns a slice of the devices that are of type T.
func SelectDevicesByTypes ¶
func SelectDevicesByTypes( devices []vimtypes.BaseVirtualDevice, deviceTypes ...vimtypes.BaseVirtualDevice, ) []vimtypes.BaseVirtualDevice
SelectDevicesByTypes returns a slice of the devices that match at least one the provided device types.
func SelectDynamicDirectPathIO ¶
func SelectDynamicDirectPathIO( devices []vimtypes.BaseVirtualDevice, ) []*vimtypes.VirtualPCIPassthrough
SelectDynamicDirectPathIO returns a slice of dynamic direct path I/O devices.
func SelectNvidiaVgpu ¶ added in v1.8.3
func SelectNvidiaVgpu( devices []vimtypes.BaseVirtualDevice, ) []*vimtypes.VirtualPCIPassthrough
SelectNvidiaVgpu return a slice of Nvidia vGPU devices.
func SelectVirtualPCIPassthrough ¶
func SelectVirtualPCIPassthrough( devices []vimtypes.BaseVirtualDevice, ) []*vimtypes.VirtualPCIPassthrough
SelectVirtualPCIPassthrough returns a slice of *VirtualPCIPassthrough devices.
func TryToDecodeBase64Gzip ¶
TryToDecodeBase64Gzip base64-decodes the provided data until the DecodeString function fails. If the result is gzipped, then it is decompressed and returned. Otherwise the decoded data is returned.
This function will also return the original data as a string if it was neither base64 encoded or gzipped.
func UnmarshalConfigSpecFromBase64XML ¶
func UnmarshalConfigSpecFromBase64XML( src []byte) (vimtypes.VirtualMachineConfigSpec, error)
UnmarshalConfigSpecFromBase64XML returns a ConfigSpec object from a byte-slice of the ConfigSpec marshaled as a base64-encoded, XML string.
func UnmarshalConfigSpecFromJSON ¶
func UnmarshalConfigSpecFromJSON( data []byte) (vimtypes.VirtualMachineConfigSpec, error)
UnmarshalConfigSpecFromJSON returns a ConfigSpec object from a byte-slice of the ConfigSpec marshaled as a JSON string.
func UnmarshalConfigSpecFromXML ¶
func UnmarshalConfigSpecFromXML( data []byte) (vimtypes.VirtualMachineConfigSpec, error)
UnmarshalConfigSpecFromXML returns a ConfigSpec object from a byte-slice of the ConfigSpec marshaled as an XML string.
func WithVAPIActivationID ¶ added in v1.9.0
WithVAPIActivationID adds the specified id to the context to be used as the VAPI REST client's activation ID -- the value assigned to the activationId field to the vim.Task the VAPI API may spawn.
Types ¶
type Cache ¶ added in v1.8.1
type Cache[T any] struct { // contains filtered or unexported fields }
Cache is a generic implementation of a cache that can be configured with a maximum number of items and can evict items after a certain amount of time.
func NewCache ¶ added in v1.8.1
NewCache initializes a new cache with the provided expiration options.
func (*Cache[T]) Close ¶ added in v1.8.1
func (c *Cache[T]) Close()
Close shuts down the cache. It is safe to call this function more than once.
func (*Cache[T]) ExpiredChan ¶ added in v1.8.1
ExpiredChan returns a channel on which the IDs of items that are expired are sent. This channel is closed when the cache is closed, but only after all, pending eviction notices are received.
func (*Cache[T]) Get ¶ added in v1.8.1
Get returns the cached item with the provided ID. The function isHit may be optionally provided to further determine whether a cached item should hit or miss.
func (*Cache[T]) Put ¶ added in v1.8.1
func (c *Cache[T]) Put(id string, t T) CachePutResult
Put stores the provided item in the cache, updating existing items.
type CacheItem ¶ added in v1.8.1
type CacheItem[T any] struct { // Item is the cached item. Item T // LastUpdated is the last time the item was updated. LastUpdated time.Time }
CacheItem wraps T so it has a LastUpdated field and can be used with Cache.
type CachePutResult ¶ added in v1.8.1
type CachePutResult uint
CachePutResult describes the result of putting an item into the cache.
const ( // CachePutResultCreate indicates the item was created in the cache. CachePutResultCreate CachePutResult = iota + 1 // CachePutResultUpdate indicates an existing, cached item was updated. CachePutResultUpdate // CachePutResultMaxItemsExceeded indicates the item was not stored because // the cache's maximum number of items would have been exceeded. CachePutResultMaxItemsExceeded )
type ControllerID ¶ added in v1.10.0
type ControllerID struct {
ControllerType vmopv1.VirtualControllerType
BusNumber int32
}
ControllerID represents a unique identifier for a virtual controller in a VM. It combines the controller type (IDE, NVME, SCSI, or SATA) with a bus number to uniquely identify a specific controller instance within the virtual machine.
func (ControllerID) Compare ¶ added in v1.10.0
func (c ControllerID) Compare(b ControllerID) int
Compare compares two ControllerID values and returns a negative number if c < b, 0 if c == b, or a positive number if c > b. It first compares by ControllerType, then by BusNumber.
func (ControllerID) String ¶ added in v1.10.0
func (c ControllerID) String() string
String returns a string representation of the ControllerID in the format "controllerType:BusNumber".
type DevicePlacement ¶ added in v1.10.0
type DevicePlacement struct {
Key string
ControllerType vmopv1.VirtualControllerType
ControllerBusNumber int32
UnitNumber int32
}
DevicePlacement represents the placement information for a virtual device attached to a controller. It combines a unique key (such as volume name or backing file name) with controller type, controller bus number, and unit number to uniquely identify the placement of a device (such as a disk or CD-ROM) on a specific controller within the virtual machine.
func (DevicePlacement) Compare ¶ added in v1.10.0
func (d DevicePlacement) Compare(b DevicePlacement) int
Compare compares two DevicePlacement values and returns a negative number if d < b, 0 if d == b, or a positive number if d > b. It first compares by Key, then by ControllerType, ControllerBusNumber, and UnitNumber.
func (DevicePlacement) String ¶ added in v1.10.0
func (d DevicePlacement) String() string
String returns a string representation of the DevicePlacement in the format "Key (controllerType:controllerBusNumber:unitNumber)".
type HardwareInfo ¶ added in v1.10.0
type HardwareInfo struct {
Controllers sets.Set[ControllerID]
Disks sets.Set[DevicePlacement]
CDROMs sets.Set[DevicePlacement]
}
HardwareInfo stores information about the actual hardware devices attached to a VM, including controllers, disks, and CD-ROMs.
func BuildHardwareInfo ¶ added in v1.10.0
func BuildHardwareInfo(moVM mo.VirtualMachine) HardwareInfo
BuildHardwareInfo extracts hardware information from the VM's managed object, including all attached controllers, disks, and CD-ROMs.
type LockPool ¶ added in v1.8.1
LockPool is a synchronized set of maps that can be obtained with a provided ID.
type OptionValues ¶ added in v1.9.0
type OptionValues []vimtypes.BaseOptionValue
OptionValues simplifies manipulation of properties that are arrays of vimtypes.BaseOptionValue, such as ExtraConfig.
func OptionValuesFromMap ¶ added in v1.9.0
func OptionValuesFromMap[T any](in map[string]T) OptionValues
OptionValuesFromMap returns a new OptionValues object from the provided map.
func (OptionValues) Additions ¶ added in v1.9.0
func (ov OptionValues) Additions(in ...vimtypes.BaseOptionValue) OptionValues
Additions returns a diff that includes only the elements from the provided list that do not already exist.
func (OptionValues) Append ¶ added in v1.9.0
func (ov OptionValues) Append(in ...vimtypes.BaseOptionValue) OptionValues
Append adds the provided item(s) as long as a key does not conflict with an existing item.
func (OptionValues) Delete ¶ added in v1.9.0
func (ov OptionValues) Delete(key string) OptionValues
Delete removes elements with the given key, returning the new list.
func (OptionValues) Diff ¶ added in v1.9.0
func (ov OptionValues) Diff(in ...vimtypes.BaseOptionValue) OptionValues
Diff returns a diff that includes the elements from the provided list that do not already exist or have different values.
func (OptionValues) Get ¶ added in v1.9.0
func (ov OptionValues) Get(key string) (any, bool)
Get returns the value if exists, otherwise nil is returned. The second return value is a flag indicating whether the value exists or nil was the actual value.
func (OptionValues) GetString ¶ added in v1.9.0
func (ov OptionValues) GetString(key string) (string, bool)
GetString returns the value as a string if the value exists.
func (OptionValues) Map ¶ added in v1.9.0
func (ov OptionValues) Map() map[string]any
Map returns the list of option values as a map.
func (OptionValues) Merge ¶ added in v1.9.0
func (ov OptionValues) Merge(in ...vimtypes.BaseOptionValue) OptionValues
Merge adds the provided item(s), overwriting any existing values.
func (OptionValues) StringMap ¶ added in v1.9.0
func (ov OptionValues) StringMap() map[string]string
StringMap returns the list of option values as a map where the values are strings.
type SelectDeviceFn ¶
type SelectDeviceFn[T vimtypes.BaseVirtualDevice] func(dev vimtypes.BaseVirtualDevice) bool
SelectDeviceFn returns true if the provided virtual device is a match.
type Sortable ¶ added in v1.10.0
Sortable is a type constraint that requires a Compare method for sorting. Types that implement Sortable[T] must have a Compare method that returns a negative number if a < b, 0 if a == b, or a positive number if a > b.
type VirtualCdromInfo ¶ added in v1.10.0
type VirtualCdromInfo struct {
DeviceName string
FileName string
ControllerKey int32
UnitNumber *int32
Device *vimtypes.VirtualCdrom
}
VirtualCdromInfo holds basic disk information extracted from a VirtualCdrom.
func GetVirtualCdromInfo ¶ added in v1.10.0
func GetVirtualCdromInfo( vc *vimtypes.VirtualCdrom) VirtualCdromInfo
GetVirtualCdromInfo extracts CD-ROM information from a VirtualCdrom.
type VirtualDiskInfo ¶ added in v1.10.0
type VirtualDiskInfo struct {
FileName string
Label string
UUID string
DeviceKey int32
CryptoKey *vimtypes.CryptoKeyId
Sharing vimtypes.VirtualDiskSharing
DiskMode vimtypes.VirtualDiskMode
HasParent bool
ControllerKey int32
UnitNumber *int32
CapacityInBytes int64
Device *vimtypes.VirtualDisk
BackingType cnstypes.CnsVolumeBackingType
}
VirtualDiskInfo holds basic disk information extracted from a VirtualDisk.
func GetVirtualDiskInfo ¶ added in v1.10.0
func GetVirtualDiskInfo( vd *vimtypes.VirtualDisk) VirtualDiskInfo
GetVirtualDiskInfo extracts disk information from a VirtualDisk.
func (VirtualDiskInfo) Name ¶ added in v1.10.0
func (vdi VirtualDiskInfo) Name() string
Name returns the name of the disk to use in the volume status as well as the UnmanagedVolumeSource.ID field.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package nil provides a utility function for determining if a value is nil.
|
Package nil provides a utility function for determining if a value is nil. |
|
vsphere
|
|