gce

package
v0.0.0-...-6152d30 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2016 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package gce communicates with compute engine

Index

Constants

View Source
const (
	// VMCreationTimeout is timeout of VM creation to running
	VMCreationTimeout = 180 * time.Second
	// VMStoppingTimeout is timeout of VM running to stopped
	VMStoppingTimeout = 180 * time.Second
	// DiskCreationTimeout is timeout of disk creation
	DiskCreationTimeout = 180 * time.Second
	// VMSetMachineTypeTimeout is timeout of set machine type
	VMSetMachineTypeTimeout = 180 * time.Second
	// InstanceTemplateCreationTimeout is timeout of creating instance template
	InstanceTemplateCreationTimeout = 180 * time.Second

	// VMStatusTerminated ...
	VMStatusTerminated = "TERMINATED"
	// VMStatusRunning ...
	VMStatusRunning = "RUNNING"
)

Variables

This section is empty.

Functions

func BuildGceService

func BuildGceService(serviceEmail string, key []byte) (*compute.Service, error)

BuildGceService builds the singlton service for Manager

Types

type BySnapshotName

type BySnapshotName []*compute.Snapshot

BySnapshotName is used to sort all gce snapshot by name

func (BySnapshotName) Len

func (a BySnapshotName) Len() int

func (BySnapshotName) Less

func (a BySnapshotName) Less(i, j int) bool

func (BySnapshotName) Swap

func (a BySnapshotName) Swap(i, j int)

type Manager

type Manager struct {
	Service *compute.Service `inject:""`
}

Manager is for low level communication with Google Compute Engine.

func (*Manager) AddInstancesIntoInstanceGroup

func (m *Manager) AddInstancesIntoInstanceGroup(
	projectID, zone, instanceGroupName string, instances []string) (
	*compute.Operation, error)

AddInstancesIntoInstanceGroup adds instances into some instance group https://godoc.org/google.golang.org/api/compute/v1#InstanceGroupsService.AddInstances

func (*Manager) AddInstancesIntoTargetPool

func (m *Manager) AddInstancesIntoTargetPool(
	projectID, region, targetPool string, instances []string) (*compute.Operation, error)

AddInstancesIntoTargetPool adds instances into the target pool of load balancer https://godoc.org/google.golang.org/api/compute/v1#TargetPoolsService.AddInstance

func (*Manager) AttachTags

func (m *Manager) AttachTags(projectID, zone, vmName string, addedTags []string) (*compute.Operation, error)

AttachTags attaches tags onto VM.

func (*Manager) DeleteDisk

func (m *Manager) DeleteDisk(projectID, zone, diskName string) error

DeleteDisk deletes disk. https://godoc.org/google.golang.org/api/compute/v1#DisksService.Delete

func (*Manager) DeleteInstanceTemplate

func (m *Manager) DeleteInstanceTemplate(projectID, templateName string) (*compute.Operation, error)

DeleteInstanceTemplate ... https://godoc.org/google.golang.org/api/compute/v1#InstanceTemplatesService.Delete

func (*Manager) DeleteVM

func (m *Manager) DeleteVM(projectID, zone, vmName string) error

DeleteVM deletes a VM. https://godoc.org/google.golang.org/api/compute/v1#InstancesService.Delete

func (*Manager) DetachTags

func (m *Manager) DetachTags(projectID, zone, vmName string, removedTages []string) (*compute.Operation, error)

DetachTags detaches tags from VM.

func (*Manager) GetDisk

func (m *Manager) GetDisk(projectID, zone, diskName string) (*compute.Disk, error)

GetDisk gets disk. https://godoc.org/google.golang.org/api/compute/v1#DisksService.Get

func (*Manager) GetInstanceGroup

func (m *Manager) GetInstanceGroup(projectID, zone, instanceGroupName string) (
	*compute.InstanceGroup, error)

GetInstanceGroup - https://godoc.org/google.golang.org/api/compute/v1#InstanceGroupsService.Get

func (*Manager) GetInstanceGroupManager

func (m *Manager) GetInstanceGroupManager(projectID, zone, instanceGroupManagerName string) (
	*compute.InstanceGroupManager, error)

GetInstanceGroupManager ... https://godoc.org/google.golang.org/api/compute/v1#InstanceGroupManagersService.Get

func (*Manager) GetInstanceTemplate

func (m *Manager) GetInstanceTemplate(projectID, templateName string) (*compute.InstanceTemplate, error)

