vm

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2023 License: MPL-2.0 Imports: 24 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 ConstructNetworksConnectionWithoutVM added in v0.3.0

func ConstructNetworksConnectionWithoutVM(vApp vapp.VAPP, networks []NetworkConnection) (networkConnection govcdtypes.NetworkConnectionSection, err error)

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 GetAllOsTypes

func GetAllOsTypes() []string

getAllOsTypes returns all osTypes name.

func GetAllOsTypesWithDescription added in v0.3.0

func GetAllOsTypesWithDescription() []fstringvalidator.OneOfWithDescriptionValues

func GetBusTypeByCode

func GetBusTypeByCode(code string) busType

func GetBusTypeByKey

func GetBusTypeByKey(key string) busType

func GetVMOLD added in v0.3.0

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

GetVM returns a VM by name.

func GuestPropertiesSchema

func GuestPropertiesSchema() schema.Attribute

func GuestPropertiesSuperSchema added in v0.3.0

func GuestPropertiesSuperSchema() superschema.Attribute

func InternalDiskAttrType

func InternalDiskAttrType() map[string]attr.Type

InternalDiskAttrType returns the type map for the internal disk.

func InternalDiskSchema

func InternalDiskSchema() map[string]schema.Attribute

func InternalDiskSchemaComputed

func InternalDiskSchemaComputed() map[string]schema.Attribute

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 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 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 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 GetVMOpts added in v0.3.0

type GetVMOpts struct {
	ID   types.String
	Name types.String
}

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 NetworkConnection added in v0.3.0

type NetworkConnection struct {
	Name             types.String
	Connected        types.Bool
	IPAllocationMode types.String
	IP               types.String
	Type             types.String
	Mac              types.String
	AdapterType      types.String
	IsPrimary        types.Bool
}

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.

type VM added in v0.3.0

type VM struct {
	*client.VM
	// contains filtered or unexported fields
}

func ConstructObject added in v0.3.0

func ConstructObject(vApp vapp.VAPP, vm *govcd.VM) VM

ConstructObject is a special function that is used to construct the VM object from the govcd.VM.

func Get added in v0.3.0

func Get(vApp vapp.VAPP, vmInfo GetVMOpts) (vm VM, d diag.Diagnostics)

func Init added in v0.3.0

func Init(_ *client.CloudAvenue, vApp vapp.VAPP, vmInfo GetVMOpts) (vm VM, d diag.Diagnostics)

Init

Initializes a VM struct with a VM and a vApp.

func (VM) AttachDiskSettings added in v0.3.0

func (v VM) AttachDiskSettings(busNumber, unitNumber types.Int64, diskHREF string) *govcdtypes.DiskAttachOrDetachParams

AttachDiskSettings represents the settings for attaching a disk to a VM.

func (VM) ConstructNetworksConnection added in v0.3.0

func (v VM) ConstructNetworksConnection(networks []NetworkConnection) (networkConnection govcdtypes.NetworkConnectionSection, err error)

ConstructNetworksConnection constructs a NetworkConnectionSection from a list of NetworkConnection.

func (*VM) CustomizationRead added in v0.4.0

func (v *VM) CustomizationRead(ctx context.Context) (*VMResourceModelSettingsCustomization, error)

CustomizationRead reads the customization fields from a VM.

func (VM) GetCPUCoresCount added in v0.3.0

func (v VM) GetCPUCoresCount() int64

GetCPUCoresCount returns the number of CPU cores of the VM.

func (VM) GetCPUCount added in v0.3.0

func (v VM) GetCPUCount() int64

GetCPUCount returns the number of CPUs of the VM.

func (VM) GetDescription added in v0.3.0

func (v VM) GetDescription() string

GetDescription returns the description of the VM.

func (VM) GetDiskSettings added in v0.3.0

func (v VM) GetDiskSettings() []*govcdtypes.DiskSettings

GetDiskSettings returns the disk settings of the VM.

func (VM) GetID added in v0.3.0

