Documentation
¶
Index ¶
- Constants
- Variables
- func CommHost(host string) func(multistep.StateBag) (string, error)
- func CommPort(state multistep.StateBag) (int, error)
- func GetControllerEnumCode(controllerName string) (string, error)
- func NewArtifact(dir string, vmName string, generatedData map[string]interface{}) (packersdk.Artifact, error)
- type CommConfig
- type Driver
- type DriverMock
- func (d *DriverMock) Delete(name string) error
- func (d *DriverMock) ExecuteOsaScript(command ...string) (string, error)
- func (d *DriverMock) Export(vmId string, path string) error
- func (d *DriverMock) GuestToolsIsoPath() (string, error)
- func (d *DriverMock) Import(path string) (string, error)
- func (d *DriverMock) IsRunning(name string) (bool, error)
- func (d *DriverMock) Stop(name string) error
- func (d *DriverMock) Utmctl(args ...string) (string, error)
- func (d *DriverMock) Verify() error
- func (d *DriverMock) Version() (string, error)
- type ExportConfig
- type GuestAdditionsConfig
- type HWConfig
- type NoPauseConfig
- type OutputConfig
- type ShutdownConfig
- type StepAttachDisplay
- type StepAttachISOs
- type StepCreateVM
- type StepDownloadGuestAdditions
- type StepExport
- type StepHTTPIPDiscover
- type StepPause
- type StepPortForwarding
- type StepRemoveDevices
- type StepRun
- type StepShutdown
- type StepSshKeyPair
- type StepStopVm
- type StepUploadVersion
- type StepUtmDownload
- type Utm45Driver
- func (d *Utm45Driver) Delete(name string) error
- func (d *Utm45Driver) ExecuteOsaScript(command ...string) (string, error)
- func (d *Utm45Driver) Export(vmId string, path string) error
- func (d *Utm45Driver) GuestToolsIsoPath() (string, error)
- func (d *Utm45Driver) Import(path string) (string, error)
- func (d *Utm45Driver) IsRunning(name string) (bool, error)
- func (d *Utm45Driver) Stop(name string) error
- func (d *Utm45Driver) Utmctl(args ...string) (string, error)
- func (d *Utm45Driver) Verify() error
- func (d *Utm45Driver) Version() (string, error)
- type Utm46Driver
- type UtmBundleConfig
- type UtmVersionConfig
Constants ¶
const ( GuestAdditionsModeDisable string = "disable" GuestAdditionsModeAttach string = "attach" GuestAdditionsModeUpload string = "upload" )
These are the different valid mode values for "guest_additions_mode" which determine how guest additions are delivered to the guest.
const BuilderId = "naveenrajm7.utm"
This is the common builder ID to all of these artifacts.
Variables ¶
var ControllerEnumMap = map[string]string{
"none": "QdIn",
"ide": "QdIi",
"scsi": "QdIs",
"sd": "QdId",
"mtd": "QdIm",
"floppy": "QdIf",
"pflash": "QdIp",
"virtio": "QdIv",
"nvme": "QdIn",
"usb": "QdIu",
}
Map of controller names to their corresponding enum codes
Functions ¶
func GetControllerEnumCode ¶
Function to get the UTM enum code for a given controller name
Types ¶
type CommConfig ¶
type CommConfig struct {
Comm communicator.Config `mapstructure:",squash"`
// The minimum port to use for the Communicator port on the host machine which is forwarded
// to the SSH or WinRM port on the guest machine. By default this is 2222.
HostPortMin int `mapstructure:"host_port_min" required:"false"`
// The maximum port to use for the Communicator port on the host machine which is forwarded
// to the SSH or WinRM port on the guest machine. Because Packer often runs in parallel,
// Packer will choose a randomly available port in this range to use as the
// host port. By default this is 4444.
HostPortMax int `mapstructure:"host_port_max" required:"false"`
// Defaults to false. When enabled, Packer
// does not setup forwarded port mapping for communicator (SSH or WinRM) requests and uses ssh_port or winrm_port
// on the host to communicate to the virtual machine.
SkipNatMapping bool `mapstructure:"skip_nat_mapping" required:"false"`
// These are deprecated, but we keep them around for backwards compatibility
// TODO: remove later
SSHHostPortMin int `mapstructure:"ssh_host_port_min" required:"false"`
// TODO: remove later
SSHHostPortMax int `mapstructure:"ssh_host_port_max"`
// TODO: remove later
SSHSkipNatMapping bool `mapstructure:"ssh_skip_nat_mapping" required:"false"`
}
func (*CommConfig) Prepare ¶
func (c *CommConfig) Prepare(ctx *interpolate.Context) []error
type Driver ¶
type Driver interface {
// Delete a VM by name
Delete(string) error
// Executes the given AppleScript with the given arguments.
ExecuteOsaScript(command ...string) (string, error)
// Export a VM to a UTM file
Export(string, string) error
// Import a VM
Import(string) (string, error)
// Checks if the VM with the given id is running.
IsRunning(string) (bool, error)
// Get guest tools iso path
GuestToolsIsoPath() (string, error)
// Stop stops a running machine, forcefully.
Stop(string) error
// Utmctl executes the given Utmctl command
// and returns the stdout channel as string
Utmctl(...string) (string, error)
// Verify checks to make sure that this driver should function
// properly. If there is any indication the driver can't function,
// this will return an error.
Verify() error
// Version reads the version of UTM that is installed.
Version() (string, error)
}
A driver is able to talk to UTM and perform certain operations with it. Some of the operations on here may seem overly specific, but they were built specifically in mind to handle features of the UTM builder for Packer, and to abstract differences in versions out of the builder steps, so sometimes the methods are extremely specific.
type DriverMock ¶
type DriverMock struct {
sync.Mutex
DeleteCalled bool
DeleteName string
DeleteErr error
ExecuteOsaCalls [][]string
ExecuteOsaErrs []error
ExecuteOsaResult string
GuestToolsIsoPathCalled bool
GuestToolsIsoPathErr error
ImportCalled bool
ImportId string
ImportPath string
ImportErr error
IsRunningName string
IsRunningReturn bool
IsRunningErr error
StopName string
StopErr error
UtmctlCalls [][]string
UtmctlErrs []error
UtmctlResult string
VerifyCalled bool
VerifyErr error
VersionCalled bool
VersionResult string
VersionErr error
}
func (*DriverMock) Delete ¶
func (d *DriverMock) Delete(name string) error
func (*DriverMock) ExecuteOsaScript ¶
func (d *DriverMock) ExecuteOsaScript(command ...string) (string, error)
func (*DriverMock) GuestToolsIsoPath ¶
func (d *DriverMock) GuestToolsIsoPath() (string, error)
func (*DriverMock) Stop ¶
func (d *DriverMock) Stop(name string) error
func (*DriverMock) Verify ¶
func (d *DriverMock) Verify() error
func (*DriverMock) Version ¶
func (d *DriverMock) Version() (string, error)
type ExportConfig ¶
type ExportConfig struct {
// Only UTM, this specifies the output format
// of the exported virtual machine. This defaults to utm.
Format string `mapstructure:"format" required:"false"`
}
func (*ExportConfig) Prepare ¶
func (c *ExportConfig) Prepare(ctx *interpolate.Context) []error
type GuestAdditionsConfig ¶
type GuestAdditionsConfig struct {
// The method by which guest additions are
// made available to the guest for installation. Valid options are `upload`,
// `attach`, or `disable`. If the mode is `attach` the guest additions ISO will
// be attached as a CD device to the virtual machine. If the mode is `upload`
// the guest additions ISO will be uploaded to the path specified by
// `guest_additions_path`. The default value is `upload`. If `disable` is used,
// guest additions won't be downloaded, either.
GuestAdditionsMode string `mapstructure:"guest_additions_mode"`
// The interface type to use to mount guest additions when
// guest_additions_mode is set to attach. Will default to the value set in
// iso_interface, if iso_interface is set. Will default to "USB", if
// iso_interface is not set. Options are none/IDE/SCSI/SD/MTD/Floppy/PFlash/VirtIO/NVMe/USB.
GuestAdditionsInterface string `mapstructure:"guest_additions_interface" required:"false"`
// The path on the guest virtual machine
// where the UTM guest additions ISO will be uploaded. By default this
// is `utm-guest-tools-<version>.iso` which should upload into the login directory of
// the user.
GuestAdditionsPath string `mapstructure:"guest_additions_path"`
// The SHA256 checksum of the guest
// additions ISO that will be uploaded to the guest VM. By default the
// checksums will be downloaded from the UTM website, so this only needs
// to be set if you want to be explicit about the checksum.
GuestAdditionsSHA256 string `mapstructure:"guest_additions_sha256"`
// The URL of the guest additions ISO
// to upload. This can also be a file URL if the ISO is at a local path. By
// default, the UTM builder will attempt to find the guest additions ISO
// on the local file system. If it is not available locally, the builder will
// download the proper guest additions ISO from the internet.
GuestAdditionsURL string `mapstructure:"guest_additions_url" required:"false"`
}
func (*GuestAdditionsConfig) Prepare ¶
func (c *GuestAdditionsConfig) Prepare(communicatorType string) []error
type HWConfig ¶
type NoPauseConfig ¶
type NoPauseConfig struct {
// If true, the build process will not pause to add display.
// false by default
DisplayNoPause bool `mapstructure:"display_nopause" required:"false"`
// If true, the build process will not pause to confirm successful boot.
// false by default
BootNoPause bool `mapstructure:"boot_nopause" required:"false"`
// If true, the build process will not pause to allow pre-export steps.
// false by default
ExportNoPause bool `mapstructure:"export_nopause" required:"false"`
}
Temporary configuration to disable the pause step Once the pause step is removed, this configuration will be removed as well
func (*NoPauseConfig) Prepare ¶
func (c *NoPauseConfig) Prepare(ctx *interpolate.Context) []error
type OutputConfig ¶
type OutputConfig struct {
// This is the path to the directory where the
// resulting virtual machine will be created. This may be relative or absolute.
// If relative, the path is relative to the working directory when packer
// is executed. This directory must not exist or 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"`
// This is the base name of the file (excluding the file extension) where
// the resulting virtual machine will be created. By default this is the
// `vm_name`.
OutputFilename string `mapstructure:"output_filename" required:"false"`
}
func (*OutputConfig) Prepare ¶
func (c *OutputConfig) Prepare(ctx *interpolate.Context, pc *common.PackerConfig) []error
type ShutdownConfig ¶
type ShutdownConfig struct {
// The command to use to gracefully shut down the
// machine once all the provisioning is done. By default this is an empty
// string, which tells Packer to just forcefully shut down the machine unless a
// shutdown command takes place inside script so this may safely be omitted. If
// one or more scripts require a reboot it is suggested to leave this blank
// since reboots may fail and specify the final shutdown command in your
// last script.
ShutdownCommand string `mapstructure:"shutdown_command" required:"false"`
// The amount of time to wait after executing the
// shutdown_command for the virtual machine to actually shut down. If it
// doesn't shut down in this time, it is an error. By default, the timeout is
// 5m or five minutes.
ShutdownTimeout time.Duration `mapstructure:"shutdown_timeout" required:"false"`
// The amount of time to wait after shutting
// down the virtual machine. If you get the error
// Error removing floppy controller, you might need to set this to 5m
// or so. By default, the delay is 0s or disabled.
PostShutdownDelay time.Duration `mapstructure:"post_shutdown_delay" required:"false"`
// 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 the preseed.cfg or your 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" required:"false"`
}
func (*ShutdownConfig) Prepare ¶
func (c *ShutdownConfig) Prepare(ctx *interpolate.Context) []error
type StepAttachDisplay ¶
type StepAttachDisplay struct {
HardwareType string
// contains filtered or unexported fields
}
This step attaches a display to the virtual machine.
func (*StepAttachDisplay) Cleanup ¶
func (s *StepAttachDisplay) Cleanup(state multistep.StateBag)
func (*StepAttachDisplay) Run ¶
func (s *StepAttachDisplay) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepAttachISOs ¶
type StepAttachISOs struct {
AttachBootISO bool
ISOInterface string
GuestAdditionsMode string
GuestAdditionsInterface string
// contains filtered or unexported fields
}
This step attaches the boot ISO, cd_files iso, and guest additions to the virtual machine, if present.
func (*StepAttachISOs) Cleanup ¶
func (s *StepAttachISOs) Cleanup(state multistep.StateBag)
func (*StepAttachISOs) Run ¶
func (s *StepAttachISOs) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepCreateVM ¶
type StepCreateVM struct {
// takes
VMName string
VMBackend string
VMArch string
VMIcon string
HWConfig HWConfig
UEFIBoot bool
Hypervisor bool
KeepRegistered bool
// contains filtered or unexported fields
}
This step creates the actual virtual machine.
Produces:
vmId string - The UUID of the VM
func (*StepCreateVM) Cleanup ¶
func (s *StepCreateVM) Cleanup(state multistep.StateBag)
func (*StepCreateVM) Run ¶
func (s *StepCreateVM) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepDownloadGuestAdditions ¶
type StepDownloadGuestAdditions struct {
GuestAdditionsMode string
GuestAdditionsURL string
GuestAdditionsSHA256 string
Ctx interpolate.Context
}
This step uploads a file containing the UTM version, which can be useful for various provisioning reasons.
Produces:
guest_additions_path string - Path to the guest additions.
func (*StepDownloadGuestAdditions) Cleanup ¶
func (s *StepDownloadGuestAdditions) Cleanup(state multistep.StateBag)
func (*StepDownloadGuestAdditions) Run ¶
func (s *StepDownloadGuestAdditions) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepExport ¶
type StepExport struct {
Format string
OutputDir string
OutputFilename string
ExportOpts []string
Bundling UtmBundleConfig
SkipNatMapping bool
SkipExport bool
}
This step cleans up forwarded ports and (TODO) exports the VM to an UTM file.
Uses:
Produces:
exportPath string - The path to the resulting export.
func (*StepExport) Cleanup ¶
func (s *StepExport) Cleanup(state multistep.StateBag)
func (*StepExport) Run ¶
func (s *StepExport) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepHTTPIPDiscover ¶
type StepHTTPIPDiscover struct{}
Step to discover the http ip which guests use to reach the vm host To make sure the IP is set before boot command and http server steps
func (*StepHTTPIPDiscover) Cleanup ¶
func (s *StepHTTPIPDiscover) Cleanup(state multistep.StateBag)
func (*StepHTTPIPDiscover) Run ¶
func (s *StepHTTPIPDiscover) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepPortForwarding ¶
type StepPortForwarding struct {
CommConfig *communicator.Config
HostPortMin int
HostPortMax int
SkipNatMapping bool
ClearNetworkInterfaces bool // if true, all network interfaces will be cleared before adding new ones
// contains filtered or unexported fields
}
This step adds a Emulated VLAN port forwarding definition so that SSH (or WinRM ?) is available on the guest machine.
Uses:
driver Driver ui packersdk.Ui vmName string
Produces:
func (*StepPortForwarding) Cleanup ¶
func (s *StepPortForwarding) Cleanup(state multistep.StateBag)
func (*StepPortForwarding) Run ¶
func (s *StepPortForwarding) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepRemoveDevices ¶
type StepRemoveDevices struct {
Bundling UtmBundleConfig
}
This step removes any devices (floppy disks, ISOs, etc.) from the machine that we may have added.
Uses:
driver Driver ui packersdk.Ui vmName string
Produces:
func (*StepRemoveDevices) Cleanup ¶
func (s *StepRemoveDevices) Cleanup(state multistep.StateBag)
func (*StepRemoveDevices) Run ¶
func (s *StepRemoveDevices) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepRun ¶
type StepRun struct {
// contains filtered or unexported fields
}
This step starts the virtual machine.
Uses:
driver Driver ui packersdk.Ui vmName string
Produces:
type StepShutdown ¶
type StepShutdown struct {
Command string
Timeout time.Duration
Delay time.Duration
DisableShutdown bool
}
This step shuts down the machine.
Uses:
communicator packersdk.Communicator driver Driver ui packersdk.Ui vmName string
Produces:
<nothing>
func (*StepShutdown) Cleanup ¶
func (s *StepShutdown) Cleanup(state multistep.StateBag)
func (*StepShutdown) Run ¶
func (s *StepShutdown) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepSshKeyPair ¶
type StepSshKeyPair struct {
Debug bool
DebugKeyPath string
Comm *communicator.Config
}
StepSshKeyPair executes the business logic for setting the SSH key pair in the specified communicator.Config.
func (*StepSshKeyPair) Cleanup ¶
func (s *StepSshKeyPair) Cleanup(state multistep.StateBag)
func (*StepSshKeyPair) Run ¶
func (s *StepSshKeyPair) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepStopVm ¶
type StepStopVm struct{}
This step stops the machine.
Uses:
driver Driver ui packersdk.Ui vmId string
Produces:
<nothing>
func (*StepStopVm) Cleanup ¶
func (s *StepStopVm) Cleanup(state multistep.StateBag)
func (*StepStopVm) Run ¶
func (s *StepStopVm) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepUploadVersion ¶
type StepUploadVersion struct {
Path string
}
This step uploads a file containing the UTM version, which can be useful for various provisioning reasons.
func (*StepUploadVersion) Cleanup ¶
func (s *StepUploadVersion) Cleanup(state multistep.StateBag)
func (*StepUploadVersion) Run ¶
func (s *StepUploadVersion) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type StepUtmDownload ¶
type StepUtmDownload struct {
// The checksum and the type of the checksum for the download
Checksum string
// A short description of the type of download being done. Example:
// "ISO" or "Guest Additions"
Description string
// The name of the key where the final path of the ISO will be put
// into the state.
ResultKey string
// The path where the result should go, otherwise it goes to the
// cache directory.
TargetPath string
// A list of URLs to attempt to download this thing.
Url []string
// Extension is the extension to force for the file that is downloaded.
// Some systems require a certain extension. If this isn't set, the
// extension on the URL is used. Otherwise, this will be forced
// on the downloaded file for every URL.
Extension string
}
Uses:
ui packersdk.Ui
func (*StepUtmDownload) Cleanup ¶
func (s *StepUtmDownload) Cleanup(multistep.StateBag)
func (*StepUtmDownload) Run ¶
func (s *StepUtmDownload) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction
type Utm45Driver ¶
type Utm45Driver struct {
// This is the path to the utmctl binary
UtmctlPath string
}
Utm45Driver is the base type for UTM drivers
func (*Utm45Driver) Delete ¶
func (d *Utm45Driver) Delete(name string) error
func (*Utm45Driver) ExecuteOsaScript ¶
func (d *Utm45Driver) ExecuteOsaScript(command ...string) (string, error)
ExecuteOsaScript executes an AppleScript command with the given arguments.
func (*Utm45Driver) Export ¶
func (d *Utm45Driver) Export(vmId string, path string) error
UTM 4.5 Doesn't support exporting VMs
func (*Utm45Driver) GuestToolsIsoPath ¶
func (d *Utm45Driver) GuestToolsIsoPath() (string, error)
UTM 4.5 : doesn't support adding support guest tools
func (*Utm45Driver) Import ¶
func (d *Utm45Driver) Import(path string) (string, error)
UTM 4.5 : We just create a VM shortcut using UTM open command.
func (*Utm45Driver) Stop ¶
func (d *Utm45Driver) Stop(name string) error
func (*Utm45Driver) Verify ¶
func (d *Utm45Driver) Verify() error
func (*Utm45Driver) Version ¶
func (d *Utm45Driver) Version() (string, error)
Version reads the version of UTM that is installed.
type Utm46Driver ¶
type Utm46Driver struct {
Utm45Driver
}
Utm46Driver are inherited from Utm45Driver.
func (*Utm46Driver) Export ¶
func (d *Utm46Driver) Export(vmId string, path string) error
Export VM to UTM file
func (*Utm46Driver) GuestToolsIsoPath ¶
func (d *Utm46Driver) GuestToolsIsoPath() (string, error)
Return the downloaded guest tools path if available.
type UtmBundleConfig ¶
type UtmBundleConfig struct {
// Defaults to false. When enabled, Packer includes
// any attached ISO disc devices into the final virtual machine. Useful for
// some live distributions that require installation media to continue to be
// attached after installation.
BundleISO bool `mapstructure:"bundle_iso" required:"false"`
}
func (*UtmBundleConfig) Prepare ¶
func (c *UtmBundleConfig) Prepare(ctx *interpolate.Context) []error
type UtmVersionConfig ¶
type UtmVersionConfig struct {
// The path within the virtual machine to
// upload a file that contains the UTM version that was used to create
// the machine. This information can be useful for provisioning. By default
// this is .utm_version, which will generally be upload it into the
// home directory. Set to an empty string to skip uploading this file, which
// can be useful when using the none communicator.
UtmVersionFile *string `mapstructure:"utm_version_file" required:"false"`
}
func (*UtmVersionConfig) Prepare ¶
func (c *UtmVersionConfig) Prepare(communicatorType string) []error
Source Files
¶
- artifact.go
- comm.go
- comm_config.go
- driver.go
- driver_4_5.go
- driver_4_6.go
- driver_mock.go
- export_config.go
- guest_additions_config.go
- hw_config.go
- nopause_config.go
- output_config.go
- shutdown_config.go
- step_attach_display.go
- step_attach_isos.go
- step_create_vm.go
- step_download.go
- step_download_guest_additions.go
- step_export.go
- step_http_ip_discover.go
- step_pause.go
- step_port_forwarding.go
- step_remove_devices.go
- step_run.go
- step_shutdown.go
- step_ssh_key_pair.go
- step_stop_vm.go
- step_upload_version.go
- utils.go
- utm_version_config.go
- utmbundle_config.go