common

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2026 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const BuilderId = "vcd"

Variables

This section is empty.

Functions

func CommHost

func CommHost(configuredHost string) func(multistep.StateBag) (string, error)

CommHost returns a function that retrieves the communicator host IP from the state bag. This is used by communicator.StepConnect to know where to connect.

Types

type Artifact

type Artifact struct {
	Name      string
	Location  LocationConfig
	VM        driver.VirtualMachine
	StateData map[string]interface{}
	Outconfig *string
}

func (*Artifact) BuilderId

func (a *Artifact) BuilderId() string

func (*Artifact) Destroy

func (a *Artifact) Destroy() error

func (*Artifact) Files

func (a *Artifact) Files() []string

func (*Artifact) Id

func (a *Artifact) Id() string

func (*Artifact) State

func (a *Artifact) State(name string) interface{}

func (*Artifact) String

func (a *Artifact) String() string

type BootCommandConfig

type BootCommandConfig struct {
	bootcommand.BootConfig `mapstructure:",squash"`

	// Time in ms to wait between each key press. Defaults to 100ms.
	BootKeyInterval time.Duration `mapstructure:"boot_key_interval"`
}

BootCommandConfig contains configuration for sending boot commands to the VM.

func (*BootCommandConfig) FlatMapstructure

func (*BootCommandConfig) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatBootCommandConfig. FlatBootCommandConfig is an auto-generated flat version of BootCommandConfig. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*BootCommandConfig) Prepare

func (c *BootCommandConfig) Prepare(ctx *interpolate.Context) []error

type BootCommandFromVM

type BootCommandFromVM interface {
	GetVM() *govcd.VM
}

BootCommandFromVM provides context for acquiring console access

type CatalogConfig

type CatalogConfig struct {
	// The name of an existing catalog to use for ISO upload.
	// If not set, a temporary catalog will be created and deleted after the build.
	// Using an existing catalog enables ISO caching across builds.
	// This catalog is separate from the output catalog where the final vApp template is exported.
	ISOCatalog string `mapstructure:"iso_catalog"`

	// Prefix for temporary catalog names when creating a new catalog.
	// Only used when iso_catalog is not set.
	// Defaults to "packer-".
	TempCatalogPrefix string `mapstructure:"temp_catalog_prefix"`

	// If true and using an existing catalog (iso_catalog), check if the ISO already exists
	// before uploading. This enables reusing ISOs across multiple builds.
	// Defaults to true when iso_catalog is specified.
	CacheISO bool `mapstructure:"cache_iso"`

	// If true, overwrite existing cached ISO even if it exists in the catalog.
	// Defaults to false.
	CacheOverwrite bool `mapstructure:"cache_overwrite"`
}

CatalogConfig defines configuration for the ISO source catalog during build. This catalog is used to upload and store the ISO image used to boot the VM. For the output catalog where the final vApp template is exported, see ExportToCatalogConfig.

func (*CatalogConfig) Prepare

func (c *CatalogConfig) Prepare() []error

type ConnectConfig

type ConnectConfig struct {
	// The fully qualified domain name or IP address of the vCD Server instance.
	Host string `mapstructure:"host"`
	// The username to authenticate with the vCD Server instance.
	Org string `mapstructure:"org"`
	// The username to authenticate with the vCD Server instance.
	Username string `mapstructure:"username"`
	// The password to authenticate with the vCD Server instance.
	Password string `mapstructure:"password"`
	// The token to authenticate with the vCenter Server instance.
	Token string `mapstructure:"token"`

	// Do not validate the certificate of the vCD Server instance.
	// Defaults to `false`.
	//
	// -> **Note:** This option is beneficial in scenarios where the certificate
	// is self-signed or does not meet standard validation criteria.
	InsecureConnection bool `mapstructure:"insecure_connection"`
}

func (*ConnectConfig) Prepare

func (c *ConnectConfig) Prepare() []error

type Driver

type Driver interface {
	NewVM() (*govcd.VM, error)
}

type ExportConfig

type ExportConfig struct {
	// The name of the exported image in Open Virtualization Format (OVF).
	//
	// -> **Note:** The name of the virtual machine with the `.ovf` extension is
	// used if this option is not specified.
	Name string `mapstructure:"name"`
	// Forces the export to overwrite existing files. Defaults to `false`.
	// If set to `false`, an error is returned if the file(s) already exists.
	Force bool `mapstructure:"force"`
	// The path to the directory where the exported image will be saved.
	OutputDir OutputConfig `mapstructure:",squash"`
}