func (v VM) GetID() string

GetID returns the ID of the VM.

func (VM) GetName added in v0.3.0

func (v VM) GetName() string

GetName returns the name of the VM.

func (VM) GetVirtualHardwareSection added in v0.9.0

func (v VM) GetVirtualHardwareSection() *govcdtypes.VirtualHardwareSection

GetVirtualHardwareSection returns the virtual hardware section of the VM.

func (VM) GetVirtualHardwareSectionItems added in v0.9.0

func (v VM) GetVirtualHardwareSectionItems() []*govcdtypes.VirtualHardwareItem

GetVirtualHardwareSectionItems returns the virtual hardware section items of the VM.

func (VM) GuestPropertiesRead added in v0.3.0

func (v VM) GuestPropertiesRead() (guestProperties *VMResourceModelSettingsGuestProperties, err error)

GuestPropertiesRead reads the guest properties from a VM.

func (VM) IsCPUHotAddEnabled added in v0.3.0

func (v VM) IsCPUHotAddEnabled() bool

IsCPUHotAddEnabled returns true if CPU hot add is enabled.

func (VM) IsPoweredON added in v0.3.0

func (v VM) IsPoweredON() bool

IsPoweredOn returns true if the VM is powered on.

func (VM) LockVM added in v0.3.0

func (v VM) LockVM(ctx context.Context) (d diag.Diagnostics)

LockVM locks VM.

func (VM) NetworksRead added in v0.3.0

func (v VM) NetworksRead() (*VMResourceModelResourceNetworks, error)

NetworksRead returns network configuration for saving into statefile.

func (VM) ResourceRead added in v0.3.0

func (v VM) ResourceRead(_ context.Context) (resource *VMResourceModelResource)

ResourceRead is the read function for the resource.

func (VM) SettingsRead added in v0.3.0

func (v VM) SettingsRead(ctx context.Context, stateCustomization any) (settings *VMResourceModelSettings, err error)

SettingsRead returns the value of the Settings attribute, if set, as a *VMResourceModelSettings.

func (VM) StateRead added in v0.3.0

func (v VM) StateRead(ctx context.Context) (*VMResourceModelState, error)

StateRead returns the value of the State attribute, if set, as a *VMResourceModelState.

func (VM) UnlockVM added in v0.3.0

func (v VM) UnlockVM(ctx context.Context) (d diag.Diagnostics)

UnlockVM unlocks VM.

type VMResourceModel added in v0.3.0

type VMResourceModel struct {
	ID          types.String `tfsdk:"id"`
	VDC         types.String `tfsdk:"vdc"`
	Name        types.String `tfsdk:"name"`
	VappName    types.String `tfsdk:"vapp_name"`
	VappID      types.String `tfsdk:"vapp_id"`
	Description types.String `tfsdk:"description"`
	DeployOS    types.Object `tfsdk:"deploy_os"`
	State       types.Object `tfsdk:"state"`
	Resource    types.Object `tfsdk:"resource"`
	Settings    types.Object `tfsdk:"settings"`
}

func (*VMResourceModel) AllStructsFromPlan added in v0.3.0

func (rm *VMResourceModel) AllStructsFromPlan(ctx context.Context) (allStructs *VMResourceModelAllStructs, diags diag.Diagnostics)

AllStructsFromPlan returns the values of all the attributes of the VMResourceModel, if set, as a *VMResourceModelAllStructs.

func (*VMResourceModel) DeployOSFromPlan added in v0.3.0

func (rm *VMResourceModel) DeployOSFromPlan(ctx context.Context) (deployOS *VMResourceModelDeployOS, diags diag.Diagnostics)

* DeployOS DeployOSFromPlan returns the value of the DeployOS attribute, if set, as a VMResourceModelDeployOS.

func (*VMResourceModel) ResourceFromPlan added in v0.3.0

func (rm *VMResourceModel) ResourceFromPlan(ctx context.Context) (resource *VMResourceModelResource, diags diag.Diagnostics)

