util

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2023 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// XsiNamespace indicates the XML schema instance namespace.
	XsiNamespace = "http://www.w3.org/2001/XMLSchema-instance"
)

Variables

This section is empty.

Functions

func Base64Decode

func Base64Decode(src []byte) ([]byte, error)

Base64Decode returns a byte slice decoded from a base64 byte slice.

func DevicesFromConfigSpec

func DevicesFromConfigSpec(
	configSpec *vimTypes.VirtualMachineConfigSpec,
) []vimTypes.BaseVirtualDevice

DevicesFromConfigSpec returns a slice of devices from the ConfigSpec's DeviceChange property.

func IsDeviceDynamicDirectPathIO

func IsDeviceDynamicDirectPathIO(dev vimTypes.BaseVirtualDevice) bool

IsDeviceDynamicDirectPathIO returns true if the provided device is a dynamic direct path I/O device..

func IsDeviceVGPU

func IsDeviceVGPU(dev vimTypes.BaseVirtualDevice) bool

IsDeviceVGPU returns true if the provided device is a vGPU.

func IsEthernetCard

func IsEthernetCard(dev vimTypes.BaseVirtualDevice) bool

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

func SanitizeVMClassConfigSpec(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 SelectVGPUs

func SelectVGPUs(
	devices []vimTypes.BaseVirtualDevice,
) []*vimTypes.VirtualPCIPassthrough

SelectVGPUs returns a slice of vGPUs.

func SelectVirtualPCIPassthrough

func SelectVirtualPCIPassthrough(
	devices []vimTypes.BaseVirtualDevice,
) []*vimTypes.VirtualPCIPassthrough

SelectVirtualPCIPassthrough returns a slice of *VirtualPCIPassthrough devices.

func TryToDecodeBase64Gzip

func TryToDecodeBase64Gzip(data []byte) (string, error)

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.

Types

type SelectDeviceFn

type SelectDeviceFn[T vimTypes.BaseVirtualDevice] func(dev vimTypes.BaseVirtualDevice) bool

SelectDeviceFn returns true if the provided virtual device is a match.

Jump to

Keyboard shortcuts

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