vm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2023 License: MPL-2.0 Imports: 32 Imported by: 0

Documentation

Overview

Package vm contains the common code for the VM resource and the VM datasource.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomizationAttrType

func CustomizationAttrType() map[string]attr.Type

CustomizationAttrType.

func CustomizationSchema

func CustomizationSchema() map[string]schema.Attribute

CustomizationSchema returns the schema for the customization block.

func DiskAttach

func DiskAttach(ctx context.Context, vdc vdc.VDC, disk *Disk, vm *govcd.VM) diag.Diagnostics

DiskAttach

attach a disk to a VM.

func DiskAttrType

func DiskAttrType() map[string]attr.Type

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 DiskDetach

func DiskDetach(ctx context.Context, vdc vdc.VDC, disk *Disk, vm *govcd.VM) diag.Diagnostics

DiskDetach

detach a disk from a VM.

func DiskSchema

func DiskSchema() map[string]schema.Attribute

DiskSchema returns the schema for the OLDdisk.

func GetAllOsTypes

func GetAllOsTypes() []string

getAllOsTypes returns all osTypes name.

func GetBusTypeByCode

func GetBusTypeByCode(code string) busType

func GetBusTypeByKey

func GetBusTypeByKey(key string) busType

func GetVM

func GetVM(vdc *govcd.Vdc, vappNameOrID, vmNameOrID string) (*govcd.VM, error)

GetVM returns a VM by name.

func GuestPropertiesAttrType

func GuestPropertiesAttrType() map[string]attr.Type

GuestPropertiesAttrType returns the type map for the guest properties.

func GuestPropertiesSchema

func GuestPropertiesSchema() schema.Attribute

func InternalDiskAttrType

func InternalDiskAttrType() map[string]attr.Type

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 InternalDiskSchema() map[string]schema.Attribute

func InternalDiskSchemaComputed

func InternalDiskSchemaComputed() map[string]schema.Attribute

func NetworkAttrType

func NetworkAttrType() map[string]attr.Type

NetworkAttrType is the type of the network attribute.

func NetworkSchema

func NetworkSchema() map[string]schema.Attribute

NetworkSchema returns the schema for the network.

func PowerOffIfNeeded

func PowerOffIfNeeded(vm *govcd.VM, busType string, allowVMReboot bool) (string, error)

PowerOffIfNeeded powers off a VM if it was powered off before and the bus type is IDE.

func PowerOnIfNeeded

func PowerOnIfNeeded(vm *govcd.VM, busType string, allowVMReboot bool, vmStatusBefore string) error

PowerOnIfNeeded powers on a VM if it was powered on before and the bus type is IDE.

func ResourceAttrType

func ResourceAttrType() map[string]attr.Type

func ResourceSchema

func ResourceSchema() map[string]schema.Attribute

ResourceSchema returns the schema for the resource.

func TemplateDiskAttrType

func TemplateDiskAttrType() map[string]attr.Type

TemplateDiskAttrType returns the type map for the template disk.

func TemplateDiskSchema

func TemplateDiskSchema() map[string]schema.Attribute

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

func DisksFromPlan(ctx context.Context, x types.Set) (*Disk, diag.Diagnostics)

DisksFromPlan converts the terraform plan to a OLDDisk struct.

func (*Disk) ElementType

func (d *Disk) ElementType() attr.Type

ElementType

return the attr.Type for the disk.

func (*Disk) ToAttrValue

func (d *Disk) ToAttrValue() map[string]attr.Value

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 Disks

type Disks []Disk

Disks is a list of Disk.

func (*Disks) ElementType

func (d *Disks) ElementType() attr.Type

func (*Disks) ToPlan

ToPlan converts the disk struct to a terraform plan.

type GuestProperties

type GuestProperties map[string]string

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

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

func NetworksFromPlan(x basetypes.ListValue) (networks *Networks, err error)

NetworksFromPlan converts a plan to a Networks struct.

func NetworksRead

func NetworksRead(vm *govcd.VM) (*Networks, error)

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.

func (*Networks) ToPlan

func (n *Networks) ToPlan() (basetypes.ListValue, diag.Diagnostics)

ToPlan converts a Network to a plan.

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

func ResourceFromPlan(ctx context.Context, x types.Object) (*Resource, diag.Diagnostics)

ResourceFromPlan converts a plan to a resource struct.

func ResourceRead

func ResourceRead(vm *govcd.VM) (Resource, error)

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

func (r *Resource) ToAttrValue() map[string]attr.Value

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

ToPlan converts the resource struct to a plan.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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