vm_state

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package vm_state implements the hyperv_vm_state data source -- read-only power-state plus IP-address lookup for an existing VM by name. Useful for HCL conditionals and downstream resources that gate on the live VM state without needing to manage the VM itself.

Pairs with hyperv_vm.state.{desired, current, shutdown_mode}: the resource manages the transition; this data source reports it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New() datasource.DataSource

New is the framework factory.

Types

type DataSource

type DataSource struct {
	// contains filtered or unexported fields
}

DataSource implements data.hyperv_vm_state.

func (*DataSource) Configure

Configure stashes the typed Hyper-V client built by the provider's Configure pass. Skips when ProviderData is nil (validate-time invocation before the provider has resolved its config).

func (*DataSource) Metadata

Metadata sets the data source's TF type name.

func (*DataSource) Read

Read fetches the VM via Get-VM and writes the typed state-only shape into state. ErrNotFound surfaces as an attribute-anchored diagnostic so the operator sees which `name` value didn't resolve. ErrUnavailable surfaces with transient phrasing so a vmms blip during a plan doesn't read like "the VM is gone".

func (*DataSource) Schema

Schema declares the read shape: name is the lookup key (Required); everything else is read-only Computed pulled from Get-VM.

The deliberately narrow surface (current + ip_addresses) reflects the data source's purpose: gate downstream HCL on power state. Callers who need the full VM read shape (memory, attachments, boot order) should use the hyperv_vm resource's state.

type Model

type Model struct {
	Name        types.String `tfsdk:"name"`
	ID          types.String `tfsdk:"id"`
	Current     types.String `tfsdk:"current"`
	IPAddresses types.List   `tfsdk:"ip_addresses"`
}

Model is the tfsdk-bound state struct.

Jump to

Keyboard shortcuts

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