func (*ExportConfig) FlatMapstructure

func (*ExportConfig) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatExportConfig. FlatExportConfig is an auto-generated flat version of ExportConfig. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*ExportConfig) Prepare

type ExportToCatalogConfig

type ExportToCatalogConfig struct {
	// The name of the catalog to export the vApp template to.
	Catalog string `mapstructure:"catalog"`

	// The name for the vApp template in the catalog.
	// If not set, defaults to the VM name.
	TemplateName string `mapstructure:"template_name"`

	// Description for the vApp template.
	Description string `mapstructure:"description"`

	// If true, overwrite an existing template with the same name.
	// Defaults to false.
	Overwrite bool `mapstructure:"overwrite"`

	// If true, create the catalog if it doesn't exist.
	// Defaults to false.
	CreateCatalog bool `mapstructure:"create_catalog"`
}

ExportToCatalogConfig defines configuration for exporting the built VM as a vApp template. This is separate from the ISO catalog (CatalogConfig) which is used for ISO storage during build.

func (*ExportToCatalogConfig) FlatMapstructure

func (*ExportToCatalogConfig) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatExportToCatalogConfig. FlatExportToCatalogConfig is an auto-generated flat version of ExportToCatalogConfig. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*ExportToCatalogConfig) Prepare

func (c *ExportToCatalogConfig) Prepare(lc *LocationConfig) []error

type FlatBootCommandConfig

type FlatBootCommandConfig struct {
	BootGroupInterval *string  `mapstructure:"boot_keygroup_interval" cty:"boot_keygroup_interval" hcl:"boot_keygroup_interval"`
	BootWait          *string  `mapstructure:"boot_wait" cty:"boot_wait" hcl:"boot_wait"`
	BootCommand       []string `mapstructure:"boot_command" cty:"boot_command" hcl:"boot_command"`
	BootKeyInterval   *string  `mapstructure:"boot_key_interval" cty:"boot_key_interval" hcl:"boot_key_interval"`
}

FlatBootCommandConfig is an auto-generated flat version of BootCommandConfig. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatBootCommandConfig) HCL2Spec

func (*FlatBootCommandConfig) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a BootCommandConfig. This spec is used by HCL to read the fields of BootCommandConfig. The decoded values from this spec will then be applied to a FlatBootCommandConfig.

type FlatExportConfig

type FlatExportConfig struct {
	Name      *string     `mapstructure:"name" cty:"name" hcl:"name"`
	Force     *bool       `mapstructure:"force" cty:"force" hcl:"force"`
	OutputDir *string     `mapstructure:"output_directory" required:"false" cty:"output_directory" hcl:"output_directory"`
	DirPerm   os.FileMode `mapstructure:"directory_permission" required:"false" cty:"directory_permission" hcl:"directory_permission"`
}

FlatExportConfig is an auto-generated flat version of ExportConfig. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatExportConfig) HCL2Spec

func (*FlatExportConfig) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a ExportConfig. This spec is used by HCL to read the fields of ExportConfig. The decoded values from this spec will then be applied to a FlatExportConfig.

type FlatExportToCatalogConfig

type FlatExportToCatalogConfig struct {
	Catalog       *string `mapstructure:"catalog" cty:"catalog" hcl:"catalog"`
	TemplateName  *string `mapstructure:"template_name" cty:"template_name" hcl:"template_name"`
	Description   *string `mapstructure:"description" cty:"description" hcl:"description"`
	Overwrite     *bool   `mapstructure:"overwrite" cty:"overwrite" hcl:"overwrite"`
	CreateCatalog *bool   `mapstructure:"create_catalog" cty:"create_catalog" hcl:"create_catalog"`
}

FlatExportToCatalogConfig is an auto-generated flat version of ExportToCatalogConfig. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatExportToCatalogConfig) HCL2Spec

func (*FlatExportToCatalogConfig) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a ExportToCatalogConfig. This spec is used by HCL to read the fields of ExportToCatalogConfig. The decoded values from this spec will then be applied to a FlatExportToCatalogConfig.

type FlatOutputConfig

type FlatOutputConfig struct {
	OutputDir *string     `mapstructure:"output_directory" required:"false" cty:"output_directory" hcl:"output_directory"`
	DirPerm   os.FileMode `mapstructure:"directory_permission" required:"false" cty:"directory_permission" hcl:"directory_permission"`
}

FlatOutputConfig is an auto-generated flat version of OutputConfig. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatOutputConfig) HCL2Spec

