proxmox

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertNoNonSchemaValues

func AssertNoNonSchemaValues(
	devices pxapi.QemuDevices,
	schemaDef *schema.Schema,
) error

func BIOSValidator

func BIOSValidator() schema.SchemaValidateDiagFunc

func BoolPointer

func BoolPointer(b bool) *bool

func BuildSmbiosArgs

func BuildSmbiosArgs(smbiosList []interface{}) string

func ByteCountIEC

func ByteCountIEC(b int64) string

func ConfigureLogger

func ConfigureLogger(enableOutput bool, logPath string, inputLogLevels map[string]string)

Configure the debug logger for this provider. The goal here is to enable selective amounts of output for targetted debugging without overwhelming with data from sources the user/developer doesn't care about.

logLevels can be specifed as follows:

map[string]string

keys can be:
 * '_root' - to affect the root logger
 * '_capturelog' - (with any level set) to tell us to capture all message through the native log library
 * '_default' - sets the default log level (if this is not set, the default is INFO)
 (any other string) - the level to set that SubLogger to

Eventually we'll have a list of all subloggers that can be displayed/generated but for now, unfortuantely,
the code is the manual on that. I'll do my best to keep this doc string updated.

Known Subloggers:
 * resource_vm_create - logs from the create function
 * resource_vm_read  - logs from the read function

values can be one of "panic", "fatal", "error", "warn", "info", "debug", "trace".
these will be mapped out to the zerolog levels.  See the levelStringToZerologLevel function.

logs will be written out to the logPath specified. An existing file at that path will be appended to. note that there are some information (like our redirection of the built-in log library) which will not follow the zerolog pattern and thus could mess with parsing. This is annoying but something to fix in a future verison.

func CreateSubLogger

func CreateSubLogger(loggerName string) (zerolog.Logger, error)

Create a sublogger from the rootLogger This is helpful as it allows for custom logging level for each component/part of the system.

The loggerName string is used to set the name of the logger in message outputs (as a key-val pair) but also as a way to know what we should set the logging level for this sublogger to (info/trace/warn/etc)

func DevicesListToDevices

func DevicesListToDevices(devicesList []interface{}, key string) pxapi.QemuDevices

func DevicesSetToMap

func DevicesSetToMap(devicesSet *schema.Set) (pxapi.QemuDevices, error)

Converting from schema.TypeSet to map of id and conf for each device, which will be sent to Proxmox API.

func DevicesSetToMapWithoutId

func DevicesSetToMapWithoutId(devicesSet *schema.Set) pxapi.QemuDevices

func DropElementsFromMap

func DropElementsFromMap(elements []string, mapList []map[string]interface{}) ([]map[string]interface{}, error)

Drops an element from each map in a []map[string]interface{} this allows a quick and easy way to remove things like "id" that is added by the proxmox api go library when we instead encode that id as the list index (and thus terraform would reject it in a d.Set(..) call WARNING mutates the list fed in! make a copy if you need to keep the original

func ExpandDevicesList

func ExpandDevicesList(deviceList []interface{}) (pxapi.QemuDevices, error)

Consumes a terraform TypeList of a Qemu Device (network, hard drive, etc) and returns the "Expanded" version of the equivalent configuration that the API understands (the struct pxapi.QemuDevices). NOTE this expects the provided deviceList to be []map[string]interface{}.

func FlattenDevicesList

func FlattenDevicesList(proxmoxDevices pxapi.QemuDevices) ([]map[string]interface{}, error)

Consumes an API return (pxapi.QemuDevices) and "flattens" it into a []map[string]interface{} as expected by the terraform interface for TypeList

func MacAddressValidator

func MacAddressValidator() schema.SchemaValidateDiagFunc

func MachineTypeValidator

func MachineTypeValidator() schema.SchemaValidateDiagFunc

func Provider

func Provider() *schema.Provider

Provider - Terrafrom properties for proxmox

func ReadSmbiosArgs

func ReadSmbiosArgs(smbios string) []interface{}

func UpdateDeviceConfDefaults

func UpdateDeviceConfDefaults(
	activeDeviceConf pxapi.QemuDevice,
	defaultDeviceConf *schema.Set,
) *schema.Set

func UpdateDevicesSet

func UpdateDevicesSet(
	devicesSet *schema.Set,
	devicesMap pxapi.QemuDevices,
	idKey string,
) *schema.Set

Update schema.TypeSet with new values comes from Proxmox API. TODO: remove these set functions and convert attributes using a set to a list instead.

func VMIDValidator

func VMIDValidator() schema.SchemaValidateDiagFunc

func VMStateValidator

func VMStateValidator() schema.SchemaValidateDiagFunc

Types

type KeyedDeviceMap

type KeyedDeviceMap map[interface{}]pxapi.QemuDevice

func DeviceToMap

func DeviceToMap(device pxapi.QemuDevice, key interface{}) KeyedDeviceMap

func DevicesListToMapByKey

func DevicesListToMapByKey(devicesList []interface{}, key string) KeyedDeviceMap

Jump to

Keyboard shortcuts

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