* Resource ResourceFromPlan returns the value of the Resource attribute, if set, as a VMResourceModelResource.

func (*VMResourceModel) SettingsFromPlan added in v0.3.0

func (rm *VMResourceModel) SettingsFromPlan(ctx context.Context) (settings *VMResourceModelSettings, diags diag.Diagnostics)

* Settings SettingsFromPlan returns the value of the Settings attribute, if set, as a VMResourceModelSettings.

func (*VMResourceModel) StateFromPlan added in v0.3.0

func (rm *VMResourceModel) StateFromPlan(ctx context.Context) (state *VMResourceModelState, diags diag.Diagnostics)

* State StateFromPlan returns the value of the State attribute, if set, as a VMResourceModelState.

type VMResourceModelAllStructs added in v0.3.0

type VMResourceModelAllStructs struct {
	DeployOS *VMResourceModelDeployOS
	State    *VMResourceModelState
	Resource *VMResourceModelResource
	Settings *VMResourceModelSettings
}

type VMResourceModelDeployOS added in v0.3.0

type VMResourceModelDeployOS struct {
	VappTemplateID   types.String `tfsdk:"vapp_template_id"`
	VMNameInTemplate types.String `tfsdk:"vm_name_in_template"`
	BootImageID      types.String `tfsdk:"boot_image_id"`
	AcceptAllEulas   types.Bool   `tfsdk:"accept_all_eulas"`
}

func (*VMResourceModelDeployOS) AttrTypes added in v0.3.0

func (do *VMResourceModelDeployOS) AttrTypes() map[string]attr.Type

attrTypes() returns the types of the attributes of the DeployOS attribute.

func (*VMResourceModelDeployOS) ToPlan added in v0.3.0

ToPlan returns the value of the DeployOS attribute, if set, as a types.Object.

type VMResourceModelResource added in v0.3.0

type VMResourceModelResource struct {
	CPUs                types.Int64 `tfsdk:"cpus"`
	CPUsCores           types.Int64 `tfsdk:"cpus_cores"`
	CPUHotAddEnabled    types.Bool  `tfsdk:"cpu_hot_add_enabled"`
	Memory              types.Int64 `tfsdk:"memory"`
	MemoryHotAddEnabled types.Bool  `tfsdk:"memory_hot_add_enabled"`
	Networks            types.List  `tfsdk:"networks"`
}

func (*VMResourceModelResource) AttrTypes added in v0.3.0

func (r *VMResourceModelResource) AttrTypes() map[string]attr.Type

AttrTypes returns the types of the attributes of the Resource attribute.

func (*VMResourceModelResource) Equal added in v0.3.0

Equal returns true if the values of the attributes of the Resource attribute are equal.

func (*VMResourceModelResource) NetworksFromPlan added in v0.3.0

func (r *VMResourceModelResource) NetworksFromPlan(ctx context.Context) (networks *VMResourceModelResourceNetworks, diags diag.Diagnostics)

* Networks NetworksFromPlan returns the value of the Networks attribute, if set, as a VMResourceModelResourceNetworks.

func (*VMResourceModelResource) ToPlan added in v0.3.0

ToPlan returns the value of the Resource attribute, if set, as a types.Object.

type VMResourceModelResourceNetwork added in v0.3.0

type VMResourceModelResourceNetwork 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 (*VMResourceModelResourceNetwork) ConvertToNetworkConnection added in v0.3.0

func (n *VMResourceModelResourceNetwork) ConvertToNetworkConnection() NetworkConnection

ConvertToNetworkConnection converts a VMResourceModelResourceNetworks to a NetworkConnection.

func (*VMResourceModelResourceNetwork) Equal added in v0.3.0

Equal returns true if the two VMResourceModelResourceNetwork are equal.

type VMResourceModelResourceNetworks added in v0.3.0

type VMResourceModelResourceNetworks []VMResourceModelResourceNetwork //nolint:revive

func (*VMResourceModelResourceNetworks) AttrTypes added in v0.3.0

