2013-12-13 00:38:34 -05:00
|
|
|
package googlecompute
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
type Driver interface {
|
2014-12-09 11:42:33 -05:00
|
|
|
// ImageExists returns true if the specified image exists. If an error
|
|
|
|
// occurs calling the API, this method returns false.
|
|
|
|
ImageExists(name string) bool
|
|
|
|
|
2014-11-24 11:36:14 -05:00
|
|
|
// CreateImage creates an image from the given disk in Google Compute
|
|
|
|
// Engine.
|
|
|
|
CreateImage(name, description, zone, disk string) <-chan error
|
2013-12-13 22:03:10 -05:00
|
|
|
|
2013-12-13 22:07:10 -05:00
|
|
|
// DeleteImage deletes the image with the given name.
|
|
|
|
DeleteImage(name string) <-chan error
|
|
|
|
|
2014-11-24 11:36:14 -05:00
|
|
|
// DeleteInstance deletes the given instance, keeping the boot disk.
|
2013-12-13 01:34:47 -05:00
|
|
|
DeleteInstance(zone, name string) (<-chan error, error)
|
|
|
|
|
2014-11-24 11:36:14 -05:00
|
|
|
// DeleteDisk deletes the disk with the given name.
|
|
|
|
DeleteDisk(zone, name string) (<-chan error, error)
|
|
|
|
|
2013-12-13 16:01:28 -05:00
|
|
|
// GetNatIP gets the NAT IP address for the instance.
|
|
|
|
GetNatIP(zone, name string) (string, error)
|
|
|
|
|
2015-05-29 17:50:11 -04:00
|
|
|
// GetInternalIP gets the GCE-internal IP address for the instance.
|
|
|
|
GetInternalIP(zone, name string) (string, error)
|
|
|
|
|
2013-12-13 00:38:34 -05:00
|
|
|
// RunInstance takes the given config and launches an instance.
|
|
|
|
RunInstance(*InstanceConfig) (<-chan error, error)
|
2013-12-13 16:01:28 -05:00
|
|
|
|
|
|
|
// WaitForInstance waits for an instance to reach the given state.
|
|
|
|
WaitForInstance(state, zone, name string) <-chan error
|
2013-12-13 00:38:34 -05:00
|
|
|
}
|
|
|
|
|
2014-08-20 13:20:28 -04:00
|
|
|
type Image struct {
|
|
|
|
Name string
|
|
|
|
ProjectId string
|
|
|
|
}
|
|
|
|
|
2013-12-13 00:38:34 -05:00
|
|
|
type InstanceConfig struct {
|
|
|
|
Description string
|
2014-08-07 15:34:08 -04:00
|
|
|
DiskSizeGb int64
|
2014-08-20 13:20:28 -04:00
|
|
|
Image Image
|
2013-12-13 00:38:34 -05:00
|
|
|
MachineType string
|
|
|
|
Metadata map[string]string
|
|
|
|
Name string
|
|
|
|
Network string
|
|
|
|
Tags []string
|
|
|
|
Zone string
|
|
|
|
}
|