hostProvider

package
v0.0.0-...-85d2ec5 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2016 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type GcloudAccessConfig

type GcloudAccessConfig struct {
	Kind       string `json:"kind"`
	AccessType string `json:"type"`
	Name       string `json:"name"`
	NatIP      string `json:"natIP"`
}

GcloudAccessConfig is a nested struct for network access data

type GcloudDisk

type GcloudDisk struct {
	Kind             string `json:"kind"`
	Index            int    `json:"index"`
	DiskType         string `json:"type"`
	Mode             string `json:"mode"`
	Source           string `json:"source"`
	DeviceName       string `json:"deviceName"`
	Boot             bool   `json:"boot"`
	InitializeParams struct {
		DiskName    string `json:"diskName"`
		SourceImage string `json:"sourceImage"`
		DiskSizeGb  uint64 `json:"diskSizeGb"`
		DiskType    string `json:"diskType"`
	} `json:"initializeParams"`
	AutoDelete    bool     `json:"autoDelete"`
	Licenses      []string `json:"licenses"`
	DiskInterface string   `json:"interface"`
}

GcloudDisk is a struct for data about an instances disk(s)

type GcloudHost

type GcloudHost struct {
	HostProvider
	Project   string
	Zones     []string
	Instances []*GcloudInstance
	Client    *http.Client
}

GcloudHost is the HostProvider struct for gcloud, used to control instances on GCE

func NewGcloud

func NewGcloud(p, jsonFile string) *GcloudHost

NewGcloud returns a new GCE HostProvider

func (GcloudHost) CreateServer

func (g GcloudHost) CreateServer(namespace, zone, name, machineType, sourceImage, source string) (Instance, error)

CreateServer will send a POST to the GCE api to create an instance

func (GcloudHost) DeleteServer

func (g GcloudHost) DeleteServer(namespace, zone, name string) error

DeleteServer will send GCE a DELETE to delete a specific instance

func (GcloudHost) GetServer

func (g GcloudHost) GetServer(project, zone, name string) (Instance, error)

GetServer returns a specific server on GCE

func (GcloudHost) GetServers

func (g GcloudHost) GetServers(namespace string) ([]Instance, error)

GetServers returns a slice of servers in GCE

type GcloudInstance

type GcloudInstance struct {
	Instance
	Kind              string `json:"kind"`
	ID                uint64 `json:"id"`
	CreationTimestamp string `json:"creationTimestamp"`
	Zone              string `json:"zone"`
	Status            string `json:"status"`
	StatusMessage     string `json:"statusMessage"`
	Name              string `json:"name"`
	Description       string `json:"description"`
	Tags              struct {
		Items       []string `json:"items"`
		Fingerprint []byte   `json:"fingerprint"`
	} `json:"tags"`
	MachineType       string                   `json:"machineType"`
	CanIPForward      bool                     `json:"canIpForward"`
	NetworkInterfaces []GcloudNetworkInterface `json:"networkInterfaces"`
	Disks             []GcloudDisk             `json:"disks"`
	Metadata          struct {
		Kind        string `json:"kind"`
		Fingerprint []byte `json:"fingerPrint"`
		Items       []struct {
			Key   string `json:"key"`
			Value string `json:"value"`
		} `json:"items"`
	} `json:"metaData"`
	ServiceAccounts []GcloudServiceAccounts `json:"serviceAccounts"`
	SelfLink        string                  `json:"selfLink"`
	Scheduling      struct {
		OnHostMaintenance string `json:"onHostMaintenance"`
		AutomaticRestart  bool   `json:"automaticRestart"`
		Preemptible       bool   `json:"preemptible"`
	} `json:"scheduling"`
	CPUPlatform string `json:"cpuPlatform"`
}

GcloudInstance is the outer most struct for GCE instance data

func NewGCEInstance

func NewGCEInstance() *GcloudInstance

NewGCEInstance returns a new GceInstance struct

func (GcloudInstance) GetInternalIP

func (g GcloudInstance) GetInternalIP() string

GetInternalIP returns the internal IP of its instance

type GcloudNetworkInterface

type GcloudNetworkInterface struct {
	Network       string               `json:"network"`
	NetworkIP     string               `json:"networkIP"`
	Name          string               `json:"name"`
	AccessConfigs []GcloudAccessConfig `json:"accessConfigs"`
}

GcloudNetworkInterface is a nested struct for network access data

type GcloudServiceAccounts

type GcloudServiceAccounts struct {
	Email  string   `json:"email"`
	Scopes []string `json:"scopes"`
}

GcloudServiceAccounts is a struct for GCE service account data

type HostProvider

type HostProvider interface {
	// GetServers returns a slice of instances
	GetServers(namespace string) ([]Instance, error)
	// GetServer returns a specific instance
	GetServer(project, zone, name string) (Instance, error)
	// CreateServer creates an instance for the platform
	CreateServer(namespace, zone, name, machineType, sourceImage, source string) (Instance, error)
	// DeleteServer deletes an instance for the platform
	DeleteServer(namespace, zone, name string) error
}

HostProvider is the interface for HostProviders for each platform to control instances on the platform

type Instance

type Instance interface {
	// GetInternalIP returns a string of the instance's internal IP
	GetInternalIP() string
}

Instance is an interface for a platform's instances

type InstanceTemplate

type InstanceTemplate struct {
	Name        string `json:"name"`
	MachineType string `json:"machineType"`
	SourceImage string `json:"sourceImage"`
	Source      string `json:"source"`
}

InstanceTemplate is a struct for request data to create a server

type LocalHost

type LocalHost struct {
	HostProvider
	Instances []Instance
}

LocalHost controls Instances for the "local" platform

func NewLocal

func NewLocal() *LocalHost

NewLocal returns a new LocalHost struct

func (LocalHost) CreateServer

func (l LocalHost) CreateServer(namespace, zone, name, machineType, sourceImage, source string) (Instance, error)

CreateServer creates a new server

func (LocalHost) DeleteServer

func (l LocalHost) DeleteServer(namespace, zone, name string) error

DeleteServer will delete a registered server i.e. kill a process

func (LocalHost) GetServer

func (l LocalHost) GetServer(project, zone, name string) (Instance, error)

GetServer returns a specific server/process

func (LocalHost) GetServers

func (l LocalHost) GetServers(namespace string) ([]Instance, error)

GetServers returns all local servers, i.e. registered process

type LocalInstance

type LocalInstance struct {
	Instance
	Process     string
	ProcessPort int
	Name        string
	IP          string
	Zone        string
}

LocalInstance is an instance struct for the "local" platform

Jump to

Keyboard shortcuts

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