func (n *VMResourceModelResourceNetworks) AttrTypes() map[string]attr.Type

attrTypes() returns the types of the attributes of the Networks attribute.

func (*VMResourceModelResourceNetworks) ObjectType added in v0.3.0

ObjectType() returns the type of the Networks attribute.

func (*VMResourceModelResourceNetworks) ToPlan added in v0.3.0

ToPlan returns the value of the Networks attribute, if set, as a types.Object.

type VMResourceModelSettings added in v0.3.0

type VMResourceModelSettings struct {
	ExposeHardwareVirtualization types.Bool   `tfsdk:"expose_hardware_virtualization"`
	OsType                       types.String `tfsdk:"os_type"`
	StorageProfile               types.String `tfsdk:"storage_profile"`
	GuestProperties              types.Map    `tfsdk:"guest_properties"`
	AffinityRuleID               types.String `tfsdk:"affinity_rule_id"`
	Customization                types.Object `tfsdk:"customization"`
}

func (*VMResourceModelSettings) AttrTypes added in v0.3.0

func (s *VMResourceModelSettings) AttrTypes() map[string]attr.Type

AttrTypes returns the types of the attributes of the Settings attribute.

func (*VMResourceModelSettings) CustomizationFromPlan added in v0.3.0

func (s *VMResourceModelSettings) CustomizationFromPlan(ctx context.Context) (customization *VMResourceModelSettingsCustomization, diags diag.Diagnostics)

* SettingsCustomization CustomizationFromPlan returns the value of the SettingsCustomization attribute, if set, as a VMResourceModelSettingsCustomization.

func (*VMResourceModelSettings) Equal added in v0.3.0

Equal returns true if the two VMResourceModelSettings are equal.

func (*VMResourceModelSettings) GuestPropertiesFromPlan added in v0.3.0

func (s *VMResourceModelSettings) GuestPropertiesFromPlan(ctx context.Context, x types.Map) (guestProperties *VMResourceModelSettingsGuestProperties, diags diag.Diagnostics)

* SettingsGuestProperties GuestPropertiesFromPlan returns the value of the SettingsGuestProperties attribute, if set, as a VMResourceModelSettingsGuestProperties.

func (*VMResourceModelSettings) ToPlan added in v0.3.0

ToPlan returns the value of the Settings attribute, if set, as a types.Object.

type VMResourceModelSettingsCustomization added in v0.3.0

type VMResourceModelSettingsCustomization struct {
	Force                          types.Bool   `tfsdk:"force"`
	Enabled                        types.Bool   `tfsdk:"enabled"`
	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"`
	Hostname                       types.String `tfsdk:"hostname"`
}

func (*VMResourceModelSettingsCustomization) AttrTypes added in v0.3.0

attrTypes() returns the types of the attributes of the SettingsCustomization attribute.

func (*VMResourceModelSettingsCustomization) GetCustomizationSection added in v0.3.0

GetCustomizationSection returns the value of the SettingsCustomization attribute, if set, as a *types.CustomizationSection.

func (*VMResourceModelSettingsCustomization) ToPlan added in v0.3.0

ToPlan returns the value of the SettingsCustomization attribute, if set, as a types.Object.

type VMResourceModelSettingsGuestProperties added in v0.3.0

type VMResourceModelSettingsGuestProperties map[string]string //nolint:revive

func (*VMResourceModelSettingsGuestProperties) AttrType added in v0.3.0

GuestPropertiesAttrType returns the type map for the guest properties.

func (*VMResourceModelSettingsGuestProperties) ToPlan added in v0.3.0

ToPlan converts a GuestProperties to a plan.

type VMResourceModelState added in v0.3.0

type VMResourceModelState struct {
	PowerON types.Bool   `tfsdk:"power_on"`
	Status  types.String `tfsdk:"status"`
}

func (*VMResourceModelState) ToPlan added in v0.3.0

ToPlan returns the value of the State attribute, if set, as a types.Object.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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