func (*FlatOutputConfig) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a OutputConfig. This spec is used by HCL to read the fields of OutputConfig. The decoded values from this spec will then be applied to a FlatOutputConfig.

type FlatWaitIpConfig

type FlatWaitIpConfig struct {
	WaitTimeout   *string `mapstructure:"ip_wait_timeout" cty:"ip_wait_timeout" hcl:"ip_wait_timeout"`
	SettleTimeout *string `mapstructure:"ip_settle_timeout" cty:"ip_settle_timeout" hcl:"ip_settle_timeout"`
}

FlatWaitIpConfig is an auto-generated flat version of WaitIpConfig. Where the contents of a field with a `mapstructure:,squash` tag are bubbled up.

func (*FlatWaitIpConfig) HCL2Spec

func (*FlatWaitIpConfig) HCL2Spec() map[string]hcldec.Spec

HCL2Spec returns the hcl spec of a WaitIpConfig. This spec is used by HCL to read the fields of WaitIpConfig. The decoded values from this spec will then be applied to a FlatWaitIpConfig.

type HardwareConfig

type HardwareConfig struct {
	// The number of virtual CPUs cores for the virtual machine.
	CPUs int32 `mapstructure:"CPUs"`
	// Cores per socket for the virtual machine.
	CoresPerSocket int32 `mapstructure:"cores_per_socket"`
	// Enable CPU hot plug setting for virtual machine. Defaults to `false`
	CpuHotAddEnabled bool `mapstructure:"CPU_hot_plug"`

	// The amount of memory for the virtual machine (MB)
	Memory int64 `mapstructure:"memory"`
	// Enable memory hot add setting for virtual machine. Defaults to `false`.
	MemoryHotAddEnabled bool `mapstructure:"RAM_hot_plug"`

	// Enable nested hardware virtualization for the virtual machine.
	NestedHV bool `mapstructure:"NestedHV"`
	// The firmware for the virtual machine.
	//
	// The available options for this setting are: 'bios', 'efi', and
	// 'efi-secure'.
	//
	// -> **Note:** Use `efi-secure` for UEFI Secure Boot.
	Firmware string `mapstructure:"firmware"`
	// The VM hardware version. Defaults to vmx-21 (ESXi 8.0+).
	// Examples: vmx-19 (ESXi 7.0 U2+), vmx-20 (ESXi 8.0), vmx-21 (ESXi 8.0 U2+)
	HardwareVersion string `mapstructure:"hw_version"`
	// Force entry into the BIOS setup screen during boot. Defaults to `false`.
	ForceBIOSSetup bool `mapstructure:"force_bios_setup"`
	// Enable virtual trusted platform module (TPM) device for the virtual
	// machine. Defaults to `false`.
	VTPMEnabled bool `mapstructure:"vTPM"`
}

func (*HardwareConfig) Prepare

func (c *HardwareConfig) Prepare() []error

type LocationConfig

type LocationConfig struct {
	// The name of the virtual machine.
	VMName string `mapstructure:"vm_name"`
	// The vApp where the virtual machine is created.
	// If not specified and create_vapp is true, a new vApp will be created.
	VApp string `mapstructure:"vapp"`
	// The VDC where the virtual machine is created.
	VDC string `mapstructure:"vdc"`
	// If true, create a new vApp if the specified vApp does not exist.
	// Defaults to true.
	CreateVApp bool `mapstructure:"create_vapp"`
	// The network to attach to the virtual machine.
	Network string `mapstructure:"network"`
	// The IP allocation mode for the network connection.
	// Valid values are: POOL, DHCP, MANUAL, NONE.
	// Defaults to POOL.
	IPAllocationMode string `mapstructure:"ip_allocation_mode"`
	// The static IP address for the virtual machine.
	// Required when ip_allocation_mode is MANUAL, unless auto_discover_ip is true.
	VMIPAddress string `mapstructure:"vm_ip"`
	// Auto-discover an available IP from the network's IP pool.
	// Requires ip_allocation_mode = "MANUAL". When enabled, finds the first
	// available IP from the network's static IP pool and makes network info
	// available as template variables: {{ .VMIP }}, {{ .Gateway }}, {{ .Netmask }}, {{ .DNS }}.
	AutoDiscoverIP bool `mapstructure:"auto_discover_ip"`
	// Override the gateway address discovered from the network.
	// Only used when auto_discover_ip = true.
	VMGateway string `mapstructure:"vm_gateway"`
	// Override the DNS server discovered from the network.
	// Only used when auto_discover_ip = true.
	VMDNS string `mapstructure:"vm_dns"`
	// The storage profile to use for the virtual machine.
	// If not specified, the default storage profile for the VDC will be used.
	StorageProfile string `mapstructure:"storage_profile"`
}

