lib

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2014 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DataTimestampFormat string = "2006-01-02 15:04:05.000000-0700"
	ArgTimestampFormat  string = "2006-01-02 15:04 MST"
)

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(fpath string, v interface{}) error

func PrintXMLStruct

func PrintXMLStruct(s interface{}, indent ...int)

Types

type AddIP

type AddIP struct {
	Number int `xml:"number,attr"`
}

type Admin

type Admin struct {
	Login    string `xml:"login,attr"`
	Password string `xml:"password"`
}

type ApplicationList

type ApplicationList struct {
	XMLName             xml.Name              `xml:"application-list" json:"-" toml:"-"`
	ApplicationTemplate []ApplicationTemplate `xml:"application-template"`
}

type ApplicationTemplate

type ApplicationTemplate struct {
	XMLName xml.Name `xml:"application-template" json:"-" toml:"-"`
	ID      int      `xml:"id,attr"`
	Name    string   `xml:"name,attr"`
	// Active      bool   `xml:"active,attr"`
	ForOS       string `xml:"for-os,attr"`
	Description string `xml:"description"`
}

type Autoscale

type Autoscale struct {
	XMLName xml.Name `xml:"autoscale" json:"-" toml:"-"`
	Current *struct {
		AutoscaleRule []AutoscaleRule `xml:"autoscale-rule"`
	} `xml:"current"`
	Ongoing *struct {
		AutoscaleRule []AutoscaleRule `xml:"autoscale-rule"`
	} `xml:"ongoing"`
}

type AutoscaleData

type AutoscaleData struct {
	XMLName       xml.Name `xml:"autoscale-data" json:"-" toml:"-"`
	AutoscaleRule []AutoscaleRule
}

type AutoscaleRule

type AutoscaleRule struct {
	XMLName           xml.Name   `xml:"autoscale-rule" json:"-" toml:"-"`
	Enabled           *bool      `xml:"enabled,attr"`
	Deleted           *bool      `xml:"deleted,attr"`
	Metric            string     `xml:"metric,attr"`
	Version           *int       `xml:"version,attr"`
	Updated           *Timestamp `xml:"updated,attr,omitempty"`
	UpdateDeliveredOk *bool      `xml:"update-delivered-ok,attr"`
	UpdateDelivered   *Timestamp `xml:"update-delivered,attr,omitempty"`
	AllowMigration    *bool      `xml:"allow-migration,attr"`
	AllowRestart      *bool      `xml:"allow-restart,attr"`
	Limits            *struct {
		Min  int `xml:"min,attr"`
		Max  int `xml:"max,attr"`
		Step int `xml:"step,attr"`
	} `xml:"limits"`
	Thresholds *struct {
		Up   *Threshold `xml:"up"`
		Down *Threshold `xml:"down"`
	} `xml:"thresholds"`
}

type Backup

type Backup struct {
	XMLName        xml.Name  `xml:"backup" json:"-" toml:"-"`
	ImBackupID     int       `xml:"im-backup-id,attr"`
	CloudBackupID  string    `xml:"cloud-backup-id,attr"`
	ScheduleName   string    `xml:"schedule-name,attr"`
	Started        Timestamp `xml:"started,attr"`
	Ended          Timestamp `xml:"ended,attr"`
	Successful     bool      `xml:"successful,attr"`
	BackupSize     int       `xml:"backup-size,attr"`
	BackupNodeName string    `xml:"backup-node-name,attr"`
	Description    string    `xml:"description"`
}

type BackupSchedule

type BackupSchedule struct {
	Name string `xml:"name,attr"`
}

type BackupScheduleList

type BackupScheduleList struct {
	XMLName        xml.Name `xml:"backup-schedule-list" json:"-" toml:"-"`
	BackupSchedule []struct {
		ID   int    `xml:"id,attr"`
		Name string `xml:"name,attr"`
		//		CronExpression  string `xml:"cron-expression,attr"`
		Description     string `xml:"description"`
		Enabled         bool   `xml:"enabled,attr"`
		BackupsToKeep   int    `xml:"backups-to-keep,attr"`
		NoOfIncremental int    `xml:"no-of-incremental,attr"`
	} `xml:"backup-schedule"`
}

type CPU

type CPU struct {
	Number int `xml:"number,attr"`
	Power  int `xml:"power,attr"`
}

type ChangeCPU

type ChangeCPU struct {
	Number int `xml:"number,attr,omitempty"`
	Power  int `xml:"power,attr,omitempty"`
}

type Client

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

func NewClient

func NewClient(baseURL, username, password string) *Client

func (*Client) SendRequest

func (c *Client) SendRequest(method, path string, data io.Reader) (*Response, error)

