Documentation ¶
Index ¶
- Constants
- Variables
- type Account
- type Disk
- type DiskType
- type Endpoint
- type Image
- type InstanceData
- type MachineType
- type Network
- type Project
- type Region
- type StorageDevice
- type Subnetwork
- type VM
- func (vm *VM) AddEndpoints() error
- func (vm *VM) AddNewDisks() ([]StorageDevice, error)
- func (vm *VM) CreateImage() error
- func (vm *VM) DeleteDisks() error
- func (vm *VM) DeleteImage() error
- func (vm *VM) DeleteVMDisks() error
- func (vm *VM) Destroy() error
- func (vm *VM) GetDiskTypeList() ([]DiskType, error)
- func (vm *VM) GetIPs() ([]net.IP, error)
- func (vm *VM) GetImageList() ([]Image, error)
- func (vm *VM) GetInstance() (*InstanceData, error)
- func (vm *VM) GetMachineTypeList() ([]MachineType, error)
- func (vm *VM) GetName() string
- func (vm *VM) GetNetworkList() ([]Network, error)
- func (vm *VM) GetRegionList() ([]Region, error)
- func (vm *VM) GetSSH(options ssh.Options) (ssh.Client, error)
- func (vm *VM) GetState() (string, error)
- func (vm *VM) GetSubnetworkList() ([]Subnetwork, error)
- func (vm *VM) GetZoneList() ([]Zone, error)
- func (vm *VM) Halt() error
- func (vm *VM) InsertSSHKey(publicKey string) error
- func (vm *VM) IsInstance() (bool, error)
- func (vm *VM) Provision() error
- func (vm *VM) RemoveEndpoints() error
- func (vm *VM) Reset() error
- func (vm *VM) Resume() error
- func (vm *VM) Start() error
- func (vm *VM) Suspend() error
- func (vm *VM) ValidateAuth() error
- type Zone
Constants ¶
const ( // PublicIP represents the index of the public IP address that GetIPs returns. PublicIP = 0 // PrivateIP represents the private IP address that GetIPs returns. PrivateIP = 1 // OperationTimeout represents Maximum time(Second) to wait for operation ready. OperationTimeout = 180 // DevicePathPrefix represents the prefix of the path given to the // disks attached to an instance. If a disk named "disk1" is attached // to an instance, it's path on the GCE instance becomes // "/dev/disk/by-id/google-disk1". This name can be used to reference // the device for mounting, resizing, and so on, from within the // instance. DevicePathPrefix = "/dev/disk/by-id/google-" )
Variables ¶
var SSHTimeout = 3 * time.Minute
SSHTimeout is the maximum time to wait before failing to GetSSH. This is not thread-safe.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { // AccountFile: Represents the JSON file required to authenticate a // Google cloud service account AccountFile string // Scopes: Represents access scopes with which API call is made Scopes []string // contains filtered or unexported fields }
Account represents a Google cloud account. It is used to make non VM related calls such as GetProjectList()
func (*Account) GetProjectList ¶
GetProjectList: Gets list of projects
type Disk ¶
type Disk struct { Name string DiskType string DiskSizeGb int AutoDelete bool // Auto delete disk Description string }
Disk represents the GCP Disk. See https://cloud.google.com/compute/docs/disks/?hl=en_US&_ga=1.115106433.702756738.1463769954
type DiskType ¶
type DiskType struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` ValidDiskSize string `json:"valid_size,omitempty"` DefaultDiskSizeGb int64 `json:"default_disk_size_gb,omitempty,string"` }
DiskType defines GCP disk type
type Endpoint ¶
type Endpoint struct { // Protocol can be one of the following well known protocol strings // (tcp, udp, icmp, esp, ah, sctp) which are supported by GCP Protocol string Ports []string }
Endpoint represents the protocol and ports configured in a firewall
type Image ¶
type Image struct { Id uint64 `json:"id,omitempty,string"` CreationTimestamp string `json:"creation_timestamp,omitempty"` // DeprecationStatus indicates whether the image is depcrecated. If the // image is not deprecated it will have an empty string. DeprecationStatus string `json:"deprecation_status,omitempty"` // DeprecationReplacement provides the url of the image which is a // replacement of this deprecated image. If this image is not deprecated // it's value will be an empty string. DeprecationReplacement string `json:"deprecation_replacement,omitempty"` Description string `json:"description,omitempty"` DiskSizeGb int64 `json:"disk_size_gb,omitempty,string"` Family string `json:"family,omitempty"` Name string `json:"name,omitempty"` Status string `json:"status,omitempty"` }
Image represents a GCE image
type InstanceData ¶
type InstanceData struct { Name string `json:"name,omitempty"` Id uint64 `json:"id,omitempty,string"` Status string `json:"status,omitempty"` CreationTimestamp string `json:"creation_timestamp,omitempty"` PrivateIpv4 string `json:"private_ipv4,omitempty"` PublicIpv4 string `json:"public_ipv4,omitempty"` Volumes []StorageDevice `json:"volumes,omitempty"` }
InstanceData represents the details of a launched GCE instance
type MachineType ¶
type MachineType struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` GuestCpus int64 `json:"cpus,omitempty"` MemoryMb int64 `json:"memory_mb,omitempty"` // Maximum persistent disks allowed MaximumPersistentDisks int64 `json:"max_persistent_disks,omitempty"` // Maximum total persistent disks size (GB) allowed MaximumPersistentDisksSizeGb int64 `json:"max_persistent_disks_size_gb,omitempty,string"` }
MachineType defines GCP machine type (aka flavors)
type Network ¶
type Network struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Id uint64 `json:"id,omitempty,string"` AutoCreateSubnetworks *bool `json:"auto_create_subnetworks,omitempty"` IPv4Range string `json:"ipv4_range,omitempty"` CreationTimestamp string `json:"creation_timestamp,omitempty"` Subnetworks []string `json:"subnetworks,omitempty"` }
Network defines a VPC network in GCP
type Project ¶
type Project struct { // Name represents project name Name string `json:"name,omitempty"` // ProjectID represents the unique, user-assigned ID of the project ProjectID string `json:"project_id,omitempty"` // ProjectNumber represents the google-assigned unique project number ProjectNumber int64 `json:"project_number,omitempty,string"` // LifecycleState is a read-only field giving state of the project LifecycleState string `json:"lifecycle_state,omitempty"` // CreateTime gives the project creation time CreateTime string `json:"create_time,omitempty"` }
Project represents a Google cloud project
type Region ¶
type Region struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Zones []string `json:"zones,omitempty"` Status string `json:"status,omitempty"` }
Region represents a GCP region
type StorageDevice ¶
type StorageDevice struct { Name string `json:"name,omitempty"` DevicePath string `json:"device_path,omitempty"` Boot *bool `json:"boot,omitempty"` AutoDelete *bool `json:"auto_delete,omitempty"` // Interface specifies the disk interface to use for attaching this disk, which // is either SCSI or NVME. The default is SCSI. Persistent disks must // always use SCSI and the request will fail if you attempt to attach // a persistent disk in any other format than SCSI. Local SSDs can use // either NVME or SCSI. Interface string `json:"interface,omitempty"` }
StorageDevice represents a disk attached to a GCE instance
type Subnetwork ¶
type Subnetwork struct { Name string `json:"name,omitempty"` Description string `json:"description,omitempty"` Id uint64 `json:"id,omitempty,string"` CreationTimestamp string `json:"creation_timestamp,omitempty"` GatewayAddress string `json:"gateway_address,omitempty"` Network string `json:"network,omitempty"` Region string `json:"region,omitempty"` IpCidrRange string `json:"ipv4_range,omitempty"` }
Subnetwork represents a GCP subnetwork in a region
type VM ¶
type VM struct { Name string Description string Zone string MachineType string Preemptible bool // Preemptible instances will be terminates after they run for 24 hours. SourceImage string //Required ImageProjects []string //Required Disks []Disk // At least one disk is required, the first one is booted device Network string Subnetwork string UseInternalIP bool PrivateIPAddress string Scopes []string //Access scopes Project string //GCE project Tags []string //Instance Tags AccountFile string SSHCreds ssh.Credentials SSHPublicKey string Firewall string // required when modifying firewall rules Endpoints []Endpoint // RawDiskSource is the full Google Cloud Storage URL where the raw disk // image is stored. It is required only for creating a new image from // a raw disk. RawDiskSource string // contains filtered or unexported fields }
VM defines a GCE virtual machine.
func (*VM) AddEndpoints ¶
AddEndpoints adds new endpoints to the given firewall
func (*VM) AddNewDisks ¶
func (vm *VM) AddNewDisks() ([]StorageDevice, error)
AddNewDisks create new disks as per given specifications and then attaches to the given instance.
func (*VM) CreateImage ¶
CreateImage: Creates a new image from raw disk
func (*VM) DeleteDisks ¶
DeleteDisks cleans up all the disks attached to the GCE instance.
func (*VM) DeleteVMDisks ¶
DeleteVMDisk detaches the given disks from the instance and deletes them
func (*VM) GetDiskTypeList ¶
GetDiskTypeList gets the list of available disk types
func (*VM) GetImageList ¶
GetImageList lists images available in given projects
func (*VM) GetInstance ¶
func (vm *VM) GetInstance() (*InstanceData, error)
GetInstance gets instance details
func (*VM) GetMachineTypeList ¶
func (vm *VM) GetMachineTypeList() ([]MachineType, error)
GetMachineTypeList gets the list of available machine types (aka flavors)
func (*VM) GetNetworkList ¶
GetNetworkList gets the list of VPC networks
func (*VM) GetRegionList ¶
GetRegionList gets the list of available regions
func (*VM) GetSubnetworkList ¶
func (vm *VM) GetSubnetworkList() ([]Subnetwork, error)
GetSubnetworkList gets the list of subnetworks
func (*VM) GetZoneList ¶
GetZoneList gets the list of available zones
func (*VM) InsertSSHKey ¶
InsertSSHKey uploads new ssh key into the GCE instance.
func (*VM) IsInstance ¶
IsInstance checks if the given instance is present in GCP. Returns true if instance is available else false.
func (*VM) Provision ¶
Provision creates a virtual machine on GCE. It returns an error if there was a problem during creation.
func (*VM) RemoveEndpoints ¶
RemoveEndpoints removes given endpoints from the given firewall
func (*VM) ValidateAuth ¶
ValidateAuth: returns error if credentials are incorrect