googlecompute

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2014 License: MPL-2.0 Imports: 22 Imported by: 0

Documentation

Overview

The googlecompute package contains a packer.Builder implementation that builds images for Google Compute Engine.

Index

Constants

View Source
const BuilderId = "packer.googlecompute"

The unique ID for this builder.

View Source
const DriverScopes string = "https://www.googleapis.com/auth/compute " +
	"https://www.googleapis.com/auth/devstorage.full_control"

Variables

This section is empty.

Functions

This section is empty.

Types

type Artifact

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

Artifact represents a GCE image as the result of a Packer build.

func (*Artifact) BuilderId

func (*Artifact) BuilderId() string

BuilderId returns the builder Id.

func (*Artifact) Destroy

func (a *Artifact) Destroy() error

Destroy destroys the GCE image represented by the artifact.

func (*Artifact) Files

func (*Artifact) Files() []string

Files returns the files represented by the artifact.

func (*Artifact) Id

func (a *Artifact) Id() string

Id returns the GCE image name.

func (*Artifact) State added in v0.7.2

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

func (*Artifact) String

func (a *Artifact) String() string

String returns the string representation of the artifact.

type Builder

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

Builder represents a Packer Builder.

func (*Builder) Cancel

func (b *Builder) Cancel()

Cancel.

func (*Builder) Prepare

func (b *Builder) Prepare(raws ...interface{}) ([]string, error)

Prepare processes the build configuration parameters.

func (*Builder) Run

func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packer.Artifact, error)

Run executes a googlecompute Packer build and returns a packer.Artifact representing a GCE machine image.

type Config

type Config struct {
	common.PackerConfig `mapstructure:",squash"`

	AccountFile       string `mapstructure:"account_file"`
	ClientSecretsFile string `mapstructure:"client_secrets_file"`
	ProjectId         string `mapstructure:"project_id"`

	BucketName           string            `mapstructure:"bucket_name"`
	DiskSizeGb           int64             `mapstructure:"disk_size"`
	ImageName            string            `mapstructure:"image_name"`
	ImageDescription     string            `mapstructure:"image_description"`
	InstanceName         string            `mapstructure:"instance_name"`
	MachineType          string            `mapstructure:"machine_type"`
	Metadata             map[string]string `mapstructure:"metadata"`
	Network              string            `mapstructure:"network"`
	SourceImage          string            `mapstructure:"source_image"`
	SourceImageProjectId string            `mapstructure:"source_image_project_id"`
	SSHUsername          string            `mapstructure:"ssh_username"`
	SSHPort              uint              `mapstructure:"ssh_port"`
	RawSSHTimeout        string            `mapstructure:"ssh_timeout"`
	RawStateTimeout      string            `mapstructure:"state_timeout"`
	Tags                 []string          `mapstructure:"tags"`
	Zone                 string            `mapstructure:"zone"`
	// contains filtered or unexported fields
}

Config is the configuration structure for the GCE builder. It stores both the publicly settable state as well as the privately generated state of the config object.

func NewConfig

func NewConfig(raws ...interface{}) (*Config, []string, error)

type Driver

type Driver interface {
	// CreateImage creates an image with the given URL in Google Storage.
	CreateImage(name, description, url string) <-chan error

	// DeleteImage deletes the image with the given name.
	DeleteImage(name string) <-chan error

	// DeleteInstance deletes the given instance.
	DeleteInstance(zone, name string) (<-chan error, error)

	// GetNatIP gets the NAT IP address for the instance.
	GetNatIP(zone, name string) (string, error)

	// RunInstance takes the given config and launches an instance.
	RunInstance(*InstanceConfig) (<-chan error, error)

	// WaitForInstance waits for an instance to reach the given state.
	WaitForInstance(state, zone, name string) <-chan error
}

Driver is the interface that has to be implemented to communicate with GCE. The Driver interface exists mostly to allow a mock implementation to be used to test the steps.

func NewDriverGCE

func NewDriverGCE(ui packer.Ui, p string, a *accountFile, c *clientSecretsFile) (Driver, error)

type DriverMock