type Config

type Config struct {
	BaseURL  string
	Username string
	Password string
	Servers  map[string]Server
}

type Console

type Console struct {
	Address IPAddr `xml:"address"`
	Port    int    `xml:"port"`
}

type CreateVe

type CreateVe struct {
	XMLName        xml.Name `xml:"ve" json:"-" toml:"-"`
	CustomNs       bool     `xml:"custom-ns,attr,omitempty"`
	Name           string   `xml:"name"`
	Hostname       string   `xml:"hostname"`
	Description    string   `xml:"description"`
	SubscriptionID int      `xml:"subscription-id,omitempty"`
	CPU            CPU      `xml:"cpu"`
	RAMSize        int      `xml:"ram-size"`
	Bandwidth      int      `xml:"bandwidth"`
	NoOfPublicIP   int      `xml:"no-of-public-ip,omitempty"`
	NoOfPublicIPv6 int      `xml:"no-of-public-ipv6,omitempty"`
	VeDisk         struct {
		Local   bool `xml:"local,attr"`
		Primary bool `xml:"primary,attr,omitempty"`
		Size    int  `xml:"size,attr"`
	} `xml:"ve-disk"`
	Platform       Platform `xml:"platform"`
	BackupSchedule *struct {
		Name string `xml:"name,attr"`
	} `xml:"backup-schedule"`
}

type CustomNs

type CustomNs int

func (CustomNs) MarshalText

func (ns CustomNs) MarshalText() (text []byte, err error)

type DropIP

type DropIP struct {
	IP IPAddrList `xml:"ip,attr"`
}

type Firewall

type Firewall struct {
	XMLName xml.Name `xml:"firewall" json:"-" toml:"-"`
	Rule    []struct {
		ID         int      `xml:"id,attr,omitempty" json:"-" toml:"-"`
		Name       string   `xml:"name,attr"`
		Protocol   string   `xml:"protocol,attr"`
		LocalPort  int      `xml:"local-port,attr"`
		RemotePort int      `xml:"remote-port,attr"`
		RemoteNet  []IPAddr `xml:"remote-net"`
	} `xml:"rule"`
}

type IPAddr

type IPAddr struct {
	IP    net.IP
	IPNet *net.IPNet
}

func NewIPAddr

func NewIPAddr(addr string) (*IPAddr, error)

func (IPAddr) MarshalText

func (a IPAddr) MarshalText() (text []byte, err error)

func (IPAddr) String

func (a IPAddr) String() string

func (*IPAddr) UnmarshalText

func (a *IPAddr) UnmarshalText(text []byte) error

type IPAddrList

type IPAddrList []IPAddr

func (IPAddrList) MarshalText

func (as IPAddrList) MarshalText() (text []byte, err error)

func (IPAddrList) String

func (as IPAddrList) String() string

type ImageList

type ImageList struct {
	XMLName   xml.Name `xml:"image-list" json:"-" toml:"-"`
	ImageInfo []struct {
		Name           string    `xml:"name,attr"`
		Description    string    `xml:"description,attr"`
		Size           int       `xml:"size,attr"`
		Created        Timestamp `xml:"created,attr"`
		SubscriptionID int       `xml:"subscription-id,attr"`
		ImageOf        string    `xml:"image-of,attr"`
		Location       string    `xml:location,attr"`
	} `xml:"image-info"`
}

type LbList

type LbList struct {
	XMLName      xml.Name `xml:"lb-list" json:"-" toml:"-"`
	LoadBalancer []struct {
		Name           string `xml:"name,attr"`
		State          string `xml:"state,attr"`
		SubscriptionID int    `xml:"subscription-id,attr"`
	} `xml:"load-balancer"`
}

type LoadBalancer

type LoadBalancer struct {
	XMLName         xml.Name       `xml:"load-balancer" json:"-" toml:"-"`
	ID              int            `xml:"id"`
	UUID            string         `xml:"uuid"`
	Hnid            int            `xml:"hnId"`
	CustomerID      int            `xml:"customer-id"`
	Name            string         `xml:"name"`
	Hostname        string         `xml:"hostname"`
	Description     string         `xml:"description"`
	SubscriptionID  int            `xml:"subscription-id"`
	CPU             CPU            `xml:"cpu"`
	RAMSize         int            `xml:"ram-size"`
	Bandwidth       int            `xml:"bandwidth"`
	VeDisk          VeDisk         `xml:"ve-disk"`
	Platform        Platform       `xml:"platform"`
	Network         Network        `xml:"network"`
	BackupSchedule  BackupSchedule `xml:"backup-schedule"`
	Console         Console        `xml:"console"`
	State           string         `xml:"state"`
	PrimaryDiskID   int            `xml:"primary-disk-id"`
	TemplateID      int            `xml:"template-id"`
	Admin           Admin          `xml:"admin"`
	LastOperationRc int            `xml:"last-operation-rc"`
	UsedBy          []struct {
		VeName string `xml:"ve-name,attr"`
		IP     IPAddr `xml:"ip,attr"`
	} `xml:"used-by"`
}

