Documentation
¶
Index ¶
- Constants
- func CreateUser(user *User)
- func FindHostForTests(hostId string, host *Host)
- func FindNetworkForTests(poolId string, network *Network)
- 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 GetVmPowerState(c *Client, id string) func() (result interface{}, state string, err error)
- 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
- func RemoveVmsWithNamePrefix(prefix string) func(string) error
- type Acl
- type Boot
- 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) GetCurrentUser() (*User, 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) GetPools(pool Pool) (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) GetSortedHosts(host Host, sortBy, sortOrder string) (hosts []Host, err 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 Vm) ([]Vm, error)
- func (c *Client) HaltVm(vmReq 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) StartVm(id string) error
- func (c *Client) UpdateVDI(d Disk) error
- func (c *Client) UpdateVm(vmReq Vm) (*Vm, error)
- type CloudConfig
- type CloudConfigResponse
- type Config
- type CpuInfo
- type Disk
- type FlatResourceSet
- type Host
- type HostMemoryObject
- 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 Videoram
- type Vm
- type XOClient
- type XoObject
Constants ¶
const ( // Maximum message size allowed from peer. MaxMessageSize = 4096 PongWait = 60 * time.Second )
Variables ¶
This section is empty.
Functions ¶
func CreateUser ¶
func CreateUser(user *User)
func FindHostForTests ¶
func FindNetworkForTests ¶
func FindOrCreateVmForTests ¶
func FindPoolForTests ¶
func FindPoolForTests(pool *Pool)
func FindStorageRepositoryForTests ¶
func FindStorageRepositoryForTests(pool Pool, sr *StorageRepository, tag string)
func FindTemplateForTests ¶
func GetVmPowerState ¶
func RemoveTagFromAllObjects ¶
func RemoveUsersWithPrefix ¶
func RemoveVmsWithNamePrefix ¶
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) GetCurrentUser ¶
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) GetSortedHosts ¶
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 FlatResourceSet ¶
type FlatResourceSet struct {
Id string
}
This resource set type is used to allow differentiating between when a user wants to remove a resource set from a VM (during an update) and when a resource set parameter should be omitted from a vm.set RPC call.
func (*FlatResourceSet) MarshalJSON ¶
func (rs *FlatResourceSet) MarshalJSON() ([]byte, error)
func (*FlatResourceSet) String ¶
func (rs *FlatResourceSet) String() string
This ensures when a FlatResourceSet is printed in debug logs that the string value of the Id is used rather than the pointer value. Since the purpose of this struct is to flatten resource sets to a string, it makes the logs properly reflect what is being logged.
func (*FlatResourceSet) UnmarshalJSON ¶
func (rs *FlatResourceSet) UnmarshalJSON(data []byte) (err error)
type Host ¶
type Host struct { Id string `json:"id"` NameLabel string `json:"name_label"` Tags []interface{} `json:"tags,omitempty"` Pool string `json:"$pool"` Memory HostMemoryObject `json:"memory"` Cpus CpuInfo `json:"cpus"` }
type HostMemoryObject ¶
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"` Container string `json:"$container"` PhysicalUsage float64 `json:"physical_usage"` Size float64 `json:"size"` Usage float64 `json:"usage"` 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 Videoram ¶
type Videoram struct {
Value float64 `json:"-"`
}
The XO api sometimes returns the videoram field as an float64 and sometimes as a string. This overrides the default json unmarshalling so that we can handle both of these cases
func (*Videoram) UnmarshalJSON ¶
type Vm ¶
type Vm struct { Addresses map[string]string `json:"addresses,omitempty"` BlockedOperations map[string]string `json:"blockedOperations,omitempty"` Boot Boot `json:"boot,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"` ExpNestedHvm bool `json:"expNestedHvm,omitempty"` 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 *FlatResourceSet `json:"resourceSet"` // TODO: (#145) Uncomment this once issues with secure_boot have been figured out // SecureBoot bool `json:"secureBoot,omitempty"` Tags []string `json:"tags"` Videoram Videoram `json:"videoram,omitempty"` Vga string `json:"vga,omitempty"` StartDelay int `json:"startDelay,omitempty"` Host string `json:"$container"` // 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:"-"` }
type XOClient ¶
type XOClient interface { GetObjectsWithTags(tags []string) ([]Object, error) GetAllObjectsOfType(obj XoObject, response interface{}) error CreateVm(vmReq Vm, d time.Duration) (*Vm, error) GetVm(vmReq Vm) (*Vm, error) GetVms(vm Vm) ([]Vm, error) UpdateVm(vmReq Vm) (*Vm, error) DeleteVm(id string) error HaltVm(vmReq Vm) error StartVm(id string) error GetCloudConfigByName(name string) ([]CloudConfig, error) CreateCloudConfig(name, template string) (*CloudConfig, error) GetCloudConfig(id string) (*CloudConfig, error) DeleteCloudConfig(id string) error GetAllCloudConfigs() ([]CloudConfig, error) GetHostById(id string) (host Host, err error) GetHostByName(nameLabel string) (hosts []Host, err error) GetPools(pool Pool) ([]Pool, error) GetPoolByName(name string) (pools []Pool, err error) GetSortedHosts(host Host, sortBy, sortOrder string) (hosts []Host, err error) CreateResourceSet(rsReq ResourceSet) (*ResourceSet, error) GetResourceSets() ([]ResourceSet, error) GetResourceSet(rsReq ResourceSet) ([]ResourceSet, error) GetResourceSetById(id string) (*ResourceSet, error) DeleteResourceSet(rsReq ResourceSet) error AddResourceSetSubject(rsReq ResourceSet, subject string) error AddResourceSetObject(rsReq ResourceSet, object string) error AddResourceSetLimit(rsReq ResourceSet, limit string, quantity int) error RemoveResourceSetSubject(rsReq ResourceSet, subject string) error RemoveResourceSetObject(rsReq ResourceSet, object string) error RemoveResourceSetLimit(rsReq ResourceSet, limit string) error CreateUser(user User) (*User, error) GetAllUsers() ([]User, error) GetUser(userReq User) (*User, error) GetCurrentUser() (*User, error) DeleteUser(userReq User) error CreateNetwork(netReq Network) (*Network, error) GetNetwork(netReq Network) (*Network, error) GetNetworks() ([]Network, error) DeleteNetwork(id string) error GetPIF(pifReq PIF) (pifs []PIF, err error) GetPIFByDevice(dev string, vlan int) ([]PIF, error) GetStorageRepository(sr StorageRepository) ([]StorageRepository, error) GetStorageRepositoryById(id string) (StorageRepository, error) GetTemplate(template Template) ([]Template, error) GetVDIs(vdiReq VDI) ([]VDI, error) UpdateVDI(d Disk) error CreateAcl(acl Acl) (*Acl, error) GetAcl(aclReq Acl) (*Acl, error) DeleteAcl(acl Acl) error AddTag(id, tag string) error RemoveTag(id, tag string) error GetDisks(vm *Vm) ([]Disk, error) CreateDisk(vm Vm, d Disk) (string, error) DeleteDisk(vm Vm, d Disk) error ConnectDisk(d Disk) error DisconnectDisk(d Disk) error GetVIF(vifReq *VIF) (*VIF, error) GetVIFs(vm *Vm) ([]VIF, error) CreateVIF(vm *Vm, vif *VIF) (*VIF, error) DeleteVIF(vifReq *VIF) (err error) DisconnectVIF(vifReq *VIF) (err error) ConnectVIF(vifReq *VIF) (err error) GetCdroms(vm *Vm) ([]Disk, error) EjectCd(id string) error InsertCd(vmId, cdId string) error }