common

package
v0.0.0-...-aff02b7 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2020 License: MPL-2.0 Imports: 30 Imported by: 8

Documentation

Index

Constants

View Source
const BuilderId = "packer.xenserver"

This is the common builder ID to all of these artifacts.

View Source
const KeyLeftShift uint = 0xFFE1

Variables

This section is empty.

Functions

func CommHost

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

func ExecuteGuestSSHCmd

func ExecuteGuestSSHCmd(state multistep.StateBag, cmd string) (stdout string, err error)

func ExecuteHostSSHCmd

func ExecuteHostSSHCmd(state multistep.StateBag, cmd string) (stdout string, err error)

func FindPort

func FindPort(portMin uint, portMax uint) (net.Listener, uint)

FindPort finds and starts listening on a port in the range [portMin, portMax] returns the listener and the port number on success, or nil, 0 on failure

func HTTPUpload

func HTTPUpload(import_url string, fh *os.File, state multistep.StateBag) (result *xsclient.XenAPIObject, err error)

func HimnSSHIP

func HimnSSHIP(state multistep.StateBag) (string, error)

func HimnSSHPort

func HimnSSHPort(state multistep.StateBag) (uint, error)

func InstanceSSHIP

func InstanceSSHIP(state multistep.StateBag) (string, error)

func InstanceSSHPort

func InstanceSSHPort(state multistep.StateBag) (uint, error)

func InstanceVNCIP

func InstanceVNCIP(state multistep.StateBag) (string, error)

func InstanceVNCPort

func InstanceVNCPort(state multistep.StateBag) (uint, error)

func NewArtifact

func NewArtifact(dir string) (packer.Artifact, error)

func SSHAddress

func SSHAddress(state multistep.StateBag) (string, error)

func SSHConfigFunc

func SSHConfigFunc(config SSHConfig) func(multistep.StateBag) (*gossh.ClientConfig, error)

func SSHLocalAddress

func SSHLocalAddress(state multistep.StateBag) (string, error)

func SSHPort

func SSHPort(state multistep.StateBag) (int, error)

Types

type APIResult

type APIResult struct {
	Status           string
	Value            interface{}
	ErrorDescription string
}

type CommonConfig

type CommonConfig struct {
	Username string `mapstructure:"remote_username"`
	Password string `mapstructure:"remote_password"`
	HostIp   string `mapstructure:"remote_host"`

	VMName             string   `mapstructure:"vm_name"`
	VMDescription      string   `mapstructure:"vm_description"`
	SrName             string   `mapstructure:"sr_name"`
	FloppyFiles        []string `mapstructure:"floppy_files"`
	NetworkNames       []string `mapstructure:"network_names"`
	ExportNetworkNames []string `mapstructure:"export_network_names"`

	HostPortMin uint `mapstructure:"host_port_min"`
	HostPortMax uint `mapstructure:"host_port_max"`

	BootCommand     []string `mapstructure:"boot_command"`
	ShutdownCommand string   `mapstructure:"shutdown_command"`

	RawBootWait string `mapstructure:"boot_wait"`
	BootWait    time.Duration

	ToolsIsoName string `mapstructure:"tools_iso_name"`

	HTTPDir     string `mapstructure:"http_directory"`
	HTTPPortMin uint   `mapstructure:"http_port_min"`
	HTTPPortMax uint   `mapstructure:"http_port_max"`

	//	SSHHostPortMin    uint   `mapstructure:"ssh_host_port_min"`
	//	SSHHostPortMax    uint   `mapstructure:"ssh_host_port_max"`
	SSHKeyPath  string `mapstructure:"ssh_key_path"`
	SSHPassword string `mapstructure:"ssh_password"`
	SSHPort     uint   `mapstructure:"ssh_port"`
	SSHUser     string `mapstructure:"ssh_username"`
	SSHConfig   `mapstructure:",squash"`

	RawSSHWaitTimeout string `mapstructure:"ssh_wait_timeout"`
	SSHWaitTimeout    time.Duration

	OutputDir string `mapstructure:"output_directory"`
	Format    string `mapstructure:"format"`
	KeepVM    string `mapstructure:"keep_vm"`
	IPGetter  string `mapstructure:"ip_getter"`
}

func (CommonConfig) GetSR

func (config CommonConfig) GetSR(client xsclient.XenAPIClient) (*xsclient.SR, error)

func (*CommonConfig) Prepare

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

func (CommonConfig) ShouldKeepVM

func (c CommonConfig) ShouldKeepVM(state multistep.StateBag) bool

steps should check config.ShouldKeepVM first before cleaning up the VM

type Host

type Host XenAPIObject

func (*Host) CallPlugin

func (self *Host) CallPlugin(plugin, function string, args map[string]string) (res string, err error)

