2013-12-12 21:38:34 -08: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 08:42:33 -08: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 08:36:14 -08:00
|
|
|
// CreateImage creates an image from the given disk in Google Compute
|
|
|
|
// Engine.
|
|
|
|
CreateImage(name, description, zone, disk string) <-chan error
|
2013-12-13 19:03:10 -08:00
|
|
|
|
2013-12-13 19:07:10 -08:00
|
|
|
// DeleteImage deletes the image with the given name.
|
|
|
|
DeleteImage(name string) <-chan error
|
|
|
|
|
2014-11-24 08:36:14 -08:00
|
|
|
// DeleteInstance deletes the given instance, keeping the boot disk.
|
2013-12-12 22:34:47 -08:00
|
|
|
DeleteInstance(zone, name string) (<-chan error, error)
|
|
|
|
|
2014-11-24 08:36:14 -08:00
|
|
|
// DeleteDisk deletes the disk with the given name.
|
|
|
|
DeleteDisk(zone, name string) (<-chan error, error)
|
|
|
|
|
2013-12-13 13:01:28 -08:00
|
|
|
// GetNatIP gets the NAT IP address for the instance.
|
|
|
|
GetNatIP(zone, name string) (string, error)
|
|
|
|
|
2015-05-29 14:50:11 -07:00
|
|
|
// GetInternalIP gets the GCE-internal IP address for the instance.
|
|
|
|
GetInternalIP(zone, name string) (string, error)
|
|
|
|
|
2013-12-12 21:38:34 -08:00
|
|
|
// RunInstance takes the given config and launches an instance.
|
|
|
|
RunInstance(*InstanceConfig) (<-chan error, error)
|
2013-12-13 13:01:28 -08:00
|
|
|
|
|
|
|
// WaitForInstance waits for an instance to reach the given state.
|
|
|
|
WaitForInstance(state, zone, name string) <-chan error
|
2013-12-12 21:38:34 -08:00
|
|
|
}
|
|
|
|
|
2014-08-20 10:20:28 -07:00
|
|
|
type Image struct {
|
|
|
|
Name string
|
|
|
|
ProjectId string
|
|
|
|
}
|
|
|
|
|
2013-12-12 21:38:34 -08:00
|
|
|
type InstanceConfig struct {
|
|
|
|
Description string
|
2014-08-07 15:34:08 -04:00
|
|
|
DiskSizeGb int64
|
2014-08-20 10:20:28 -07:00
|
|
|
Image Image
|
2013-12-12 21:38:34 -08:00
|
|
|
MachineType string
|
|
|
|
Metadata map[string]string
|
|
|
|
Name string
|
|
|
|
Network string
|
2016-02-11 17:31:46 +13:00
|
|
|
Subnetwork string
|
2015-12-24 09:19:29 -06:00
|
|
|
Address string
|
2015-12-05 05:13:35 +09:00
|
|
|
Preemptible bool
|
2013-12-12 21:38:34 -08:00
|
|
|
Tags []string
|
2016-02-11 17:31:46 +13:00
|
|
|
Region string
|
2013-12-12 21:38:34 -08:00
|
|
|
Zone string
|
|
|
|
}
|