Documentation ¶
Overview ¶
Package vm contains the common code for the VM resource and the VM datasource.
Index ¶
- func CustomizationAttrType() map[string]attr.Type
- func CustomizationSchema() map[string]schema.Attribute
- func DiskAttach(ctx context.Context, vdc vdc.VDC, disk *Disk, vm *govcd.VM) diag.Diagnostics
- func DiskAttrType() map[string]attr.Type
- func DiskDelete(ctx context.Context, client *client.CloudAvenue, disk *Disk, org org.Org, ...) diag.Diagnostics
- func DiskDetach(ctx context.Context, vdc vdc.VDC, disk *Disk, vm *govcd.VM) diag.Diagnostics
- func DiskSchema() map[string]schema.Attribute
- func GetAllOsTypes() []string
- func GetBusTypeByCode(code string) busType
- func GetBusTypeByKey(key string) busType
- func GetVM(vdc *govcd.Vdc, vappNameOrID, vmNameOrID string) (*govcd.VM, error)
- func GuestPropertiesAttrType() map[string]attr.Type
- func GuestPropertiesSchema() schema.Attribute
- func InternalDiskAttrType() map[string]attr.Type
- func InternalDiskDelete(ctx context.Context, disk *InternalDisk, vm *govcd.VM) (d diag.Diagnostics)
- func InternalDiskSchema() map[string]schema.Attribute
- func InternalDiskSchemaComputed() map[string]schema.Attribute
- func NetworkAttrType() map[string]attr.Type
- func NetworkSchema() map[string]schema.Attribute
- func PowerOffIfNeeded(vm *govcd.VM, busType string, allowVMReboot bool) (string, error)
- func PowerOnIfNeeded(vm *govcd.VM, busType string, allowVMReboot bool, vmStatusBefore string) error
- func ResourceAttrType() map[string]attr.Type
- func ResourceSchema() map[string]schema.Attribute
- func TemplateDiskAttrType() map[string]attr.Type
- func TemplateDiskSchema() map[string]schema.Attribute
- type Customization
- type Disk
- func DiskCreate(ctx context.Context, org org.Org, vdc vdc.VDC, vm *govcd.VM, disk *Disk, ...) (*Disk, diag.Diagnostics)
- func DiskRead(ctx context.Context, client *client.CloudAvenue, org org.Org, vdc vdc.VDC, ...) (*Disk, diag.Diagnostics)
- func DiskUpdate(ctx context.Context, client *client.CloudAvenue, diskPlan, diskState *Disk, ...) (*Disk, diag.Diagnostics)
- func DisksFromPlan(ctx context.Context, x types.Set) (*Disk, diag.Diagnostics)
- type Disks
- type GuestProperties
- type InternalDisk
- func InternalDiskCreate(ctx context.Context, c *client.CloudAvenue, disk InternalDisk, ...) (newDisk *InternalDisk, d diag.Diagnostics)
- func InternalDiskRead(ctx context.Context, client *client.CloudAvenue, disk *InternalDisk, ...) (readDisk *InternalDisk, d diag.Diagnostics)
- func InternalDiskUpdate(ctx context.Context, c *client.CloudAvenue, disk InternalDisk, ...) (updatedDisk *InternalDisk, d diag.Diagnostics)
- type InternalDisks
- type Network
- type Networks
- type Resource
- type TemplateDiskModel
- type TemplatesDiskModel
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CustomizationAttrType ¶
CustomizationAttrType.
func CustomizationSchema ¶
CustomizationSchema returns the schema for the customization block.
func DiskAttrType ¶
DiskAttrType
returns the attr.Type map for the disk
attr.Type is a map[string]attr.Type
- "id" (types.StringType)
- "vapp_name" (types.StringType)
- "vapp_id" (types.StringType)
- "vm_name" (types.StringType)
- "vm_id" (types.StringType)
- "vdc" (types.StringType)
- "name" (types.StringType)
- "size_in_mb" (types.Int64Type)
- "storage_profile" (types.StringType)
- "bus_type" (types.StringType)
- "bus_number" (types.Int64Type)
- "unit_number" (types.Int64Type)
func DiskDelete ¶
func DiskDelete(ctx context.Context, client *client.CloudAvenue, disk *Disk, org org.Org, vdc vdc.VDC, inVapp vapp.VAPP) diag.Diagnostics
DiskDelete
delete a disk
if the disk is attached to a VM, it will return an error.
func DiskSchema ¶
DiskSchema returns the schema for the OLDdisk.
func GetBusTypeByCode ¶
func GetBusTypeByCode(code string) busType
func GetBusTypeByKey ¶
func GetBusTypeByKey(key string) busType
func GuestPropertiesAttrType ¶
GuestPropertiesAttrType returns the type map for the guest properties.
func GuestPropertiesSchema ¶
func InternalDiskAttrType ¶
InternalDiskAttrType returns the type map for the internal disk.
func InternalDiskDelete ¶
func InternalDiskDelete(ctx context.Context, disk *InternalDisk, vm *govcd.VM) (d diag.Diagnostics)
InternalDiskDelete
Deletes an internal disk associated with a VM.
func InternalDiskSchema ¶
func NetworkAttrType ¶
NetworkAttrType is the type of the network attribute.
func NetworkSchema ¶
NetworkSchema returns the schema for the network.
func PowerOffIfNeeded ¶
PowerOffIfNeeded powers off a VM if it was powered off before and the bus type is IDE.
func PowerOnIfNeeded ¶
PowerOnIfNeeded powers on a VM if it was powered on before and the bus type is IDE.
func ResourceAttrType ¶
func ResourceSchema ¶
ResourceSchema returns the schema for the resource.
func TemplateDiskAttrType ¶
TemplateDiskAttrType returns the type map for the template disk.
func TemplateDiskSchema ¶
TemplateDiskSchema returns the schema for the template disk.
Types ¶
type Customization ¶
type Customization struct { Enabled types.Bool `tfsdk:"enabled"` Force types.Bool `tfsdk:"force"` ChangeSid types.Bool `tfsdk:"change_sid"` AllowLocalAdminPassword types.Bool `tfsdk:"allow_local_admin_password"` MustChangePasswordOnFirstLogin types.Bool `tfsdk:"must_change_password_on_first_login"` AdminPassword types.String `tfsdk:"admin_password"` AutoGeneratePassword types.Bool `tfsdk:"auto_generate_password"` NumberOfAutoLogons types.Int64 `tfsdk:"number_of_auto_logons"` JoinDomain types.Bool `tfsdk:"join_domain"` JoinOrgDomain types.Bool `tfsdk:"join_org_domain"` JoinDomainName types.String `tfsdk:"join_domain_name"` JoinDomainUser types.String `tfsdk:"join_domain_user"` JoinDomainPassword types.String `tfsdk:"join_domain_password"` JoinDomainAccountOU types.String `tfsdk:"join_domain_account_ou"` InitScript types.String `tfsdk:"init_script"` }
func CustomizationFromPlan ¶
func CustomizationFromPlan(ctx context.Context, x types.Object) (*Customization, diag.Diagnostics)
CustomizationFromPlan converts the terraform plan to a Customization struct.
func CustomizationRead ¶
func CustomizationRead(vm *govcd.VM) (c Customization, err error)
CustomizationRead reads the customization block from the API response.
func (*Customization) ToAttrValue ¶
func (c *Customization) ToAttrValue() map[string]attr.Value
ToAttrValue converts the Customization struct to a map of attr.Value.
func (*Customization) ToPlan ¶
func (c *Customization) ToPlan() basetypes.ObjectValue
ToPlan converts the Customization struct to a terraform plan.
type Disk ¶
type Disk struct { ID types.String `tfsdk:"id"` VAppName types.String `tfsdk:"vapp_name"` VAppID types.String `tfsdk:"vapp_id"` VMName types.String `tfsdk:"vm_name"` VMID types.String `tfsdk:"vm_id"` VDC types.String `tfsdk:"vdc"` Name types.String `tfsdk:"name"` SizeInMb types.Int64 `tfsdk:"size_in_mb"` StorageProfile types.String `tfsdk:"storage_profile"` IsDetachable types.Bool `tfsdk:"is_detachable"` BusType types.String `tfsdk:"bus_type"` BusNumber types.Int64 `tfsdk:"bus_number"` UnitNumber types.Int64 `tfsdk:"unit_number"` }
Disk is independent disk attached to a VM. This disk is always detached disk type.
func DiskCreate ¶
func DiskCreate(ctx context.Context, org org.Org, vdc vdc.VDC, vm *govcd.VM, disk *Disk, inVapp vapp.VAPP) (*Disk, diag.Diagnostics)
DiskCreate
creates a detachable disk.
func DiskRead ¶
func DiskRead(ctx context.Context, client *client.CloudAvenue, org org.Org, vdc vdc.VDC, disk *Disk, inVapp vapp.VAPP) (*Disk, diag.Diagnostics)
DiskRead
reads a detachable disk If the disk is not found, returns nil
if disk and diag.Diagnostics are nil the disk is not found and the resource should be removed from state.
func DiskUpdate ¶
func DiskUpdate(ctx context.Context, client *client.CloudAvenue, diskPlan, diskState *Disk, org org.Org, vdc vdc.VDC, inVapp vapp.VAPP) (*Disk, diag.Diagnostics)
DiskUpdate
updates a detachable disk
List of attributes require attach/detach disk to be updated if the disk is detachable and attached to a VM:
- size_in_mb
- storage_profile
func DisksFromPlan ¶
DisksFromPlan converts the terraform plan to a OLDDisk struct.
func (*Disk) ToAttrValue ¶
ToAttrValue
converts the Disk struct to a terraform plan
attr.Value is a map[string]attr.Value
- "id"
- "vdc"
- "vapp_name"
- "vapp_id"
- "vm_name"
- "vm_id"
- "name"
- "size_in_mb"
- "storage_profile"
- "is_detachable"
- "bus_type"
- "bus_number"
- "unit_number"
type GuestProperties ¶
func GuestPropertiesFromPlan ¶
func GuestPropertiesFromPlan(ctx context.Context, x types.Map) (*GuestProperties, diag.Diagnostics)
GuestPropertiesFromPlan converts a terraform plan to a GuestProperties struct.
func GuestPropertiesRead ¶
func GuestPropertiesRead(vm *govcd.VM) (m *GuestProperties, err error)
GuestPropertiesRead reads the guest properties from a VM.
func (*GuestProperties) ToAttrValue ¶
func (g *GuestProperties) ToAttrValue() map[string]attr.Value
ToAttrValue converts a GuestProperties to an attr.Value.
func (*GuestProperties) ToPlan ¶
func (g *GuestProperties) ToPlan() basetypes.MapValue
ToPlan converts a GuestProperties to a plan.
type InternalDisk ¶
type InternalDisk struct { ID types.String `tfsdk:"id"` BusType types.String `tfsdk:"bus_type"` BusNumber types.Int64 `tfsdk:"bus_number"` SizeInMb types.Int64 `tfsdk:"size_in_mb"` UnitNumber types.Int64 `tfsdk:"unit_number"` StorageProfile types.String `tfsdk:"storage_profile"` }
func InternalDiskCreate ¶
func InternalDiskCreate(ctx context.Context, c *client.CloudAvenue, disk InternalDisk, vAppName, vmName, vdcName types.String) (newDisk *InternalDisk, d diag.Diagnostics)
InternalDiskCreate
Creates a new internal disk associated with a VM.
func InternalDiskRead ¶
func InternalDiskRead(ctx context.Context, client *client.CloudAvenue, disk *InternalDisk, vm *govcd.VM) (readDisk *InternalDisk, d diag.Diagnostics)
InternalDiskRead
Reads an internal disk associated with a VM.
func InternalDiskUpdate ¶
func InternalDiskUpdate(ctx context.Context, c *client.CloudAvenue, disk InternalDisk, vAppName, vmName, vdcName types.String) (updatedDisk *InternalDisk, d diag.Diagnostics)
InternalDiskUpdate
Updates an internal disk associated with a VM.
type InternalDisks ¶
type InternalDisks []InternalDisk
func InternalDiskFromPlan ¶
func InternalDiskFromPlan(ctx context.Context, x types.Set) (*InternalDisks, diag.Diagnostics)
InternalDiskFromPlan creates a InternalDisks from a plan.
func (*InternalDisks) ToPlan ¶
func (i *InternalDisks) ToPlan(ctx context.Context) (basetypes.SetValue, diag.Diagnostics)
ToPlan converts a InternalDisks struct to a terraform plan.
type Network ¶
type Network struct { Type types.String `tfsdk:"type"` IPAllocationMode types.String `tfsdk:"ip_allocation_mode"` Name types.String `tfsdk:"name"` IP types.String `tfsdk:"ip"` IsPrimary types.Bool `tfsdk:"is_primary"` Mac types.String `tfsdk:"mac"` AdapterType types.String `tfsdk:"adapter_type"` Connected types.Bool `tfsdk:"connected"` }
func (*Network) ObjectType ¶
func (n *Network) ObjectType() types.ObjectType
ObjectType returns the type of the network object.
type Networks ¶
type Networks []Network
func NetworksFromPlan ¶
NetworksFromPlan converts a plan to a Networks struct.
func NetworksRead ¶
NetworksRead returns network configuration for saving into statefile.
func (*Networks) ObjectType ¶
func (n *Networks) ObjectType() types.ObjectType
ObjectType returns the type of the networks object.
type Resource ¶
type Resource struct { // CPU CPUs types.Int64 `tfsdk:"cpus"` CPUCores types.Int64 `tfsdk:"cpu_cores"` CPUHotAddEnabled types.Bool `tfsdk:"cpu_hot_add_enabled"` // Memory Memory types.Int64 `tfsdk:"memory"` MemoryHotAddEnabled types.Bool `tfsdk:"memory_hot_add_enabled"` }
func ResourceFromPlan ¶
ResourceFromPlan converts a plan to a resource struct.
func ResourceRead ¶
ResourceRead is the read function for the resource.
func (*Resource) ObjectType ¶
func (r *Resource) ObjectType() types.ObjectType
ObjectType returns the type of the resource object.
func (*Resource) ToAttrValue ¶
ToAttrValue converts the Customization struct to a map of attr.Value.
func (*Resource) ToPlan ¶
func (r *Resource) ToPlan() basetypes.ObjectValue
ToPlan converts the resource struct to a plan.
type TemplateDiskModel ¶
type TemplateDiskModel struct { BusType types.String `tfsdk:"bus_type"` BusNumber types.Int64 `tfsdk:"bus_number"` SizeInMb types.Int64 `tfsdk:"size_in_mb"` StorageProfile types.String `tfsdk:"storage_profile"` UnitNumber types.Int64 `tfsdk:"unit_number"` }
func (*TemplateDiskModel) ToAttrValue ¶
func (m *TemplateDiskModel) ToAttrValue() map[string]attr.Value
ToAttrValue converts the model to an attr.Value.
type TemplatesDiskModel ¶
type TemplatesDiskModel []TemplateDiskModel
func TemplatesDiskFromPlan ¶
func TemplatesDiskFromPlan(ctx context.Context, x types.Set) (*TemplatesDiskModel, diag.Diagnostics)
ResourceFromPlan converts a terraform plan to a TemplatesDiskModel struct.
func (*TemplatesDiskModel) ObjectType ¶
func (m *TemplatesDiskModel) ObjectType() attr.Type
ObjectType returns the type of the resource object.
func (*TemplatesDiskModel) ToPlan ¶
func (m *TemplatesDiskModel) ToPlan(ctx context.Context) (basetypes.SetValue, diag.Diagnostics)
ToPlan converts the resource struct to a plan.