type Network

type Network struct {
	PrivateIP IPAddr `xml:"private-ip,attr"`
	PublicIP  []struct {
		ChunkRef int    `xml:"chunk-ref,attr"`
		ID       int    `xml:"id,attr"`
		Address  IPAddr `xml:"address,attr"`
		Gateway  IPAddr `xml:"gateway,attr"`
	} `xml:"public-ip"`
	PublicIP6 []struct {
		ID      int    `xml:"id,attr"`
		Address IPAddr `xml:"address,attr"`
		Gateway IPAddr `xml:"gateway,attr"`
	} `xml:"public-ip6"`
}

type PasswordResponse

type PasswordResponse struct {
	XMLName  xml.Name `xml:"pwd-response" json:"-" toml:"-"`
	Message  string   `xml:"message"`
	Password string   `xml:"password"`
}

type Platform

type Platform struct {
	TemplateInfo struct {
		Name string `xml:"name,attr"`
	} `xml:"template-info"`
	OSInfo struct {
		Type       string `xml:"type,attr"`
		Technology string `xml:"technology,attr"`
		Family     string `xml:"family,attr,omitempty"`
	} `xml:"os-info"`
}

type ReconfigureIP

type ReconfigureIP struct {
	AddIP  *AddIP  `xml:"add-ip"`
	DropIP *DropIP `xml:"drop-ip"`
}

type ReconfigureVe

type ReconfigureVe struct {
	XMLName         xml.Name       `xml:"reconfigure-ve" json:"-" toml:"-"`
	Description     string         `xml:"description,omitempty"`
	ChangeCPU       *ChangeCPU     `xml:"change-cpu"`
	RAMSize         int            `xml:"ram-size,omitempty"`
	Bandwidth       int            `xml:"bandwidth,omitempty"`
	ReconfigureIPv4 *ReconfigureIP `xml:"reconfigure-ipv4"`
	ReconfigureIPv6 *ReconfigureIP `xml:"reconfigure-ipv6"`
	PrimaryDiskSize int            `xml:"primary-disk-size,omitempty"`
	CustomNs        *int           `xml:"custom-ns"`
}

type ResourceConsumptionAndAutoscaleHistory

type ResourceConsumptionAndAutoscaleHistory struct {
	XMLName                   xml.Name `xml:"resource-consumption-and-autoscale-history" json:"-" toml:"-"`
	ResourceConsumptionSample []struct {
		RAMUsage               int       `xml:"ram-usage,attr"`
		CPUUsage               int       `xml:"cpu-usage,attr"`
		PrivateIncomingTraffic int       `xml:"private-incoming-traffic,attr"`
		PrivateOutgoingTraffic int       `xml:"private-outgoing-traffic,attr"`
		PublicIncomingTraffic  int       `xml:"public-incoming-traffic,attr"`
		PublicOutgoingTraffic  int       `xml:"public-outgoing-traffic,attr"`
		NodeSeqNo              int       `xml:"node-seq-no,attr"`
		NodeTimestamp          Timestamp `xml:"node-timestamp,attr"`
		PaciTimestamp          Timestamp `xml:"paci-timestamp,attr"`
		CPU                    int       `xml:"cpu,attr"`
		RAM                    int       `xml:"ram,attr"`
		Bandwidth              int       `xml:"bandwidth,attr"`
	} `xml:"resource-consumption-sample"`
	AutoscaleEvent struct {
		Direction     string    `xml:"direction,attr"`
		RuleVersion   int       `xml:"rule-version,attr"`
		NodeSeqNo     int       `xml:"node-seq-no,attr"`
		NodeTimestamp Timestamp `xml:"node-timestamp,attr"`
		Metric        string    `xml:"metric,attr"`
		NewValue      int       `xml:"new-value,attr"`
		NodeUUID      string    `xml:"node-uuid,attr"`
		Started       string    `xml:"started,attr"`
		Ended         string    `xml:"ended,attr"`
		EndedOk       bool      `xml:"ended-ok,attr"`
	} `xml:"autoscale-event"`
	AutoscaleRule []AutoscaleRule `xml:"autoscale-rule"`
}

type Response

type Response struct {
	Status     string
	StatusCode int
	Body       []byte
}