func (*LocationConfig) Prepare

func (c *LocationConfig) Prepare() []error

type OutputConfig

type OutputConfig struct {
	// The directory where artifacts from the build, such as the virtual machine
	// files and disks, will be output to. The path to the directory may be
	// relative or absolute. If relative, the path is relative to the working
	// directory Packer is run from. This directory must not exist or, if
	// created, must be empty prior to running the builder. By default, this is
	// "output-<buildName>" where "buildName" is the name of the build.
	OutputDir string `mapstructure:"output_directory" required:"false"`
	// The permissions to apply to the "output_directory", and to any parent
	// directories that get created for output_directory.  By default, this is
	// "0750". You should express the permission as quoted string with a
	// leading zero such as "0755" in JSON file, because JSON does not support
	// octal value. In Unix-like OS, the actual permission may differ from
	// this value because of umask.
	DirPerm os.FileMode `mapstructure:"directory_permission" required:"false"`
}

func (*OutputConfig) FlatMapstructure

func (*OutputConfig) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatOutputConfig. FlatOutputConfig is an auto-generated flat version of OutputConfig. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*OutputConfig) ListFiles

func (c *OutputConfig) ListFiles() ([]string, error)

ListFiles retrieves a list of all non-directory file paths within the configured output directory.

func (*OutputConfig) Prepare

func (c *OutputConfig) Prepare(ctx *interpolate.Context, pc *common.PackerConfig) []error

type RemoveNetworkAdapterConfig

type RemoveNetworkAdapterConfig struct {
	// Remove all network adapters from the virtual machine image. Defaults to `false`.
	RemoveNetworkAdapter bool `mapstructure:"remove_network_adapter"`
}

type RunConfig

type RunConfig struct {
	// The priority of boot devices. Defaults to `disk,cdrom`.
	//
	// The available boot devices are: `floppy`, `cdrom`, `ethernet`, and
	// `disk`.
	//
	// -> **Note:** If not set, the boot order is temporarily set to
	// `disk,cdrom` for the duration of the build and then cleared upon
	// build completion.
	BootOrder string `mapstructure:"boot_order"`
}

type ShutdownConfig

type ShutdownConfig struct {
	// Specify a virtual machine guest shutdown command. This command will be run using
	// the `communicator`. Otherwise, the VMware Tools are used to gracefully shut down
	// the virtual machine.
	Command string `mapstructure:"shutdown_command"`
	// Amount of time to wait for graceful shut down of the virtual machine.
	// Defaults to `5m` (5 minutes).
	// This will likely need to be modified if the `communicator` is 'none'.
	Timeout time.Duration `mapstructure:"shutdown_timeout"`
	// Packer normally halts the virtual machine after all provisioners have
	// run when no `shutdown_command` is defined. If this is set to `true`, Packer
	// *will not* halt the virtual machine but will assume that you will send the stop
	// signal yourself through a `preseed.cfg`, a script or the final provisioner.
	// Packer will wait for a default of 5 minutes until the virtual machine is shutdown.
	// The timeout can be changed using `shutdown_timeout` option.
	DisableShutdown bool `mapstructure:"disable_shutdown"`
}

func (*ShutdownConfig) Prepare

func (c *ShutdownConfig) Prepare(comm communicator.Config) (warnings []string, errs []error)

type StepBootCommand

type StepBootCommand struct {
	Config *BootCommandConfig
	VMName string
	Ctx    interpolate.Context
}

StepBootCommand runs the boot command via WMKS console

func (*StepBootCommand) Cleanup

func (s *StepBootCommand) Cleanup(state multistep.StateBag)

func (*StepBootCommand) Run

type StepConnect

type StepConnect struct {
	Config *ConnectConfig
}

func (*StepConnect) Cleanup

func (s *StepConnect) Cleanup(state multistep.StateBag)

func (*StepConnect) Run

type StepCreateTempCatalog

type StepCreateTempCatalog struct {
	Config  *CatalogConfig
	VDCName string // VDC name to get storage profile from for catalog storage
}

func (*StepCreateTempCatalog) Cleanup

func (s *StepCreateTempCatalog) Cleanup(state multistep.StateBag)

func (*StepCreateTempCatalog) Run

