Documentation ¶
Index ¶
- Constants
- func FindHostForTests(hostId string, host *Host)
- func FindOrCreateVmForTests(vm *Vm, poolId, srId, templateName, tag string)
- func FindPoolForTests(pool *Pool)
- func FindStorageRepositoryForTests(pool Pool, sr *StorageRepository, tag string)
- func FindTemplateForTests(template *Template, poolId, templateEnvVar string)
- func RemoveCloudConfigsWithPrefix(cloudConfigPrefix string) func(string) error
- func RemoveNetworksWithNamePrefix(prefix string) func(string) error
- func RemoveResourceSetsWithNamePrefix(rsNamePrefix string) func(string) error
- func RemoveTagFromAllObjects(tag string) func(string) error
- func RemoveUsersWithPrefix(usernamePrefix string) func(string) error
- type Acl
- type CPUs
- type Client
- func (c Client) AddResourceSetLimit(rsReq ResourceSet, limit string, quantity int) error
- func (c Client) AddResourceSetObject(rsReq ResourceSet, object string) error
- func (c Client) AddResourceSetSubject(rsReq ResourceSet, subject string) error
- func (c *Client) AddTag(id, tag string) error
- func (c *Client) Call(method string, params, result interface{}, opt ...jsonrpc2.CallOption) error
- func (c *Client) ConnectDisk(d Disk) error
- func (c *Client) ConnectVIF(vifReq *VIF) (err error)
- func (c *Client) CreateAcl(acl Acl) (*Acl, error)
- func (c *Client) CreateCloudConfig(name, template string) (*CloudConfig, error)
- func (c *Client) CreateDisk(vm Vm, d Disk) (string, error)
- func (c *Client) CreateNetwork(netReq Network) (*Network, error)
- func (c Client) CreateResourceSet(rsReq ResourceSet) (*ResourceSet, error)
- func (c *Client) CreateUser(user User) (*User, error)
- func (c *Client) CreateVIF(vm *Vm, vif *VIF) (*VIF, error)
- func (c *Client) CreateVm(vmReq Vm, createTime time.Duration) (*Vm, error)
- func (c *Client) DeleteAcl(acl Acl) error
- func (c *Client) DeleteCloudConfig(id string) error
- func (c *Client) DeleteDisk(vm Vm, d Disk) error
- func (c *Client) DeleteNetwork(id string) error
- func (c Client) DeleteResourceSet(rsReq ResourceSet) error
- func (c *Client) DeleteUser(user User) error
- func (c *Client) DeleteVIF(vifReq *VIF) (err error)
- func (c *Client) DeleteVm(id string) error
- func (c *Client) DisconnectDisk(d Disk) error
- func (c *Client) DisconnectVIF(vifReq *VIF) (err error)
- func (c *Client) EjectCd(id string) error
- func (c *Client) EjectVmCd(vm *Vm) error
- func (c *Client) FindFromGetAllObjects(obj XoObject) (interface{}, error)
- func (c *Client) GetAcl(aclReq Acl) (*Acl, error)
- func (c *Client) GetAcls() ([]Acl, error)
- func (c *Client) GetAllCloudConfigs() ([]CloudConfig, error)
- func (c *Client) GetAllObjectsOfType(obj XoObject, response interface{}) error
- func (c *Client) GetAllUsers() ([]User, error)
- func (c *Client) GetCdroms(vm *Vm) ([]Disk, error)
- func (c *Client) GetCloudConfig(id string) (*CloudConfig, error)
- func (c *Client) GetCloudConfigByName(name string) ([]CloudConfig, error)
- func (c *Client) GetDisks(vm *Vm) ([]Disk, error)
- func (c *Client) GetHostById(id string) (host Host, err error)
- func (c *Client) GetHostByName(nameLabel string) (hosts []Host, err error)
- func (c *Client) GetNetwork(netReq Network) (*Network, error)
- func (c *Client) GetNetworks() ([]Network, error)
- func (c *Client) GetObjectsWithTags(tags []string) ([]Object, error)
- func (c *Client) GetPIF(pifReq PIF) (pifs []PIF, err error)
- func (c *Client) GetPIFByDevice(dev string, vlan int) ([]PIF, error)
- func (c *Client) GetParentVDI(vbd VBD) (VDI, error)
- func (c *Client) GetPoolByName(name string) (pools []Pool, err error)
- func (c Client) GetResourceSet(rsReq ResourceSet) ([]ResourceSet, error)
- func (c Client) GetResourceSetById(id string) (*ResourceSet, error)
- func (c Client) GetResourceSets() ([]ResourceSet, error)
- func (c *Client) GetStorageRepository(sr StorageRepository) ([]StorageRepository, error)
- func (c *Client) GetStorageRepositoryById(id string) (StorageRepository, error)
- func (c *Client) GetTemplate(template Template) ([]Template, error)
- func (c *Client) GetUser(userReq User) (*User, error)
- func (c *Client) GetVDIs(vdiReq VDI) ([]VDI, error)
- func (c *Client) GetVIF(vifReq *VIF) (*VIF, error)
- func (c *Client) GetVIFs(vm *Vm) ([]VIF, error)
- func (c *Client) GetVm(vmReq Vm) (*Vm, error)
- func (c *Client) GetVms() ([]Vm, error)
- func (c *Client) InsertCd(vmId, cdId string) error
- func (c Client) RemoveResourceSetLimit(rsReq ResourceSet, limit string) error
- func (c Client) RemoveResourceSetObject(rsReq ResourceSet, object string) error
- func (c Client) RemoveResourceSetSubject(rsReq ResourceSet, subject string) error
- func (c *Client) RemoveTag(id, tag string) error
- func (c *Client) UpdateVDI(d Disk) error
- func (c *Client) UpdateVm(id string, cpus int, nameLabel, nameDescription, ha, rs string, ...) (*Vm, error)
- type CloudConfig
- type CloudConfigResponse
- type Config
- type CpuInfo
- type Disk
- type Host
- type Installation
- type MemoryObject
- type Network
- type NotFound
- type NotFoundError
- type Object
- type PIF
- type Pool
- type Preferences
- type ResourceSet
- type ResourceSetLimit
- type ResourceSetLimits
- type SshKey
- type StateChangeConf
- type StateRefreshFunc
- type StorageRepository
- type Template
- type TemplateDisk
- type TemplateInfo
- type TimeoutError
- type UnexpectedStateError
- type User
- type VBD
- type VDI
- type VIF
- type Vm
- type XoObject
Constants ¶
const ( // Maximum message size allowed from peer. MaxMessageSize = 4096 PongWait = 60 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func FindHostForTests ¶
func FindOrCreateVmForTests ¶
func FindPoolForTests ¶
func FindPoolForTests(pool *Pool)
func FindStorageRepositoryForTests ¶
func FindStorageRepositoryForTests(pool Pool, sr *StorageRepository, tag string)
func FindTemplateForTests ¶
func RemoveTagFromAllObjects ¶
func RemoveUsersWithPrefix ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func (Client) AddResourceSetLimit ¶
func (c Client) AddResourceSetLimit(rsReq ResourceSet, limit string, quantity int) error
func (Client) AddResourceSetObject ¶
func (c Client) AddResourceSetObject(rsReq ResourceSet, object string) error
func (Client) AddResourceSetSubject ¶
func (c Client) AddResourceSetSubject(rsReq ResourceSet, subject string) error
func (*Client) Call ¶
func (c *Client) Call(method string, params, result interface{}, opt ...jsonrpc2.CallOption) error
func (*Client) ConnectDisk ¶
func (*Client) ConnectVIF ¶
func (*Client) CreateCloudConfig ¶
func (c *Client) CreateCloudConfig(name, template string) (*CloudConfig, error)
func (Client) CreateResourceSet ¶
func (c Client) CreateResourceSet(rsReq ResourceSet) (*ResourceSet, error)
func (*Client) DeleteCloudConfig ¶
func (*Client) DeleteNetwork ¶
func (Client) DeleteResourceSet ¶
func (c Client) DeleteResourceSet(rsReq ResourceSet) error
func (*Client) DeleteUser ¶
func (*Client) DisconnectDisk ¶
func (*Client) DisconnectVIF ¶
func (*Client) FindFromGetAllObjects ¶
func (*Client) GetAllCloudConfigs ¶
func (c *Client) GetAllCloudConfigs() ([]CloudConfig, error)
func (*Client) GetAllObjectsOfType ¶
func (*Client) GetAllUsers ¶
func (*Client) GetCloudConfig ¶
func (c *Client) GetCloudConfig(id string) (*CloudConfig, error)
func (*Client) GetCloudConfigByName ¶
func (c *Client) GetCloudConfigByName(name string) ([]CloudConfig, error)
func (*Client) GetHostByName ¶
func (*Client) GetNetworks ¶
func (*Client) GetObjectsWithTags ¶
func (*Client) GetPIFByDevice ¶
func (*Client) GetPoolByName ¶
func (Client) GetResourceSet ¶
func (c Client) GetResourceSet(rsReq ResourceSet) ([]ResourceSet, error)
func (Client) GetResourceSetById ¶
func (c Client) GetResourceSetById(id string) (*ResourceSet, error)
func (Client) GetResourceSets ¶
func (c Client) GetResourceSets() ([]ResourceSet, error)
func (*Client) GetStorageRepository ¶
func (c *Client) GetStorageRepository(sr StorageRepository) ([]StorageRepository, error)
func (*Client) GetStorageRepositoryById ¶
func (c *Client) GetStorageRepositoryById(id string) (StorageRepository, error)
func (Client) RemoveResourceSetLimit ¶
func (c Client) RemoveResourceSetLimit(rsReq ResourceSet, limit string) error
func (Client) RemoveResourceSetObject ¶
func (c Client) RemoveResourceSetObject(rsReq ResourceSet, object string) error
func (Client) RemoveResourceSetSubject ¶
func (c Client) RemoveResourceSetSubject(rsReq ResourceSet, subject string) error
type CloudConfig ¶
type CloudConfig struct { Name string `json:"name"` Template string `json:"template"` Id string `json:"id"` }
func (CloudConfig) Compare ¶
func (c CloudConfig) Compare(obj interface{}) bool
type CloudConfigResponse ¶
type CloudConfigResponse struct {
Result []CloudConfig `json:"result"`
}
type Config ¶
func GetConfigFromEnv ¶
func GetConfigFromEnv() Config
type Installation ¶
type MemoryObject ¶
type Network ¶
type NotFoundError ¶
type NotFoundError struct { LastError error LastRequest interface{} LastResponse interface{} Message string Retries int }
func (*NotFoundError) Error ¶
func (e *NotFoundError) Error() string
type PIF ¶
type Pool ¶
type Preferences ¶
type Preferences struct {
SshKeys []SshKey `json:"sshKeys,omitempty"`
}
type ResourceSet ¶
type ResourceSet struct { Id string `json:"id"` Limits ResourceSetLimits `json:"limits"` Name string `json:"name"` Subjects []string `json:"subjects"` Objects []string `json:"objects"` }
func (ResourceSet) Compare ¶
func (rs ResourceSet) Compare(obj interface{}) bool
type ResourceSetLimit ¶
type ResourceSetLimits ¶
type ResourceSetLimits struct { Cpus ResourceSetLimit `json:"cpus,omitempty"` Memory ResourceSetLimit `json:"memory,omitempty"` Disk ResourceSetLimit `json:"disk,omitempty"` }
type StateChangeConf ¶
type StateChangeConf struct { Delay time.Duration // Wait this time before starting checks Pending []string // States that are "allowed" and will continue trying Refresh StateRefreshFunc // Refreshes the current state Target []string // Target state Timeout time.Duration // The amount of time to wait before timeout MinTimeout time.Duration // Smallest time to wait before refreshes PollInterval time.Duration // Override MinTimeout/backoff and only poll this often NotFoundChecks int // Number of times to allow not found // This is to work around inconsistent APIs ContinuousTargetOccurence int // Number of times the Target state has to occur continuously }
StateChangeConf is the configuration struct used for `WaitForState`.
func (*StateChangeConf) WaitForState ¶
func (conf *StateChangeConf) WaitForState() (interface{}, error)
WaitForState watches an object and waits for it to achieve the state specified in the configuration using the specified Refresh() func, waiting the number of seconds specified in the timeout configuration.
If the Refresh function returns an error, exit immediately with that error.
If the Refresh function returns a state other than the Target state or one listed in Pending, return immediately with an error.
If the Timeout is exceeded before reaching the Target state, return an error.
Otherwise, the result is the result of the first call to the Refresh function to reach the target state.
type StateRefreshFunc ¶
StateRefreshFunc is a function type used for StateChangeConf that is responsible for refreshing the item being watched for a state change.
It returns three results. `result` is any object that will be returned as the final object after waiting for state change. This allows you to return the final updated object, for example an EC2 instance after refreshing it.
`state` is the latest state of that object. And `err` is any error that may have happened while refreshing the state.
type StorageRepository ¶
type StorageRepository struct { Id string `json:"id"` Uuid string `json:"uuid"` NameLabel string `json:"name_label"` PoolId string `json:"$poolId"` SRType string `json:"SR_type"` Tags []string `json:"tags,omitempty"` }
func (StorageRepository) Compare ¶
func (s StorageRepository) Compare(obj interface{}) bool
type Template ¶
type Template struct { Id string `json:"id"` Uuid string `json:"uuid"` NameLabel string `json:"name_label"` PoolId string `json:"$poolId"` TemplateInfo TemplateInfo `json:"template_info"` }
type TemplateDisk ¶
type TemplateInfo ¶
type TemplateInfo struct { Arch string `json:"arch"` Disks []TemplateDisk `json:"disks"` }
type TimeoutError ¶
type TimeoutError struct { LastError error LastState string Timeout time.Duration ExpectedState []string }
TimeoutError is returned when WaitForState times out
func (*TimeoutError) Error ¶
func (e *TimeoutError) Error() string
type UnexpectedStateError ¶
UnexpectedStateError is returned when Refresh returns a state that's neither in Target nor Pending
func (*UnexpectedStateError) Error ¶
func (e *UnexpectedStateError) Error() string
type User ¶
type VBD ¶
type VBD struct { Id string `json:"id"` Attached bool Device string ReadOnly bool `json:"read_only"` VmId string `json:"VM"` VDI string `json:"VDI"` IsCdDrive bool `json:"is_cd_drive"` Position string Bootable bool PoolId string `json:"$poolId"` }
TODO: Change this file to storage or disks?
type VDI ¶
type VIF ¶
type Vm ¶
type Vm struct { Addresses map[string]string `json:"addresses,omitempty"` Type string `json:"type,omitempty"` Id string `json:"id,omitempty"` AffinityHost string `json:"affinityHost,omitempty"` NameDescription string `json:"name_description"` NameLabel string `json:"name_label"` CPUs CPUs `json:"CPUs"` Memory MemoryObject `json:"memory"` PowerState string `json:"power_state"` VIFs []string `json:"VIFs"` VBDs []string `json:"$VBDs"` VirtualizationMode string `json:"virtualizationMode"` PoolId string `json:"$poolId"` Template string `json:"template"` AutoPoweron bool `json:"auto_poweron"` HA string `json:"high_availability"` CloudConfig string `json:"cloudConfig"` ResourceSet string `json:"resourceSet,omitempty"` Tags []string `json:"tags"` // These fields are used for passing in disk inputs when // creating Vms, however, this is not a real field as far // as the XO api or XAPI is concerned Disks []Disk `json:"-"` CloudNetworkConfig string `json:"-"` VIFsMap []map[string]string `json:"-"` WaitForIps bool `json:"-"` Installation Installation `json:"-"` }