func (*Response) String

func (r *Response) String() string

type Server

type Server struct {
	Spec          *CreateVe       // xml struct
	Firewall      Firewall        // xml struct
	AutoscaleRule []AutoscaleRule // xml struct
}

type Template

type Template struct {
	XMLName                  xml.Name `xml:"template" json:"-" toml:"-"`
	ID                       int      `xml:"id,attr"`
	Name                     string   `xml:"name,attr"`
	OSType                   string   `xml:"osType,attr"`
	Technology               string   `xml:"technology,attr"`
	Active                   bool     `xml:"active,attr"`
	Default                  bool     `xml:"default,attr"`
	RootLogin                string   `xml:"root-login,attr"`
	MinHddSize               int      `xml:"min-hdd-size,attr"`
	PwdRegex                 string   `xml:"pwd-regex,attr"`
	HighWaterMarkForDelivery int      `xml:"high-watermark-for-delivery,attr"`
	LowWaterMarkForDelivery  int      `xml:"low-watermark-for-delivery,attr"`
	Option                   []struct {
		Name  string `xml:"name,attr"`
		Value string `xml:"value,attr"`
	} `xml:"option"`
}

type TemplateList

type TemplateList struct {
	XMLName  xml.Name   `xml:"template-list" json:"-" toml:"-"`
	Template []Template `xml:"template"`
}

type Threshold

type Threshold struct {
	Threshold *int `xml:"threshold,attr"`
	Period    int  `xml:"period,attr"`
}

type Timestamp

type Timestamp struct {
	time.Time
}

func (Timestamp) MarshalText

func (t Timestamp) MarshalText() ([]byte, error)

func (Timestamp) String

func (t Timestamp) String() string

func (*Timestamp) UnmarshalText

func (t *Timestamp) UnmarshalText(text []byte) error

type Traffic

type Traffic struct {
	Sent     int `xml:"sent,attr"`
	Received int `xml:"received,attr"`
}

type Ve

type Ve struct {
	XMLName         xml.Name       `xml:"ve" json:"-" toml:"-"`
	ID              int            `xml:"id"`
	UUID            string         `xml:"uuid"`
	Hnid            int            `xml:"hnId"`
	CustomerID      int            `xml:"customer-id"`
	Name            string         `xml:"name"`
	Hostname        string         `xml:"hostname"`
	Description     string         `xml:"description"`
	SubscriptionID  int            `xml:"subscription-id"`
	CPU             CPU            `xml:"cpu"`
	RAMSize         int            `xml:"ram-size"`
	Bandwidth       int            `xml:"bandwidth"`
	VeDisk          VeDisk         `xml:"ve-disk"`
	Platform        Platform       `xml:"platform"`
	Network         Network        `xml:"network"`
	BackupSchedule  BackupSchedule `xml:"backup-schedule"`
	Console         Console        `xml:"console"`
	State           string         `xml:"state"`
	PrimaryDiskID   int            `xml:"primary-disk-id"`
	TemplateID      int            `xml:"template-id"`
	Admin           Admin          `xml:"admin"`
	LastOperationRc int            `xml:"last-operation-rc"`
	AppInfo         []struct {
		AppTemplate   string `xml:"app-template,attr"`
		ForOS         string `xml:"for-os,attr"`
		InstalledAt   string `xml:"installed-at,attr"`
		InstalledOk   bool   `xml:"installed-ok,attr"`
		UninstalledAt string `xml:"uninstalled-at,attr"`
		UninstalledOk bool   `xml:"uninstalled-ok,attr"`
		AppTemplateID int    `xml:"app-template-id,attr"`
	} `xml:"app-info"`
	LoadBalancer string `xml:"load-balancer"`
	SteadyState  string `xml:"steady-state"`
	//AutoScale                  string `xml:"autoscale"`
	CurrentResourceConsumption struct {
		CPU            int     `xml:"cpu,attr"`
		RAM            int     `xml:"ram,attr"`
		PrivateTraffic Traffic `xml:"private-traffic"`
		PublicTraffic  Traffic `xml:"public-traffic"`
	} `xml:"current-resource-consumption"`
}

type VeBackups

type VeBackups struct {
	XMLName xml.Name `xml:"ve-backups" json:"-" toml:"-"`
	Backup  []Backup `xml:"backup"`
}

type VeDisk

type VeDisk struct {
	StorageID string `xml:"storage-id,attr"`
	Created   bool   `xml:"created,attr"`
	GlobalID  int    `xml:"global-id,attr"`
	ID        int    `xml:"id,attr"`
	Type      string `xml:"type,attr"`
	Size      int    `xml:"size,attr"`
}

