vm

package
v0.0.0-...-1f20b29 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2018 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrBadNetwork   = errors.New("could not determine network information")
	ErrInvalidName  = errors.New("invalid VM name")
	ErrNoExpiration = errors.New("could not determine expiration")
)

Error values for VM.Error

View Source
var Providers = map[string]Provider{}

Providers contains all known Provider instances. This is initialized by subpackage init() functions.

Functions

func AllProviderNames

func AllProviderNames() []string

AllProviderNames returns the names of all known vm Providers. This is useful with the ProvidersSequential or ProvidersParallel methods.

func FanOut

func FanOut(list List, action func(Provider, List) error) error

FanOut collates a collection of VMs by their provider and invoke the callbacks in parallel.

func FindActiveAccounts

func FindActiveAccounts() (map[string]string, error)

FindActiveAccount queries the active providers for the name of the user account.

func ForProvider

func ForProvider(named string, action func(Provider) error) error

ForProvider resolves the Provider with the given name and executes the action.

func ProvidersParallel

func ProvidersParallel(named []string, action func(Provider) error) error

ProvidersParallel concurrently executes actions for each named Provider.

func ProvidersSequential

func ProvidersSequential(named []string, action func(Provider) error) error

ProvidersSequential sequentially executes actions for each named Provider.

Types

type CreateOpts

type CreateOpts struct {
	UseLocalSSD    bool
	Lifetime       time.Duration
	GeoDistributed bool
	VMProviders    []string
}

CreateOpts is the set of options when creating VMs.

type List

type List []VM

func (List) Len

func (vl List) Len() int

func (List) Less

func (vl List) Less(i, j int) bool

func (List) Names

func (vl List) Names() []string

Extract all VM.Name entries from the List

func (List) ProviderIDs

func (vl List) ProviderIDs() []string

ProviderIDs extracts all ProviderID values from the List.

func (List) Swap

func (vl List) Swap(i, j int)

func (List) Zones

func (vl List) Zones() []string

Extract all VM.Zone entries from the List

type Provider

type Provider interface {
	CleanSSH() error
	ConfigSSH() error
	Create(names []string, opts CreateOpts) error
	Delete(vms List) error
	Extend(vms List, lifetime time.Duration) error
	// Return the account name associated with the provider
	FindActiveAccount() (string, error)
	// Returns a hook point for extending top-level roachprod tooling flags
	Flags() ProviderFlags
	List() (List, error)
	// The name of the Provider, which will also surface in the top-level Providers map.
	Name() string
}

A Provider is a source of virtual machines running on some hosting platform.

type ProviderFlags

type ProviderFlags interface {
	// Configures a FlagSet with any options relevant to the `create` command.
	ConfigureCreateFlags(*pflag.FlagSet)
	// Configures a FlagSet with any options relevant to cluster manipulation
	// commands (`create`, `destroy`, `list`, `sync` and `gc`).
	ConfigureClusterFlags(*pflag.FlagSet)
}

A hook point for Providers to supply additional, provider-specific flags to various roachprod commands. In general, the flags should be prefixed with the provider's name to prevent collision between similar options.

If a new command is added (perhaps `roachprod enlarge`) that needs additional provider- specific flags, add a similarly-named method `ConfigureEnlargeFlags` to mix in the additional flags.

type VM

type VM struct {
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"created_at"`
	// If non-empty, indicates that some or all of the data in the VM instance
	// is not present or otherwise invalid.
	Errors   []error       `json:"errors"`
	Lifetime time.Duration `json:"lifetime"`
	// The provider-internal DNS name for the VM instance
	DNS string `json:"dns"`
	// The name of the cloud provider that hosts the VM instance
	Provider string `json:"provider"`
	// The provider-specific id for the instance.  This may or may not be the same as Name, depending
	// on whether or not the cloud provider automatically assigns VM identifiers.
	ProviderID string `json:"provider_id"`
	PrivateIP  string `json:"private_ip"`
	PublicIP   string `json:"public_ip"`
	// The username that should be used to connect to the VM.
	RemoteUser string `json:"remote_user"`
	// The VPC value defines an equivalency set for VMs that can route
	// to one another via private IP addresses.  We use this later on
	// when determining whether or not cluster member should advertise
	// their public or private IP.
	VPC         string `json:"vpc"`
	MachineType string `json:"machine_type"`
	Zone        string `json:"zone"`
}

A VM is an abstract representation of a specific machine instance. This type is used across the various cloud providers supported by roachprod.

func (*VM) IsLocal

func (vm *VM) IsLocal() bool

IsLocal returns true if the VM represents the local host.

func (*VM) Locality

func (vm *VM) Locality() string

Locality returns the cloud, region, and zone for the VM. We want to include the cloud, since GCE and AWS use similarly-named regions (e.g. us-east-1)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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