func (*Host) GetSoftwareVersion

func (self *Host) GetSoftwareVersion() (versions map[string]interface{}, err error)

type IPSnooper

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

func (IPSnooper) ServeHTTP

func (snooper IPSnooper) ServeHTTP(resp http.ResponseWriter, req *http.Request)

type InterruptedError

type InterruptedError struct{}

func (InterruptedError) Error

func (err InterruptedError) Error() string

type InterruptibleWait

type InterruptibleWait struct {
	Timeout time.Duration

	// optional:
	Predicate         func() (result bool, err error)
	PredicateInterval time.Duration
}

func (InterruptibleWait) Wait

func (wait InterruptibleWait) Wait(state multistep.StateBag) error

Wait waits for up to Timeout duration, checking an optional Predicate every PredicateInterval duration.

The first run of Predicate is immediately after Wait is called.
If the command is interrupted by the user, then an InterruptedError is returned.
If Predicate is not nil, a timeout leads to TimeoutError being returned, and a successful Predicate run leads to nil being returned.
If Predicate is nil, a timeout is not an error, and nil is returned.

type LocalArtifact

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

func (*LocalArtifact) BuilderId

func (*LocalArtifact) BuilderId() string

func (*LocalArtifact) Destroy

func (a *LocalArtifact) Destroy() error

func (*LocalArtifact) Files

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

func (*LocalArtifact) Id

func (*LocalArtifact) Id() string

func (*LocalArtifact) State

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

func (*LocalArtifact) String

func (a *LocalArtifact) String() string

type Network

type Network XenAPIObject

func (*Network) GetAssignedIPs

func (self *Network) GetAssignedIPs() (ip_map map[string]string, err error)

type PIF

type PIF XenAPIObject

func (*PIF) GetRecord

func (self *PIF) GetRecord() (record map[string]interface{}, err error)

type Pool

type Pool XenAPIObject

func (*Pool) GetRecord

func (self *Pool) GetRecord() (record map[string]interface{}, err error)

type PredicateResult

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

type SR

type SR XenAPIObject

func (*SR) CreateVdi

func (self *SR) CreateVdi(name_label string, size int64) (vdi *VDI, err error)

type SSHConfig

type SSHConfig struct {
	Comm communicator.Config `mapstructure:",squash"`

	SSHHostPortMin    uint `mapstructure:"ssh_host_port_min"`
	SSHHostPortMax    uint `mapstructure:"ssh_host_port_max"`
	SSHSkipNatMapping bool `mapstructure:"ssh_skip_nat_mapping"`

	// These are deprecated, but we keep them around for BC
	// TODO(@mitchellh): remove
	SSHKeyPath     string        `mapstructure:"ssh_key_path"`
	SSHWaitTimeout time.Duration `mapstructure:"ssh_wait_timeout"`
}

func (*SSHConfig) Prepare

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

type StepAttachVdi

type StepAttachVdi struct {
	VdiUuidKey string
	VdiType    xsclient.VDIType
	// contains filtered or unexported fields
}

func (*StepAttachVdi) Cleanup

func (self *StepAttachVdi) Cleanup(state multistep.StateBag)

func (*StepAttachVdi) Run

type StepBootWait

type StepBootWait struct{}

func (*StepBootWait) Cleanup

func (self *StepBootWait) Cleanup(state multistep.StateBag)

func (*StepBootWait) Run

type StepDetachVdi

type StepDetachVdi struct {
	VdiUuidKey string
}

func (*StepDetachVdi) Cleanup

func (self *StepDetachVdi) Cleanup(state multistep.StateBag)

func (*StepDetachVdi) Run

type StepExport

type StepExport struct{}

func (StepExport) Cleanup

func (StepExport) Cleanup(state multistep.StateBag)

func (StepExport) Run

type StepFindVdi

type StepFindVdi struct {
	VdiName       string
	ImagePathFunc func() string
	VdiUuidKey    string
}

func (*StepFindVdi) Cleanup

func (self *StepFindVdi) Cleanup(state multistep.StateBag)

func (*StepFindVdi) Run

type StepForwardPortOverSSH

type StepForwardPortOverSSH struct {
	RemotePort func(state multistep.StateBag) (uint, error)
	RemoteDest func(state multistep.StateBag) (string, error)

	HostPortMin uint
	HostPortMax uint

	ResultKey string
}

func (*StepForwardPortOverSSH) Cleanup

func (self *StepForwardPortOverSSH) Cleanup(state multistep.StateBag)

func (*StepForwardPortOverSSH) Run

type StepGetVNCPort

type StepGetVNCPort struct{}

func (*StepGetVNCPort) Cleanup

func (self *StepGetVNCPort) Cleanup(state multistep.StateBag)

func (*StepGetVNCPort) Run

