Documentation ¶
Overview ¶
Package vultr ... this file rewrap existing methods to implement the cloudsvr.Handler interface
Package vultr ... Most borrowed from:
https://github.com/JamesClonk/vultr/blob/master/lib/servers.go
Index ¶
- Variables
- type Account
- type Config
- type CreateServerInput
- type Plan
- type Region
- type SDK
- func (sdk *SDK) APIEndPoint() string
- func (sdk *SDK) AccessKey() string
- func (sdk *SDK) AccountInfo() (*Account, error)
- func (sdk *SDK) InspectEcs(id int) (*Server, error)
- func (sdk *SDK) InspectNode(id, regionOrZone string) (interface{}, error)
- func (sdk *SDK) ListCloudRegions() ([]*cloudsvr.CloudRegion, error)
- func (sdk *SDK) ListCloudTypes(region string) ([]*cloudsvr.CloudNodeType, error)
- func (sdk *SDK) ListEcses() (map[string]*Server, error)
- func (sdk *SDK) ListNodes() ([]*cloudsvr.CloudNode, error)
- func (sdk *SDK) ListPlans(minCPU, maxCPU, minMem, maxMem int) (map[string]*Plan, error)
- func (sdk *SDK) ListRegions() (map[string]*Region, error)
- func (sdk *SDK) NewEcs(req *CreateServerInput) (int, error)
- func (sdk *SDK) NewNode(prefer *cloudsvr.PreferAttrs) (*cloudsvr.CloudNode, *cloudsvr.PreferAttrs, error)
- func (sdk *SDK) Ping() error
- func (sdk *SDK) RemoveEcs(id int) error
- func (sdk *SDK) RemoveNode(node *cloudsvr.CloudNode) error
- func (sdk *SDK) Type() string
- func (sdk *SDK) Verify() error
- func (sdk *SDK) WaitEcs(id int, expectStatus string, maxWait time.Duration) error
- type Server
- type V6Network
Constants ¶
This section is empty.
Variables ¶
var ( // OsImage is exported OsImage = 167 // CentOS 7 x64 // NodeLabelPrefix is exported NodeLabelPrefix = "inf-agent-vultr-node" )
var (
// CloudType is exported
CloudType = "vultr"
)
var (
// DefaultAPIEndPoint is exported
DefaultAPIEndPoint = "https://api.vultr.com/v1"
)
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { Balance float64 `json:"balance,string"` PendingCharges float64 `json:"pending_charges,string"` LastPaymentDate string `json:"last_payment_date"` LastPaymentAmount float64 `json:"last_payment_amount,string"` }
Account is exported
type Config ¶
type Config struct { EndPoint string `json:"endpoint,omitempty"` AccessKey string `json:"access_key"` }
Config is exported
type CreateServerInput ¶
type CreateServerInput struct { DCID int // must VPSPLANID int // must OSID int // must ISOID string SCRIPTID string SNAPSHOTID string EnableIPv6 bool EnablePrivateNetwork bool NETWORKID string Label string // label text SSHKEYID string AutoBackups bool APPID string Userdata string NotifyActivate bool DdosProtection bool ReservedIPv4 string Hostname string Tag string FIREWALLGROUPID string }
CreateServerInput is exported See: https://www.vultr.com/api/#server_create
func (*CreateServerInput) ToURLValues ¶
func (req *CreateServerInput) ToURLValues() url.Values
ToURLValues is exported TODO more ...
func (*CreateServerInput) Validate ¶
func (req *CreateServerInput) Validate() error
Validate is exported
type Plan ¶
type Plan struct { ID int `json:"VPSPLANID,string"` Name string `json:"name"` // Starter, Basic ... VCpus int `json:"vcpu_count,string"` RAM int `json:"ram,string"` // by MiB Disk int `json:"disk,string"` // by GiB Bandwidth float64 `json:"bandwidth,string"` // by MiB Price float64 `json:"price_per_month,string"` // by $ Type string `json:"plan_type"` // SSD SATA Regions []int `json:"available_locations"` }
Plan is exported
type Region ¶
type Region struct { ID int `json:"DCID,string"` Name string `json:"name"` Country string `json:"country"` Continent string `json:"continent"` State string `json:"state"` Ddos bool `json:"ddos_protection"` BlockStorage bool `json:"block_storage"` Code string `json:"regioncode"` }
Region is exported
type SDK ¶
type SDK struct {
// contains filtered or unexported fields
}
SDK is an implement of CloudSvr
func (*SDK) InspectEcs ¶
InspectEcs show details of a given ecs instance
func (*SDK) InspectNode ¶
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) ListNodes ¶
ListNodes list all vultr ecs instances with label prefix: NodeLabelPrefix the nodes listed does NOT have any auth fields `User` `Password`
func (*SDK) ListPlans ¶
ListPlans show all of instance plans support cpu / memory minimal/maximize filter parameters note: public api, do NOT require auth
func (*SDK) ListRegions ¶
ListRegions show all of regions vultr supported note: public api, do NOT require auth
func (*SDK) NewEcs ¶
func (sdk *SDK) NewEcs(req *CreateServerInput) (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 vultr ecs instance, try to use prefered attributes firstly
func (*SDK) RemoveNode ¶
RemoveNode remove vultr ecs instance
type Server ¶
type Server struct { ID string `json:"SUBID"` Label string `json:"label"` OS string `json:"os"` RAM string `json:"ram"` Disk string `json:"disk"` MainIP string `json:"main_ip"` VCpus int `json:"vcpu_count,string"` Location string `json:"location"` RegionID int `json:"DCID,string"` DefaultPassword string `json:"default_password"` Created string `json:"date_created"` PendingCharges float64 `json:"pending_charges"` Status string `json:"status"` // pending | active | suspended | closed Cost string `json:"cost_per_month"` CurrentBandwidth float64 `json:"current_bandwidth_gb"` AllowedBandwidth float64 `json:"allowed_bandwidth_gb,string"` NetmaskV4 string `json:"netmask_v4"` GatewayV4 string `json:"gateway_v4"` PowerStatus string `json:"power_status"` // running, stopped ... ServerState string `json:"server_state"` // none | locked | installingbooting | isomounting | ok PlanID int `json:"VPSPLANID,string"` V6Networks []V6Network `json:"v6_networks"` InternalIP string `json:"internal_ip"` KVMUrl string `json:"kvm_url"` AutoBackups string `json:"auto_backups"` Tag string `json:"tag"` OSID string `json:"OSID"` AppID string `json:"APPID"` FirewallGroupID string `json:"FIREWALLGROUPID"` }
Server is exported
func (*Server) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaller on Server. This is needed because the Vultr API is inconsistent in it's JSON responses for servers. Some fields can change type, from JSON number to JSON string and vice-versa.