linode

package
v0.0.0-...-d5b31fc Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2020 License: MIT Imports: 14 Imported by: 0

README

See More:

Linode OpenAPI Docs

https://developers.linode.com/v4/introduction

Refs

https://github.com/chiefy/go-linode
https://developers.linode.com/v4/guides/curl/creating-a-linode

Documentation

Overview

Package linode ... this file rewrap existing methods to implement the cloudsvr.Handler interface

Index

Constants

This section is empty.

Variables

View Source
var (
	// OsImage is exported
	OsImage = "linode/centos7"
	// NodeLabelPrefix is exported
	NodeLabelPrefix = "inf-agent-linode-node"
)
View Source
var (
	// CloudType is exported
	CloudType = "linode"
)
View Source
var (
	// DefaultAPIEndPoint is exported
	DefaultAPIEndPoint = "https://api.linode.com/v4"
)

Functions

This section is empty.

Types

type BaseResponse

type BaseResponse struct {
	Results int `json:"results"`
	Pages   int `json:"pages"`
	Page    int `json:"page"`
}

BaseResponse is exported

type Config

type Config struct {
	EndPoint  string `json:"endpoint,omitempty"`
	AccessKey string `json:"access_key"`
}

Config is exported

func (*Config) Valid

func (cfg *Config) Valid() error

Valid is exported

type CreateInstancesInput

type CreateInstancesInput struct {
	Region       string `json:"region"` // must
	Type         string `json:"type"`   // must
	Label        string `json:"label"`  // must be uniq,  length: [3-32]
	Distribution string `json:"distribution"`
	RootPass     string `json:"root_pass"`
	Booted       bool   `json:"booted"`
}

CreateInstancesInput is exported

func (*CreateInstancesInput) Validate

func (req *CreateInstancesInput) Validate() error

Validate is exported

type DescribeInstancesOutput

type DescribeInstancesOutput struct {
	BaseResponse
	Data []*Instance `json:"data"`
}

DescribeInstancesOutput is exported

type DescribeRegionsOutput

type DescribeRegionsOutput struct {
	BaseResponse
	Data []*Region `json:"data"`
}

DescribeRegionsOutput is exported

type DescribeTypesOutput

type DescribeTypesOutput struct {
	BaseResponse
	Data []*InstanceType `json:"data"`
}

DescribeTypesOutput is exported

type ErrResponse

type ErrResponse struct {
	Field  string `json:"field"`
	Reason string `json:"reason"`
}

ErrResponse is exported

type ErrorResponse

type ErrorResponse struct {
	Errors []*ErrResponse `json:"errors"`
}

ErrorResponse is exported

type Instance

type Instance struct {
	ID           int      `json:"id"`
	Region       string   `json:"region"`
	Image        string   `json:"image"`
	Group        string   `json:"group"`
	Distribution string   `json:"distribution"`
	IPv4         []string `json:"ipv4"`
	IPv6         string   `json:"ipv6"`
	Label        string   `json:"label"`
	Type         string   `json:"type"`       // instance type
	Status       string   `json:"status"`     // offline,booting,running,shutting_down,rebooting,provisioning,deleting,migrating
	Hypervisor   string   `json:"hypervisor"` // kvm, xen
	Created      string   `json:"created"`
	Updated      string   `json:"updated"`
	Specs        *Spec    `json:"specs"`
}

Instance is exported

type InstanceType

type InstanceType struct {
	ID         string `json:"id"`
	Memory     int    `json:"memory"` // by MiB
	VCpus      int    `json:"vcpus"`
	Disk       int    `json:"disk"`        // by MiB
	Transfer   int    `json:"transfer"`    // outbound transfer in MB
	NetworkOut int    `json:"network_out"` // Mbits outbound bandwidth
	Label      string `json:"label"`
	Class      string `json:"class"`
}

InstanceType is exported

type LnAPIError

type LnAPIError struct {
	Code   int
	Field  string
	Reason string
}

LnAPIError is exported

func (*LnAPIError) Error

func (e *LnAPIError) Error() string

Error implement error interface

type Region

type Region struct {
	ID      string `json:"id"`
	Country string `json:"country"`
}

Region is exported

type SDK

type SDK struct {
	// contains filtered or unexported fields
}

SDK is an implement of CloudSvr

func Setup

func Setup(cfg *Config) (*SDK, error)

Setup is exported

func (*SDK) APIEndPoint

func (sdk *SDK) APIEndPoint() string

APIEndPoint is exported

func (*SDK) AccessKey

func (sdk *SDK) AccessKey() string

AccessKey is exported

func (*SDK) InspectEcs

func (sdk *SDK) InspectEcs(id int) (*Instance, error)

InspectEcs show details of a given ecs instance

func (*SDK) InspectNode

func (sdk *SDK) InspectNode(id, regionOrZone string) (interface{}, error)

InspectNode show details of one given ecs instance

func (*SDK) ListCloudRegions

func (sdk *SDK) ListCloudRegions() ([]*cloudsvr.CloudRegion, error)

ListCloudRegions implement cloudsvr.Handler

func (*SDK) ListCloudTypes

func (sdk *SDK) ListCloudTypes(region string) ([]*cloudsvr.CloudNodeType, error)

ListCloudTypes implement cloudsvr.Handler

func (*SDK) ListEcses

func (sdk *SDK) ListEcses() ([]*Instance, error)

ListEcses show all of ecs instances

func (*SDK) ListInstanceTypes

func (sdk *SDK) ListInstanceTypes(minCPU, maxCPU, minMem, maxMem int) ([]*InstanceType, error)

ListInstanceTypes show all of instance types under given zone support cpu / memory minimal/maximize filter parameters note: public api, do NOT require auth

func (*SDK) ListNodes

func (sdk *SDK) ListNodes() ([]*cloudsvr.CloudNode, error)

ListNodes list all linode ecs instances with label prefix: NodeLabelPrefix the nodes listed does NOT have any auth fields `User` `Password`

func (*SDK) ListRegions

func (sdk *SDK) ListRegions() ([]*Region, error)

ListRegions show all of regions linode supported note: public api, do NOT require auth

func (*SDK) NewEcs

func (sdk *SDK) NewEcs(req *CreateInstancesInput) (int, error)

NewEcs create a new ecs instance with given settings

func (*SDK) NewNode

func (sdk *SDK) NewNode(prefer *cloudsvr.PreferAttrs) (*cloudsvr.CloudNode, *cloudsvr.PreferAttrs, error)

NewNode create linode ecs instance, try to use prefered attributes firstly

func (*SDK) Ping

func (sdk *SDK) Ping() error

Ping verify the cloudsvr settings could be working fine

func (*SDK) RemoveEcs

func (sdk *SDK) RemoveEcs(id int) error

RemoveEcs remove the specified ecs instance

func (*SDK) RemoveNode

func (sdk *SDK) RemoveNode(node *cloudsvr.CloudNode) error

RemoveNode remove linode ecs instance

func (*SDK) Type

func (sdk *SDK) Type() string

Type implement cloudsvr.Handler

func (*SDK) Verify

func (sdk *SDK) Verify() error

Verify verifies configs about linode endpoint & access id & access key

func (*SDK) WaitEcs

func (sdk *SDK) WaitEcs(id int, expectStatus string, maxWait time.Duration) error

WaitEcs wait ecs instance status reached to expected status until maxWait timeout

type Spec

type Spec struct {
	Disk     int `json:"disk"`
	Memory   int `json:"memory"`
	Vcpus    int `json:"vcpus"`
	Transfer int `json:"transfer"`
}

Spec is exported

Jump to

Keyboard shortcuts

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