type StepHTTPServer

type StepHTTPServer struct {
	Chan chan<- string
	// contains filtered or unexported fields
}

This step creates and runs the HTTP server that is serving files from the directory specified by the 'http_directory` configuration parameter in the template.

Uses:

config *config
ui     packer.Ui

Produces:

http_port int - The port the HTTP server started on.

func (*StepHTTPServer) Cleanup

func (s *StepHTTPServer) Cleanup(multistep.StateBag)

func (*StepHTTPServer) Run

type StepPrepareOutputDir

type StepPrepareOutputDir struct {
	Force bool
	Path  string
}

func (*StepPrepareOutputDir) Cleanup

func (self *StepPrepareOutputDir) Cleanup(state multistep.StateBag)

func (*StepPrepareOutputDir) Run

type StepSetVmHostSshAddress

type StepSetVmHostSshAddress struct{}

func (*StepSetVmHostSshAddress) Cleanup

func (self *StepSetVmHostSshAddress) Cleanup(state multistep.StateBag)

func (*StepSetVmHostSshAddress) Run

type StepShutdown

type StepShutdown struct{}

func (StepShutdown) Cleanup

func (StepShutdown) Cleanup(state multistep.StateBag)

func (StepShutdown) Run

type StepStartOnHIMN

type StepStartOnHIMN struct{}

func (*StepStartOnHIMN) Cleanup

func (self *StepStartOnHIMN) Cleanup(state multistep.StateBag)

func (*StepStartOnHIMN) Run

type StepStartVmPaused

type StepStartVmPaused struct{}

func (*StepStartVmPaused) Cleanup

func (self *StepStartVmPaused) Cleanup(state multistep.StateBag)

func (*StepStartVmPaused) Run

type StepTypeBootCommand

type StepTypeBootCommand struct {
	Ctx interpolate.Context
}

func (*StepTypeBootCommand) Cleanup

func (self *StepTypeBootCommand) Cleanup(multistep.StateBag)

func (*StepTypeBootCommand) Run

type StepUploadVdi

type StepUploadVdi struct {
	VdiNameFunc   func() string
	ImagePathFunc func() string
	VdiUuidKey    string
}

func (*StepUploadVdi) Cleanup

func (self *StepUploadVdi) Cleanup(state multistep.StateBag)

func (*StepUploadVdi) Run

type StepWaitForIP

type StepWaitForIP struct {
	Chan    <-chan string
	Timeout time.Duration
}

func (*StepWaitForIP) Cleanup

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

func (*StepWaitForIP) Run

type Task

type Task XenAPIObject

func (*Task) Destroy

func (self *Task) Destroy() (err error)

func (*Task) GetErrorInfo

func (self *Task) GetErrorInfo() (errorInfo []string, err error)

func (*Task) GetProgress

func (self *Task) GetProgress() (progress float64, err error)

func (*Task) GetResult

func (self *Task) GetResult() (object *XenAPIObject, err error)

func (*Task) GetStatus

func (self *Task) GetStatus() (status TaskStatusType, err error)

type TaskStatusType

type TaskStatusType int
const (
	Pending TaskStatusType
	Success
	Failure
	Cancelling
	Cancelled
)

type TimeoutError

type TimeoutError struct{}

func (TimeoutError) Error

func (err TimeoutError) Error() string

type TransferRecord

type TransferRecord struct {
	UrlFull string `xml:"url_full,attr"`
}

type VBD

type VBD XenAPIObject

func (*VBD) Destroy

func (self *VBD) Destroy() (err error)

func (*VBD) Eject

func (self *VBD) Eject() (err error)

func (*VBD) GetRecord

func (self *VBD) GetRecord() (record map[string]interface{}, err error)

VBD associated functions

func (*VBD) GetVDI

func (self *VBD) GetVDI() (vdi *VDI, err error)

func (*VBD) Unplug

func (self *VBD) Unplug() (err error)

type VDI

type VDI XenAPIObject

func (*VDI) Destroy

func (self *VDI) Destroy() (err error)

func (*VDI) Expose

func (self *VDI) Expose(format string) (url string, err error)

func (*VDI) GetUuid

func (self *VDI) GetUuid() (vdi_uuid string, err error)

func (*VDI) GetVBDs

func (self *VDI) GetVBDs() (vbds []VBD, err error)

func (*VDI) Unexpose

func (self *VDI) Unexpose() (err error)

type VDIType

type VDIType int
const (
	Disk VDIType
	CD
	Floppy
)

type VIF

type VIF XenAPIObject

func (*VIF) Destroy

func (self *VIF) Destroy() (err error)

type VM

type VM XenAPIObject

func (*VM) CleanShutdown

func (self *VM) CleanShutdown() (err error)

func (*VM) Clone