type DriverMock struct {
	CreateImageName  string
	CreateImageDesc  string
	CreateImageURL   string
	CreateImageErrCh <-chan error

	DeleteImageName  string
	DeleteImageErrCh <-chan error

	DeleteInstanceZone  string
	DeleteInstanceName  string
	DeleteInstanceErrCh <-chan error
	DeleteInstanceErr   error

	GetNatIPZone   string
	GetNatIPName   string
	GetNatIPResult string
	GetNatIPErr    error

	RunInstanceConfig *InstanceConfig
	RunInstanceErrCh  <-chan error
	RunInstanceErr    error

	WaitForInstanceState string
	WaitForInstanceZone  string
	WaitForInstanceName  string
	WaitForInstanceErrCh <-chan error
}

DriverMock is a Driver implementation that is a mocked out so that it can be used for tests.

func (*DriverMock) CreateImage

func (d *DriverMock) CreateImage(name, description, url string) <-chan error

func (*DriverMock) DeleteImage

func (d *DriverMock) DeleteImage(name string) <-chan error

func (*DriverMock) DeleteInstance

func (d *DriverMock) DeleteInstance(zone, name string) (<-chan error, error)

func (*DriverMock) GetNatIP

func (d *DriverMock) GetNatIP(zone, name string) (string, error)

func (*DriverMock) RunInstance

func (d *DriverMock) RunInstance(c *InstanceConfig) (<-chan error, error)

func (*DriverMock) WaitForInstance

func (d *DriverMock) WaitForInstance(state, zone, name string) <-chan error

type Image added in v0.7.0

type Image struct {
	Name      string
	ProjectId string
}

type InstanceConfig

type InstanceConfig struct {
	Description string
	DiskSizeGb  int64
	Image       Image
	MachineType string
	Metadata    map[string]string
	Name        string
	Network     string
	Tags        []string
	Zone        string
}

type StepCreateImage

type StepCreateImage int

StepCreateImage represents a Packer build step that creates GCE machine images.

func (*StepCreateImage) Cleanup

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

func (*StepCreateImage) Run

Run executes the Packer build step that creates a GCE machine image.

Currently the only way to create a GCE image is to run the gcimagebundle command on the running GCE instance.

type StepCreateInstance

type StepCreateInstance struct {
	Debug bool
	// contains filtered or unexported fields
}

StepCreateInstance represents a Packer build step that creates GCE instances.

func (*StepCreateInstance) Cleanup

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

Cleanup destroys the GCE instance created during the image creation process.

func (*StepCreateInstance) Run

Run executes the Packer build step that creates a GCE instance.

type StepCreateSSHKey

type StepCreateSSHKey struct {
	Debug        bool
	DebugKeyPath string
}

StepCreateSSHKey represents a Packer build step that generates SSH key pairs.

func (*StepCreateSSHKey) Cleanup

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

Nothing to clean up. SSH keys are associated with a single GCE instance.

func (*StepCreateSSHKey) Run

Run executes the Packer build step that generates SSH key pairs.

type StepInstanceInfo

type StepInstanceInfo struct {
	Debug bool
	// contains filtered or unexported fields
}

stepInstanceInfo represents a Packer build step that gathers GCE instance info.

func (*StepInstanceInfo) Cleanup

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

Cleanup.

func (*StepInstanceInfo) Run

Run executes the Packer build step that gathers GCE instance info.

type StepRegisterImage

type StepRegisterImage int

StepRegisterImage represents a Packer build step that registers GCE machine images.

func (*StepRegisterImage) Cleanup

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

Cleanup.

func (*StepRegisterImage) Run

Run executes the Packer build step that registers a GCE machine image.

type StepUpdateGcloud added in v0.7.0

type StepUpdateGcloud int

StepUpdateGcloud represents a Packer build step that updates the gsutil utility to the latest version available.

func (*StepUpdateGcloud) Cleanup added in v0.7.0

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

Cleanup.

func (*StepUpdateGcloud) Run added in v0.7.0

Run executes the Packer build step that updates the gsutil utility to the latest version available.

This step is required to prevent the image creation process from hanging; the image creation process utilizes the gcimagebundle cli tool which will prompt to update gsutil if a newer version is available.

type StepUploadImage

type StepUploadImage int

StepUploadImage represents a Packer build step that uploads GCE machine images.

func (*StepUploadImage) Cleanup

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

Cleanup.

func (*StepUploadImage) Run

Run executes the Packer build step that uploads a GCE machine image.

Jump to

Keyboard shortcuts

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