core

package
v0.2.10 Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetPingTime added in v0.2.7

func GetPingTime(ipAddress string) (pingTime int64, err error)

GetPingTime will do a ping test to the given ip address

func GetPingTimes added in v0.2.9

func GetPingTimes(ipAddressList []IPPingTime) (closestRegion string, err error)

GetPingTimesForArray will ping all ips/hosts and return the ID of the closest

Types

type DNSProvider

type DNSProvider interface {
	Init() bool
	GetHostRecord(host string) *HostInfo
	UpdateHostRecord(*HostInfo) error
	DeleteHostRecord(*HostInfo) error
}

DNSProvider is the interface all DNS providers need to follow

type HostInfo

type HostInfo struct {
	Name string // hostname
	ID   string // assigned by dns provider
	IP   string // current IP address assigned to this host
}

HostInfo has DNS details of a host

type IPPingTime added in v0.2.9

type IPPingTime struct {
	ID      string // id to identify what ip is associated with (normally region id)
	Address string // ip address or hostname that we can use for ping test
	Time    int    // ping time for given ip address (in msec)
}

type ImageInfo

type ImageInfo struct {
	ID            int      `json:"id"`
	Name          string   `json:"name"`
	Type          string   `json:"type"`
	Distrubution  string   `json:"distribution"`
	Slug          string   `json:"slug"`    // N/A if status is 'retired'
	Public        bool     `json:"public"`  // N/A if status is 'retired'
	Regions       []string `json:"regions"` // N/A if status is 'retired'
	MinDiskSize   int      `json:"min_disk_size"`
	SizeGigabytes float64  `json:"size_gigabytes"`
	CreatedAt     string   `json:"created_at"`
	Description   string   `json:"description"`
	Status        string   `json:"status"`
}

ImageInfo contains details about a disk image

type NetworkInfo

type NetworkInfo struct {
	V4Info []V4NetworkInfo `json:"v4,omitempty"`
	V6Info []V6NetworkInfo `json:"v6,omitempty"`
}

NetworkInfo has info about the networks a VM has

type PingTime added in v0.2.7

type PingTime struct {
	Name      string // name (optional) associated with the ip address
	IPAddress string // address to test
	Result    int64  // ping time in mSec
}

PingTime contains results of ping test to ip address

type RegionInfo

type RegionInfo struct {
	Name      string   `json:"name"`
	Slug      string   `json:"slug"`
	Available bool     `json:"available"`
	Country   string   `json:"country"`
	State     string   `json:"State"`
	Sizes     []string `json:"sizes"`
	Features  []string `json:"features"`
}

RegionInfo has details about a given datacenter/region

type Regions

type Regions interface {
	GetList() ([]RegionInfo, error)
	GetClosestByPing() ([]RegionInfo, error)
	GetClosestByLatLong(lat float32, long float32) ([]RegionInfo, error)
	GetClosestByCountry(country string) ([]RegionInfo, error)
}

Regions has details about all the regions a provider supports

type SSHKey added in v0.2.7

type SSHKey struct {
	Name      string
	PublicKey ssh.PublicKey
}

SSHKey has details of an ssh key

func (*SSHKey) Fingerprint added in v0.2.7

func (s *SSHKey) Fingerprint() string

Fingerprint for the given ssh key

func (*SSHKey) GenerateNewKey added in v0.2.10

func (s *SSHKey) GenerateNewKey(publicKeyPath string) error

generate a new ssh key

func (*SSHKey) GetPublicKey added in v0.2.7

func (s *SSHKey) GetPublicKey() string

GetPublicKey will return the string form of the public key

func (*SSHKey) LoadPublicKey added in v0.2.7

func (s *SSHKey) LoadPublicKey(filename string) error

LoadPublicKey the public key for an ssh key

type SSHKeys

type SSHKeys struct {
	ID          int    `json:"id"`
	Name        string `json:"name"`
	Fingerprint string `json:"fingerprint"`
	PublicKey   string `json:"public_key"`
}

SSHKeys has details of a ssh key in user's DO account

type SizeInfo

type SizeInfo struct {
	Slug         string   `json:"slug"`
	Memory       int      `json:"memory"`
	VCPUs        int      `json:"vcpus"`
	Disk         int      `json:"disk"`
	PriceMonthly float32  `json:"price_monthly"`
	PriceHourly  float32  `json:"price_hourly"`
	Regions      []string `json:"regions"`
	Available    bool     `json:"available"`
	Transfer     int      `json:"transfer"`
}

SizeInfo has details about a specific VM size

type V4NetworkInfo

type V4NetworkInfo struct {
	IPAddress string `json:"ip_address"`
	Netmask   string `json:"netmask"`
	Gateway   string `json:"gateway"`
	Type      string `json:"type"`
}

V4NetworkInfo has details of ipv4 networks

type V6NetworkInfo

type V6NetworkInfo struct {
	IPAddress string `json:"ip_address"`
	Netmask   int    `json:"netmask"`
	Gateway   string `json:"gateway"`
	Type      string `json:"type"`
}

V6NetworkInfo has details about ipv6 networks

type VMInfo

type VMInfo struct {
	ID        string      `json:"id"`
	Name      string      `json:"name"`
	Memory    int         `json:"memory"`
	VCPUs     int         `json:"vcpus"`
	Disk      int         `json:"disk"`
	Region    RegionInfo  `json:"region"`
	Status    string      `json:"status"`
	SizeSlug  string      `json:"size_slug"`
	CreatedAt string      `json:"created_at"`
	Image     ImageInfo   `json:"image"`
	Size      SizeInfo    `json:"size"`
	Networks  NetworkInfo `json:"networks"`
	VPCUUID   string      `json:"vpc_uuid"`
	Tags      []string    `json:"tags"`
}

VMInfo has all details about a given VM

func (*VMInfo) GetPublicIP

func (v *VMInfo) GetPublicIP() (publicIP string, err error)

GetPublicIP for the VM

type VMManager added in v0.2.7

type VMManager interface {
	FindAuthToken() string
	ListVMs() (vmInfo []VMInfo, err error)
	CreateVM(name string, image string, size string, region string, sshKey SSHKey) (VMInfo, error)
	GetVMInfo(vmID string) (vmInfo VMInfo, err error)
	DeleteVM(ID string) error
	// UploadSSHKey()
	IsSSHKeyUploaded(sshKey SSHKey) (string, error)
	UploadSSHKey(keyName string, sshKey SSHKey) (string, error)
	SelectClosestRegion() (closestRegion string, err error)
}

VMManager is the interface all cloud provider need to follow

type VMSizes

type VMSizes interface {
	GetList() ([]SizeInfo, error)
	GetInfo(size string) (SizeInfo, error)
	GetLargerSize()
	GetSmallerSize()
}

VMSizes allows callers to move from one size to another

Jump to

Keyboard shortcuts

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