func (self *VM) Clone(label string) (new_instance *VM, err error)

func (*VM) ConnectNetwork

func (self *VM) ConnectNetwork(network *Network, device string) (vif *VIF, err error)

func (*VM) ConnectVdi

func (self *VM) ConnectVdi(vdi *VDI, vdiType VDIType) (err error)

func (*VM) Destroy

func (self *VM) Destroy() (err error)

func (*VM) DisconnectVdi

func (self *VM) DisconnectVdi(vdi *VDI) error

func (*VM) GetDisks

func (self *VM) GetDisks() (vdis []*VDI, err error)

func (*VM) GetDomainId

func (self *VM) GetDomainId() (domid string, err error)

func (*VM) GetGuestMetrics

func (self *VM) GetGuestMetrics() (metrics map[string]interface{}, err error)

func (*VM) GetGuestMetricsRef

func (self *VM) GetGuestMetricsRef() (ref string, err error)

func (*VM) GetPowerState

func (self *VM) GetPowerState() (state string, err error)

func (*VM) GetUuid

func (self *VM) GetUuid() (uuid string, err error)

func (*VM) GetVBDs

func (self *VM) GetVBDs() (vbds []VBD, err error)

func (*VM) GetVIFs

func (self *VM) GetVIFs() (vifs []VIF, err error)

func (*VM) HardShutdown

func (self *VM) HardShutdown() (err error)

func (*VM) SetHVMBoot

func (self *VM) SetHVMBoot(policy, bootOrder string) (err error)

func (*VM) SetIsATemplate

func (self *VM) SetIsATemplate(is_a_template bool) (err error)

func (*VM) SetPVBootloader

func (self *VM) SetPVBootloader(pv_bootloader, pv_args string) (err error)

func (*VM) SetPlatform

func (self *VM) SetPlatform(params map[string]string) (err error)

func (*VM) SetStaticMemoryRange

func (self *VM) SetStaticMemoryRange(min, max uint) (err error)

func (*VM) Start

func (self *VM) Start(paused, force bool) (err error)

func (*VM) Unpause

func (self *VM) Unpause() (err error)

type XenAPIClient

type XenAPIClient struct {
	Session  interface{}
	Host     string
	Url      string
	Username string
	Password string
	RPC      *xmlrpc.Client
}

func NewXenAPIClient

func NewXenAPIClient(host, username, password string) (client XenAPIClient)

func (*XenAPIClient) APICall

func (client *XenAPIClient) APICall(result *APIResult, method string, params ...interface{}) (err error)

func (*XenAPIClient) CreateTask

func (client *XenAPIClient) CreateTask() (task *Task, err error)

func (*XenAPIClient) GetDefaultSR

func (client *XenAPIClient) GetDefaultSR() (sr *SR, err error)

func (*XenAPIClient) GetHosts

func (client *XenAPIClient) GetHosts() (hosts []*Host, err error)

func (*XenAPIClient) GetNetworkByNameLabel

func (client *XenAPIClient) GetNetworkByNameLabel(name_label string) (networks []*Network, err error)

func (*XenAPIClient) GetNetworkByUuid

func (client *XenAPIClient) GetNetworkByUuid(network_uuid string) (network *Network, err error)

func (*XenAPIClient) GetPIFs

func (client *XenAPIClient) GetPIFs() (pifs []*PIF, err error)

func (*XenAPIClient) GetPools

func (client *XenAPIClient) GetPools() (pools []*Pool, err error)

func (*XenAPIClient) GetSRByNameLabel

func (client *XenAPIClient) GetSRByNameLabel(name_label string) (srs []*SR, err error)

func (*XenAPIClient) GetSRByUuid

func (client *XenAPIClient) GetSRByUuid(sr_uuid string) (sr *SR, err error)

func (*XenAPIClient) GetVMByNameLabel

func (client *XenAPIClient) GetVMByNameLabel(name_label string) (vms []*VM, err error)

func (*XenAPIClient) GetVMByUuid

func (client *XenAPIClient) GetVMByUuid(vm_uuid string) (vm *VM, err error)

func (*XenAPIClient) GetVdiByNameLabel

func (client *XenAPIClient) GetVdiByNameLabel(name_label string) (vdis []*VDI, err error)

func (*XenAPIClient) GetVdiByUuid

func (client *XenAPIClient) GetVdiByUuid(vdi_uuid string) (vdi *VDI, err error)

func (*XenAPIClient) Login

func (client *XenAPIClient) Login() (err error)

func (*XenAPIClient) RPCCall

func (c *XenAPIClient) RPCCall(result interface{}, method string, params []interface{}) (err error)

type XenAPIObject

type XenAPIObject struct {
	Ref    string
	Client *XenAPIClient
}

Jump to

Keyboard shortcuts

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