type StepDiscoverIP added in v0.0.2

type StepDiscoverIP struct {
	NetworkName     string
	AutoDiscover    bool
	ManualIP        string // If set, skip discovery and use this IP
	OverrideGateway string // Optional override for gateway
	OverrideDNS     string // Optional override for DNS
}

StepDiscoverIP discovers an available IP address from the network's IP pool. This step is used when auto_discover_ip is enabled to automatically find an available IP from the network's static IP pool.

func (*StepDiscoverIP) Cleanup added in v0.0.2

func (s *StepDiscoverIP) Cleanup(state multistep.StateBag)

func (*StepDiscoverIP) Run added in v0.0.2

type StepExportToCatalog

type StepExportToCatalog struct {
	Config *ExportToCatalogConfig
}

func (*StepExportToCatalog) Cleanup

func (s *StepExportToCatalog) Cleanup(state multistep.StateBag)

func (*StepExportToCatalog) Run

type StepHTTPIPDiscover

type StepHTTPIPDiscover struct {
	// HTTPIP is a manually specified IP address to use (overrides auto-discovery)
	HTTPIP string
	// HTTPInterface is a specific network interface to use
	HTTPInterface string
	// TargetHost is the host to use for route-based IP discovery (typically VCD host)
	TargetHost string
}

StepHTTPIPDiscover discovers the host IP address to use for the HTTP server. This IP needs to be reachable from the VM for serving kickstart/preseed files.

func (*StepHTTPIPDiscover) Cleanup

func (s *StepHTTPIPDiscover) Cleanup(state multistep.StateBag)

func (*StepHTTPIPDiscover) Run

type StepMountISO

type StepMountISO struct{}

func (*StepMountISO) Cleanup

func (s *StepMountISO) Cleanup(state multistep.StateBag)

func (*StepMountISO) Run

type StepRemoveNetworkAdapter

type StepRemoveNetworkAdapter struct {
	Config *RemoveNetworkAdapterConfig
}

func (*StepRemoveNetworkAdapter) Run

type StepResolveVApp

type StepResolveVApp struct {
	VDCName     string
	VAppName    string
	NetworkName string
	CreateVApp  bool
}

func (*StepResolveVApp) Cleanup

func (s *StepResolveVApp) Cleanup(state multistep.StateBag)

func (*StepResolveVApp) Run

type StepRun

type StepRun struct {
	Config   *RunConfig
	SetOrder bool
}

func (*StepRun) Cleanup

func (s *StepRun) Cleanup(state multistep.StateBag)

func (*StepRun) Run

type StepShutdown

type StepShutdown struct {
	Config *ShutdownConfig
}

func (*StepShutdown) Cleanup

func (s *StepShutdown) Cleanup(state multistep.StateBag)

func (*StepShutdown) Run

type StepUploadISO

type StepUploadISO struct {
	// CacheISO when true checks if ISO already exists in catalog before uploading.
	CacheISO bool
	// CacheOverwrite when true will delete and re-upload existing ISO.
	CacheOverwrite bool
}

func (*StepUploadISO) Cleanup

func (s *StepUploadISO) Cleanup(state multistep.StateBag)

func (*StepUploadISO) Run

type StepWaitForIP

type StepWaitForIP struct {
	Config *WaitIpConfig
}

StepWaitForIP waits for the VM to acquire an IP address. This is needed before the communicator can connect to the VM.

func (*StepWaitForIP) Cleanup

func (s *StepWaitForIP) Cleanup(state multistep.StateBag)

func (*StepWaitForIP) Run

type WaitIpConfig

type WaitIpConfig struct {
	// Time to wait for the VM to get an IP address. Defaults to 30m.
	WaitTimeout time.Duration `mapstructure:"ip_wait_timeout"`

	// Time to wait after IP is discovered before considering it stable. Defaults to 5s.
	SettleTimeout time.Duration `mapstructure:"ip_settle_timeout"`
}

WaitIpConfig contains configuration for waiting for VM IP address

func (*WaitIpConfig) FlatMapstructure

func (*WaitIpConfig) FlatMapstructure() interface{ HCL2Spec() map[string]hcldec.Spec }

FlatMapstructure returns a new FlatWaitIpConfig. FlatWaitIpConfig is an auto-generated flat version of WaitIpConfig. Where the contents a fields with a `mapstructure:,squash` tag are bubbled up.

func (*WaitIpConfig) Prepare

func (c *WaitIpConfig) Prepare() []error

Jump to

Keyboard shortcuts

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