type VeHistory

type VeHistory struct {
	XMLName    xml.Name `xml:"ve-history" json:"-" toml:"-"`
	VeSnapshot []struct {
		CPU                    int       `xml:"cpu,attr"`
		RAM                    int       `xml:"ram,attr"`
		LocalDisk              int       `xml:"local-disk,attr"`
		Nbd                    int       `xml:"nbd,attr"`
		Bandwidth              int       `xml:"bandwidth,attr"`
		LastTouchedFrom        string    `xml:"last-touched-from,attr"`
		State                  string    `xml:"state,attr"`
		SteadyState            string    `xml:"steady-state,attr"`
		LastChangedBy          string    `xml:"last-changed-by,attr"`
		EventTimestamp         Timestamp `xml:"event-timestamp,attr"`
		NoOfPublicIP           int       `xml:"no-of-public-ip,attr"`
		NoOfPublicIPv6         int       `xml:"no-of-public-ipv6,attr"`
		IsLb                   bool      `xml:"is-lb,attr"`
		PrivateIncomingTraffic int       `xml:"private-incoming-traffic,attr"`
		PrivateOutgoingTraffic int       `xml:"private-outgoing-traffic,attr"`
		PublicIncomingTraffic  int       `xml:"public-incoming-traffic,attr"`
		PublicOutgoingTraffic  int       `xml:"public-outgoing-traffic,attr"`
	} `xml:"ve-snapshot"`
}

type VeImage

type VeImage struct {
	XMLName        xml.Name  `xml:"ve-image" json:"-" toml:"-"`
	ID             int       `xml:"id,attr"`
	BnodeUUID      string    `xml:"bnode-uuid,attr"`
	CustomerID     int       `xml:"customer-id,attr"`
	SubscriptionID int       `xml:"subscription-id,attr"`
	Name           string    `xml:"name,attr"`
	Hostname       string    `xml:"hostname,attr"`
	Description    string    `xml:"description"`
	CPUNumber      int       `xml:"cpu-number,attr"`
	CPUPower       int       `xml:"cpu-power,attr"`
	RAMSize        int       `xml:"ram-size,attr"`
	Bandwidth      int       `xml:"bandwidth,attr"`
	Login          string    `xml:"login,attr"`
	PrimaryDiskID  int       `xml:"primary-disk-id,attr"`
	ImageSize      int       `xml:"image-size,attr"`
	Created        Timestamp `xml:"created,attr"`
	ImageOf        string    `xml:"image-of,attr"`
	NoOfPublicIP   int       `xml:"no-of-public-ip,attr"`
	NoOfPublicIPv6 int       `xml:"no-of-public-ipv6,attr"`
	CustomNs       bool      `xml:"custom-ns,attr"`
	Disks          []struct {
		ID      int    `xml:"id,attr"`
		Type    string `xml:"type,attr"`
		Primary bool   `xml:"primary,attr"`
		Size    int    `xml:"size,attr"`
	} `xml:"disks"`
	Platform Platform `xml:"platform"`
}

type VeList

type VeList struct {
	XMLName xml.Name `xml:"ve-list" json:"-" toml:"-"`
	VeInfo  []struct {
		ID             int    `xml:"id,attr"`
		Name           string `xml:"name,attr"`
		Hostname       string `xml:"hostname,attr"`
		State          string `xml:"state,attr"`
		SubscriptionID int    `xml:"subscription-id,attr"`
	} `xml:"ve-info"`
}

type VeResourceUsageReport

type VeResourceUsageReport struct {
	XMLName           xml.Name `xml:"ve-resource-usage-report" json:"-" toml:"-"`
	VeName            string   `xml:"ve-name,attr"`
	VeID              int      `xml:"ve-id,attr"`
	OS                string   `xml:"os,attr"`
	Technology        string   `xml:"technology,attr"`
	LifeTimeInMinutes int      `xml:"life-time-in-minutes,attr"`
	IsLoadBalancer    bool     `xml:"is-load-balancer,attr"`
	ResourceUsage     []struct {
		Value             int    `xml:"value,attr"`
		ResourceUsageType string `xml:"resource-usage-type,attr"`
		ResourceType      string `xml:"resource-type,attr"`
	} `xml:"resource-usage"`
	VeTraffic []struct {
		TrafficType string `xml:"traffic-type,attr"`
		Used        int    `xml:"used,attr"`
	} `xml:"ve-traffic"`
	ActiveBackupSchedule []struct {
		ScheduleName string `xml:"schedule-name,attr"`
	} `xml:"active-backup-schedule"`
}

Jump to

Keyboard shortcuts

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