GetInstanceTemplate ... https://godoc.org/google.golang.org/api/compute/v1#InstanceTemplatesService.Get

func (*Manager) GetLatestSnapshot

func (m *Manager) GetLatestSnapshot(prefix string, snapshots []*compute.Snapshot) (*compute.Snapshot, error)

GetLatestSnapshot gets latest snapshot with specified prefix in its name

func (*Manager) GetNatIP

func (m *Manager) GetNatIP(vm *compute.Instance) string

GetNatIP gets NAT IP address from VM

func (*Manager) GetNetworkIP

func (m *Manager) GetNetworkIP(vm *compute.Instance) string

GetNetworkIP gets internal IP address from VM

func (*Manager) GetSnapshot

func (m *Manager) GetSnapshot(projectID, snapshot string) (*compute.Snapshot, error)

GetSnapshot gets the specific snapshot https://godoc.org/google.golang.org/api/compute/v1#SnapshotsService.Get

func (*Manager) GetSnapshotOfDisk

func (m *Manager) GetSnapshotOfDisk(disk *compute.Disk) string

GetSnapshotOfDisk gets the snapshot name of the disk

func (*Manager) GetTargetPool

func (m *Manager) GetTargetPool(projectID, region, targetPool string) (*compute.TargetPool, error)

GetTargetPool - https://godoc.org/google.golang.org/api/compute/v1#TargetPoolsService.Get

func (*Manager) GetVM

func (m *Manager) GetVM(projectID, zone, vmName string) (*compute.Instance, error)

GetVM gets a VM. If VM not existed, return nil. https://godoc.org/google.golang.org/api/compute/v1#InstancesService.Get

func (*Manager) InitVMFromTemplate

func (m *Manager) InitVMFromTemplate(templateFile []byte, zone string) (*compute.Instance, error)

InitVMFromTemplate builds the sample VM from template

func (*Manager) ListDisks

func (m *Manager) ListDisks(projectID, zone string) (*compute.DiskList, error)

ListDisks lists all disks. https://godoc.org/google.golang.org/api/compute/v1#DisksService.List

func (*Manager) ListImages

func (m *Manager) ListImages(projectID string) (*compute.ImageList, error)

ListImages lists all images. https://godoc.org/google.golang.org/api/compute/v1#ImagesService.List

func (*Manager) ListInstanceGroupManagers

func (m *Manager) ListInstanceGroupManagers(projectID, zone string) (
	*compute.InstanceGroupManagerList, error)

ListInstanceGroupManagers ... https://godoc.org/google.golang.org/api/compute/v1#InstanceGroupManagersService.List

func (*Manager) ListInstanceGroupsByZone

func (m *Manager) ListInstanceGroupsByZone(projectID, zone string, isPrefix func(string) bool) []string

ListInstanceGroupsByZone lists all instance groups in specified zone with filter condition https://godoc.org/google.golang.org/api/compute/v1#InstanceGroupsService.List

func (*Manager) ListInstanceTemplates

func (m *Manager) ListInstanceTemplates(projectID, filter string) ([]*compute.InstanceTemplate, error)

ListInstanceTemplates lists all instance templates which satisfies filter condition https://godoc.org/google.golang.org/api/compute/v1#InstanceTemplatesService.List

func (*Manager) ListInstancesInInstanceGroup

func (m *Manager) ListInstancesInInstanceGroup(projectID, zone, instanceGroupName string) ([]string, error)

ListInstancesInInstanceGroup lists all instances under some instance group https://godoc.org/google.golang.org/api/compute/v1#InstanceGroupsService.ListInstances

func (*Manager) ListSnapshots

func (m *Manager) ListSnapshots(projectID string) ([]*compute.Snapshot, error)

ListSnapshots gets all snapshots of the project. https://godoc.org/google.golang.org/api/compute/v1#SnapshotsService.List

func (*Manager) ListVMs

func (m *Manager) ListVMs(projectID, zone string) (*compute.InstanceList, error)

ListVMs lists all VMs. https://godoc.org/google.golang.org/api/compute/v1#InstancesService.List

func (*Manager) ListVMsWithFilter

func (m *Manager) ListVMsWithFilter(projectID, zone, filter string) (*compute.InstanceList, error)

ListVMsWithFilter lists VMs with filter. https://godoc.org/google.golang.org/api/compute/v1#InstancesService.List

func (*Manager) NewDisk

func (m *Manager) NewDisk(projectID, zone, name, sourceSnapshot string, sizeGb int64) error

NewDisk creates a new disk by specified snapshot. https://godoc.org/google.golang.org/api/compute/v1#DisksService.Insert

func (*Manager) NewInstanceTemplate

func (m *Manager) NewInstanceTemplate(projectID string, template *compute.InstanceTemplate) error

NewInstanceTemplate ... https://godoc.org/google.golang.org/api/compute/v1#InstanceTemplatesService.Insert

func (*Manager) NewVM

func (m *Manager) NewVM(projectID, zone string, vm *compute.Instance) error

NewVM creates a new VM. This method blocks till the status of created VM to be RUNNING or will be timeout if it takes over `VMCreationTimeout`. https://godoc.org/google.golang.org/api/compute/v1#InstancesService.Insert

func (*Manager) PatchInstanceMachineType

func (m *Manager) PatchInstanceMachineType(machineTypeURI, targetType string) string

PatchInstanceMachineType replaces the last part of machineTypeURI with targetType

func (*Manager) ProbeDiskCreation

func (m *Manager) ProbeDiskCreation(projectID, zone, diskName string, observer chan<- bool)

ProbeDiskCreation probes the disk status till its status is READY or timeout

func (*Manager) ProbeInstanceTemplateCreation

func (m *Manager) ProbeInstanceTemplateCreation(projectID, templateName string, observer chan<- bool)

ProbeInstanceTemplateCreation ...

func (*Manager) ProbeVMMachineTypeChanged

func (m *Manager) ProbeVMMachineTypeChanged(
	projectID, zone, vmName, machineType string, observer chan<- bool)

ProbeVMMachineTypeChanged probes if the machineType of VM has been changed

func (*Manager) ProbeVMRunning

func (m *Manager) ProbeVMRunning(projectID, zone, vmName string, observer chan<- bool)

ProbeVMRunning probes the VM status till its status is RUNNING or timeout

func (*Manager) ProbeVMStopped

func (m *Manager) ProbeVMStopped(projectID, zone, vmName string, observer chan<- bool)

ProbeVMStopped probes the instance status till its status is Stopping or timeout

func (*Manager) RemoveInstancesFromTargetPool

func (m *Manager) RemoveInstancesFromTargetPool(
	projectID, region, targetPool string, instances []string) (*compute.Operation, error)

RemoveInstancesFromTargetPool removes instances from the target pool of load balancer https://godoc.org/google.golang.org/api/compute/v1#TargetPoolsService.RemoveInstance

func (*Manager) RemoveInstancesIntoInstanceGroup

func (m *Manager) RemoveInstancesIntoInstanceGroup(
	projectID, zone, instanceGroupName string, instances []string) (
	*compute.Operation, error)

RemoveInstancesIntoInstanceGroup adds instances into some instance group https://godoc.org/google.golang.org/api/compute/v1#InstanceGroupsService.RemoveInstances

func (*Manager) ResetInstance

func (m *Manager) ResetInstance(projectID, zone, vmName string) (*compute.Operation, error)

ResetInstance resets a instance. https://godoc.org/google.golang.org/api/compute/v1#InstancesService.Reset

func (*Manager) SetInstanceTemplate

func (m *Manager) SetInstanceTemplate(projectID, zone, instanceGroupManager, instanceTemplate string) error

SetInstanceTemplate ... https://godoc.org/google.golang.org/api/compute/v1#InstanceGroupManagersService.SetInstanceTemplate

func (*Manager) SetMachineType

func (m *Manager) SetMachineType(projectID, zone, vmName, machineType string) error

SetMachineType changes the machine type for a stopped instance to the machine type specified in the request. https://godoc.org/google.golang.org/api/compute/v1#InstancesService.SetMachineType

func (*Manager) StartVM

func (m *Manager) StartVM(projectID, zone, vmName string, vcc VMConditionChecker) (*compute.Operation, error)

StartVM starts a VM. parameter `vcc` is the checker function to check if the VM is successfully started. https://godoc.org/google.golang.org/api/compute/v1#InstancesService.Start

func (*Manager) StopVM

func (m *Manager) StopVM(projectID, zone, vmName string, vcc VMConditionChecker) (*compute.Operation, error)

StopVM stops a VM. parameter `vcc` is the checker function to check if the VM is successfully stopped. https://godoc.org/google.golang.org/api/compute/v1#InstancesService.Stop

type VMConditionChecker

type VMConditionChecker func(projectID, zone, instanceName string) (bool, error)

VMConditionChecker return a bool value by checking condition inside VM

Jump to

Keyboard shortcuts

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