client

package
v1.9.0 Latest Latest
Warning

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

Go to latest
Published: Dec 2, 2025 License: MIT Imports: 23 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Maximum message size allowed from peer.
	MaxMessageSize = 4096
	PongWait       = 60 * time.Second
)
View Source
const (
	HaltedPowerState    string = "Halted"
	PausedPowerState    string = "Paused"
	RunningPowerState   string = "Running"
	SuspendedPowerState string = "Suspended"
)
View Source
const (
	WaitingState string = "Waiting"
	ReadyState   string = "Ready"
)
View Source
const (
	CloneTypeFastClone string = "fast"
	CloneTypeFullClone string = "full"
)

Variables

This section is empty.

Functions

func CreateUserForTests added in v1.5.0

func CreateUserForTests(user *User)

func FindHostForTests

func FindHostForTests(hostId string, host *Host)

func FindIsoStorageRepositoryForTests

func FindIsoStorageRepositoryForTests(pool Pool, sr *StorageRepository, tag, isoSrEnvVar string)

func FindNetworkForTests

func FindNetworkForTests(poolId string, network *Network)

func FindOrCreateVmForTests

func FindOrCreateVmForTests(vm *Vm, poolId, srId, templateName, tag string)

func FindPIFForTests

func FindPIFForTests(pif *PIF)

func FindPoolForTests

func FindPoolForTests(pool *Pool)

func FindStorageRepositoryForTests

func FindStorageRepositoryForTests(pool Pool, sr *StorageRepository, tag string)

func FindTemplateForTests

func FindTemplateForTests(template *Template, poolId, templateEnvVar string)

func FindVDIForTests

func FindVDIForTests(pool Pool, isoVdi *VDI, isoNameEnvVar string)

func GetVmPowerState

func GetVmPowerState(c *Client, id string) func() (result interface{}, state string, err error)

func RemoveCloudConfigsWithPrefix

func RemoveCloudConfigsWithPrefix(cloudConfigPrefix string) func(string) error

func RemoveNetworksWithNamePrefixForTests added in v1.5.0

func RemoveNetworksWithNamePrefixForTests(prefix string) func(string) error

func RemoveResourceSetsWithNamePrefixForTests added in v1.5.0

func RemoveResourceSetsWithNamePrefixForTests(rsNamePrefix string) func(string) error

func RemoveTagFromAllObjectsForTests added in v1.5.0

func RemoveTagFromAllObjectsForTests(tag string) func(string) error

func RemoveUsersWithPrefixForTests added in v1.5.0

func RemoveUsersWithPrefixForTests(usernamePrefix string) func(string) error

func RemoveVDIsWithPrefixForTests added in v1.5.0

func RemoveVDIsWithPrefixForTests(prefix string) func(string) error

func RemoveVmsWithNamePrefixForTests added in v1.5.0

func RemoveVmsWithNamePrefixForTests(prefix string) func(string) error

Types

type Acl

type Acl struct {
	Id      string
	Action  string
	Subject string
	Object  string
}

func (Acl) Compare

func (acl Acl) Compare(obj interface{}) bool

type Bond added in v1.2.0

type Bond struct {
	Master string `json:"master"`
	Mode   string `json:"mode"`
	Id     string `json:"id"`
	Uuid   string `json:"uuid"`
	PoolId string `json:"$poolId"`
}

func (Bond) Compare added in v1.2.0

func (b Bond) Compare(obj interface{}) bool

type Boot

type Boot struct {
	Firmware string `json:"firmware,omitempty"`
}

type CPUs

type CPUs struct {
	Number int `json:"number"`
	Max    int `json:"max"`
}

type Client

type Client struct {
	RetryMode    RetryMode
	RetryMaxTime time.Duration
	// 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) AddTag

func (c *Client) AddTag(id, tag string) error

func (*Client) Call

func (c *Client) Call(method string, params, result interface{}) error

func (*Client) ConnectDisk

func (c *Client) ConnectDisk(d Disk) error

func (*Client) ConnectVIF

func (c *Client) ConnectVIF(vifReq *VIF) (err error)

func (*Client) CreateAcl

func (c *Client) CreateAcl(acl Acl) (*Acl, error)

func (*Client) CreateBondedNetwork

func (c *Client) CreateBondedNetwork(netReq CreateBondedNetworkRequest) (*Network, error)

func (*Client) CreateCloudConfig

func (c *Client) CreateCloudConfig(name, template string) (*CloudConfig, error)

func (*Client) CreateDisk

func (c *Client) CreateDisk(vm Vm, d Disk) (string, error)

func (*Client) CreateNetwork

func (c *Client) CreateNetwork(netReq CreateNetworkRequest) (*Network, error)

func (Client) CreateResourceSet

func (c Client) CreateResourceSet(rsReq ResourceSet) (*ResourceSet, error)

func (*Client) CreateUser

func (c *Client) CreateUser(user User) (*User, error)

func (*Client) CreateVDI

func (c *Client) CreateVDI(vdiReq CreateVDIReq) (VDI, error)

func (*Client) CreateVIF

func (c *Client) CreateVIF(vm *Vm, vif *VIF) (*VIF, error)

func (*Client) CreateVm

func (c *Client) CreateVm(vmReq Vm, createTime time.Duration) (*Vm, error)

func (*Client) DeleteAcl

func (c *Client) DeleteAcl(acl Acl) error

func (*Client) DeleteCloudConfig

func (c *Client) DeleteCloudConfig(id string) error

func (*Client) DeleteDisk

func (c *Client) DeleteDisk(vm Vm, d Disk) error

DeleteDisk detaches the specified disk from the given virtual machine if it is attached, and then deletes the disk's VDI. Returns an error if any operation fails.

func (*Client) DeleteNetwork

func (c *Client) DeleteNetwork(id string) error

func (Client) DeleteResourceSet

func (c Client) DeleteResourceSet(rsReq ResourceSet) error

func (*Client) DeleteUser

func (c *Client) DeleteUser(user User) error

func (*Client) DeleteVDI

func (c *Client) DeleteVDI(id string) error

func (*Client) DeleteVIF

func (c *Client) DeleteVIF(vifReq *VIF) (err error)

func (*Client) DeleteVm

func (c *Client) DeleteVm(id string) error

func (*Client) DisconnectDisk

func (c *Client) DisconnectDisk(d Disk) error

func (*Client) DisconnectVIF

func (c *Client) DisconnectVIF(vifReq *VIF) (err error)

func (*Client) EjectCd

func (c *Client) EjectCd(id string) error

func (*Client) EjectVmCd

func (c *Client) EjectVmCd(vm *Vm) error

func (*Client) FindFromGetAllObjects

func (c *Client) FindFromGetAllObjects(obj XoObject) (interface{}, error)

func (*Client) GetAcl

func (c *Client) GetAcl(aclReq Acl) (*Acl, error)

func (*Client) GetAcls

func (c *Client) GetAcls() ([]Acl, error)

func (*Client) GetAllCloudConfigs

func (c *Client) GetAllCloudConfigs() ([]CloudConfig, error)

func (*Client) GetAllObjectsOfType

func (c *Client) GetAllObjectsOfType(obj XoObject, response interface{}) error

func (*Client) GetAllUsers

func (c *Client) GetAllUsers() ([]User, error)

func (*Client) GetAllVDIs

func (c *Client) GetAllVDIs() ([]VDI, error)

func (*Client) GetBond added in v1.2.0

func (c *Client) GetBond(bondReq Bond) (*Bond, error)

func (*Client) GetBonds added in v1.2.0

func (c *Client) GetBonds(bondReq Bond) ([]Bond, error)

func (*Client) GetCdroms

func (c *Client) GetCdroms(vm *Vm) ([]Disk, error)

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 (c *Client) GetCurrentUser() (*User, error)

func (*Client) GetDisks

func (c *Client) GetDisks(vm *Vm) ([]Disk, error)

func (*Client) GetHostById

func (c *Client) GetHostById(id string) (host Host, err error)

func (*Client) GetHostByName

func (c *Client) GetHostByName(nameLabel string) (hosts []Host, err error)

func (*Client) GetNetwork

func (c *Client) GetNetwork(netReq Network) (*Network, error)

func (*Client) GetNetworks

func (c *Client) GetNetworks() ([]Network, error)

func (*Client) GetObjectsWithTags

func (c *Client) GetObjectsWithTags(tags []string) ([]Object, error)

func (*Client) GetPIF

func (c *Client) GetPIF(pifReq PIF) (pifs []PIF, err error)

func (*Client) GetPIFByDevice

func (c *Client) GetPIFByDevice(dev string, vlan int) ([]PIF, error)

func (*Client) GetParentVDI

func (c *Client) GetParentVDI(vbd VBD) (VDI, error)

func (*Client) GetPoolByName

func (c *Client) GetPoolByName(name string) (pools []Pool, err error)

func (*Client) GetPools

func (c *Client) GetPools(pool Pool) (pools []Pool, err error)

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 (c *Client) GetSortedHosts(host Host, sortBy, sortOrder string) (hosts []Host, err 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) GetTemplate

func (c *Client) GetTemplate(template Template) ([]Template, error)

func (*Client) GetTemplateVBDs added in v1.7.0

func (c *Client) GetTemplateVBDs(template Template) (map[string]VBD, error)

GetTemplateVBDs retrieves all VBDs for a given template and returns them as a map where the key is the VBD's position.

func (*Client) GetUser

func (c *Client) GetUser(userReq User) (*User, error)

func (*Client) GetVBD added in v1.5.1

func (c *Client) GetVBD(vbdReq VBD) (VBD, error)

func (*Client) GetVDI

func (c *Client) GetVDI(vdiReq VDI) (VDI, error)

func (*Client) GetVDIs

func (c *Client) GetVDIs(vdiReq VDI) ([]VDI, error)

func (*Client) GetVIF

func (c *Client) GetVIF(vifReq *VIF) (*VIF, error)

func (*Client) GetVIFs

func (c *Client) GetVIFs(vm *Vm) ([]VIF, error)

func (*Client) GetVm

func (c *Client) GetVm(vmReq Vm) (*Vm, error)

func (*Client) GetVms

func (c *Client) GetVms(vm Vm) ([]Vm, error)

func (*Client) HaltVm

func (c *Client) HaltVm(id string) error

func (*Client) InsertCd

func (c *Client) InsertCd(vmId, cdId string) error

func (*Client) IsRetryableError

func (c *Client) IsRetryableError(err jsonrpc2.Error) bool

func (*Client) PauseVm

func (c *Client) PauseVm(id string) 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

func (*Client) RemoveTag

func (c *Client) RemoveTag(id, tag string) error

func (*Client) ResizeVDI added in v1.3.0

func (c *Client) ResizeVDI(d Disk) error

func (*Client) StartVm

func (c *Client) StartVm(id string) error

func (*Client) SuspendVm

func (c *Client) SuspendVm(id string) error

func (*Client) UpdateNetwork

func (c *Client) UpdateNetwork(netReq UpdateNetworkRequest) (*Network, error)

func (*Client) UpdateVDI

func (c *Client) UpdateVDI(d Disk) error

func (*Client) UpdateVm

func (c *Client) UpdateVm(vmReq Vm) (*Vm, 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

type Config struct {
	Url                string
	Username           string
	Password           string
	Token              string
	InsecureSkipVerify bool
	RetryMode          RetryMode
	RetryMaxTime       time.Duration
}

func GetConfigFromEnv

func GetConfigFromEnv() Config

type CpuInfo

type CpuInfo struct {
	Cores   int64 `json:"cores"`
	Sockets int64 `json:"sockets"`
}

type CreateBondedNetworkRequest

type CreateBondedNetworkRequest struct {
	// The first set of members are shared between bonded and non bonded networks
	// These should be kept in sync with the CreateNetworkRequest struct
	Automatic       bool   `mapstructure:"automatic"`
	DefaultIsLocked bool   `mapstructure:"defaultIsLocked"`
	Pool            string `mapstructure:"pool"`
	Name            string `mapstructure:"name"`
	Description     string `mapstructure:"description,omitempty"`
	Mtu             int    `mapstructure:"mtu,omitempty"`

	BondMode string   `mapstructure:"bondMode,omitempty"`
	PIFs     []string `mapstructure:"pifs,omitempty"`
}

func (CreateBondedNetworkRequest) Propagated

func (c CreateBondedNetworkRequest) Propagated(obj interface{}) bool

type CreateNetworkRequest

type CreateNetworkRequest struct {
	// The first set of members are shared between bonded and non bonded networks
	// These should be kept in sync with the CreateBondedNetworkRequest struct
	// Refactoring these fields to an embedded struct means that the caller must
	// know the embedded structs existence. Since the list is relatively small
	// this was deemed a more appropriate tradeoff to make the API nicer.
	Automatic       bool   `mapstructure:"automatic"`
	DefaultIsLocked bool   `mapstructure:"defaultIsLocked"`
	Pool            string `mapstructure:"pool"`
	Name            string `mapstructure:"name"`
	Description     string `mapstructure:"description,omitempty"`
	Mtu             int    `mapstructure:"mtu,omitempty"`

	Nbd  bool   `mapstructure:"nbd,omitempty"`
	PIF  string `mapstructure:"pif,omitempty"`
	Vlan int    `mapstructure:"vlan,omitempty"`
}

func (CreateNetworkRequest) Propagated

func (c CreateNetworkRequest) Propagated(obj interface{}) bool

Nbd and Automatic are eventually consistent. This ensures that waitForModifyNetwork will poll until the values are correct.

type CreateVDIReq

type CreateVDIReq struct {
	SRId      string
	Filepath  string
	Type      string
	NameLabel string
}

type Disk

type Disk struct {
	VBD
	VDI
}

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"`
}

func (Host) Compare

func (h Host) Compare(obj interface{}) bool

type HostMemoryObject

type HostMemoryObject struct {
	Usage int `json:"usage"`
	Size  int `json:"size"`
}

type Installation

type Installation struct {
	Method     string `json:"-"`
	Repository string `json:"-"`
}

type MemoryObject

type MemoryObject struct {
	// Value at index 0 is the min limit, Value at index 1 is the max limit
	Dynamic []int `json:"dynamic"`
	// Value at index 0 is the min limit, Value at index 1 is the max limit
	Static []int `json:"static"`
	Size   int   `json:"size"`
}

type Network

type Network struct {
	Automatic       bool     `json:"automatic,omitempty"`
	Id              string   `json:"id"`
	NameLabel       string   `json:"name_label"`
	NameDescription string   `json:"name_description"`
	Bridge          string   `json:"bridge"`
	DefaultIsLocked bool     `json:"defaultIsLocked"`
	PoolId          string   `json:"$poolId"`
	MTU             int      `json:"MTU"`
	PIFs            []string `json:"PIFs"`
	Nbd             bool     `json:"nbd"`
	InsecureNbd     bool     `json:"insecureNbd"`
}

func (Network) Compare

func (net Network) Compare(obj interface{}) bool

type NotFound

type NotFound struct {
	Query XoObject
}

func (NotFound) Error

func (e NotFound) Error() string

type NotFoundError

type NotFoundError struct {
	LastError    error
	LastRequest  interface{}
	LastResponse interface{}
	Message      string
	Retries      int
}

func (*NotFoundError) Error

func (e *NotFoundError) Error() string

type Object

type Object struct {
	Id   string
	Type string
}

type PIF

type PIF struct {
	Device       string   `json:"device"`
	Host         string   `json:"$host"`
	Network      string   `json:"$network"`
	Id           string   `json:"id"`
	Uuid         string   `json:"uuid"`
	PoolId       string   `json:"$poolId"`
	Attached     bool     `json:"attached"`
	Vlan         int      `json:"vlan"`
	IsBondMaster bool     `json:"isBondMaster,omitempty"`
	IsBondSlave  bool     `json:"isBondSlave,omitempty"`
	BondSlaves   []string `json:"bondSlaves,omitempty"`
	BondMaster   string   `json:"bondMaster,omitempty"`
}

func (PIF) Compare

func (p PIF) Compare(obj interface{}) bool

type Pool

type Pool struct {
	Id          string  `json:"id"`
	NameLabel   string  `json:"name_label"`
	Description string  `json:"name_description"`
	Cpus        CpuInfo `json:"cpus"`
	DefaultSR   string  `json:"default_SR"`
	Master      string  `json:"master"`
}

func (Pool) Compare

func (p Pool) Compare(obj interface{}) bool

type Preferences

type Preferences struct {
	SshKeys []SshKey `json:"sshKeys,omitempty"`
}

type RefreshComparison

type RefreshComparison interface {
	Propagated(obj interface{}) bool
}

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 ResourceSetLimit struct {
	Available int `json:"available,omitempty"`
	Total     int `json:"total,omitempty"`
}

type ResourceSetLimits

type ResourceSetLimits struct {
	Cpus   ResourceSetLimit `json:"cpus,omitempty"`
	Memory ResourceSetLimit `json:"memory,omitempty"`
	Disk   ResourceSetLimit `json:"disk,omitempty"`
}

type RetryMode

type RetryMode int
const (
	None RetryMode = iota // specifies that no retries will be made
	// Specifies that exponential backoff will be used for certain retryable errors. When
	// a guest is booting there is the potential for a race condition if the given action
	// relies on the existence of a PV driver (unplugging / plugging a device). This open
	// allows the provider to retry these errors until the guest is initialized.
	Backoff
)

type SshKey

type SshKey struct {
	Title string
	Key   string
}

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
	// contains filtered or unexported fields
}

StateChangeConf is the configuration struct used for `WaitForState`.

func (*StateChangeConf) Logger added in v1.5.0

func (conf *StateChangeConf) Logger() *slog.Logger

Use this method to avoid nil pointer

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

type StateRefreshFunc func() (result interface{}, state string, err error)

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 int      `json:"physical_usage"`
	Size          int      `json:"size"`
	Usage         int      `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"`
	Boot         TemplateBoot `json:"boot"`
	NameLabel    string       `json:"name_label"`
	PoolId       string       `json:"$poolId"`
	TemplateInfo TemplateInfo `json:"template_info"`
	// Array of VDI ids
	VBDs []string `json:"$VBDs"`
}

func (Template) Compare

func (t Template) Compare(obj interface{}) bool

type TemplateBoot added in v1.7.0

type TemplateBoot struct {
	Firmware string `json:"firmware"`
	Order    string `json:"order"`
}

type TemplateDisk

type TemplateDisk struct {
	Bootable bool   `json:"bootable"`
	Device   string `json:"device"`
	Size     int    `json:"size"`
	Type     string `json:"type"`
	SR       string `json:"SR"`
}

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

type UnexpectedStateError struct {
	LastError     error
	State         string
	ExpectedState []string
}

UnexpectedStateError is returned when Refresh returns a state that's neither in Target nor Pending

func (*UnexpectedStateError) Error

func (e *UnexpectedStateError) Error() string

type UpdateNetworkRequest

type UpdateNetworkRequest struct {
	Id              string  `mapstructure:"id"`
	Automatic       bool    `mapstructure:"automatic"`
	DefaultIsLocked *bool   `mapstructure:"defaultIsLocked,omitempty"`
	NameDescription *string `mapstructure:"name_description,omitempty"`
	NameLabel       *string `mapstructure:"name_label,omitempty"`
	Nbd             bool    `mapstructure:"nbd"`
}

func (UpdateNetworkRequest) Propagated

func (c UpdateNetworkRequest) Propagated(obj interface{}) bool

Nbd and Automatic are eventually consistent. This ensures that waitForModifyNetwork will poll until the values are correct.

type User

type User struct {
	Id          string
	Email       string
	Password    string `json:"-"`
	Groups      []string
	Permission  string
	Preferences Preferences
}

func (User) Compare

func (user User) Compare(obj interface{}) bool

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 `json:"position,omitempty"`
	Bootable  bool
	PoolId    string `json:"$poolId"`
}

TODO: Change this file to storage or disks?

func (VBD) Compare

func (v VBD) Compare(obj interface{}) bool

type VDI

type VDI struct {
	VDIId           string   `json:"id"`
	SrId            string   `json:"$SR"`
	NameLabel       string   `json:"name_label"`
	NameDescription string   `json:"name_description"`
	Size            int      `json:"size"`
	VBDs            []string `json:"$VBDs"`
	Parent          string   `json:"parent,omitempty"`
	PoolId          string   `json:"$poolId"`
	Tags            []string `json:"tags,omitempty"`
}

func (VDI) Compare

func (v VDI) Compare(obj interface{}) bool

type VIF

type VIF struct {
	Id         string `json:"id"`
	Attached   bool   `json:"attached"`
	Network    string `json:"$network"`
	Device     string `json:"device"`
	MacAddress string `json:"MAC"`
	VmId       string `json:"$VM"`
}

func (VIF) Compare

func (v VIF) Compare(obj interface{}) bool

type Videoram

type Videoram struct {
	Value int `json:"-"`
}

The XO api sometimes returns the videoram field as an int and sometimes as a string. This overrides the default json unmarshalling so that we can handle both of these cases

func (*Videoram) UnmarshalJSON

func (v *Videoram) UnmarshalJSON(data []byte) (err error)

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"`
	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"`
	XenstoreData       map[string]interface{} `json:"xenStoreData,omitempty"`

	// 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:"-"`
	// Map where the key is the network interface index and the
	// value is a cidr range parsable by net.ParseCIDR
	WaitForIps                     map[string]string `json:"-"`
	Installation                   Installation      `json:"-"`
	ManagementAgentDetected        bool              `json:"managementAgentDetected"`
	PVDriversDetected              bool              `json:"pvDriversDetected"`
	DestroyCloudConfigVdiAfterBoot bool              `json:"-"`
	CloneType                      string            `json:"-"`
}

func (Vm) Compare

func (v Vm) Compare(obj interface{}) bool

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(id string) error
	StartVm(id string) error
	SuspendVm(id string) error
	PauseVm(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 CreateNetworkRequest) (*Network, error)
	GetNetwork(netReq Network) (*Network, error)
	UpdateNetwork(netReq UpdateNetworkRequest) (*Network, error)
	CreateBondedNetwork(netReq CreateBondedNetworkRequest) (*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)

	GetAllVDIs() ([]VDI, error)
	GetVDIs(vdiReq VDI) ([]VDI, error)
	GetVDI(vdiReq VDI) (VDI, error)
	CreateVDI(vdiReq CreateVDIReq) (VDI, error)
	UpdateVDI(d Disk) error
	ResizeVDI(d Disk) error
	DeleteVDI(id string) 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

	GetBond(bondReq Bond) (*Bond, error)
	GetBonds(bondReq Bond) ([]Bond, error)
}

func NewClient

func NewClient(config Config) (XOClient, error)

func NewClientWithLogger added in v1.5.0

func NewClientWithLogger(config Config, logger *slog.Logger) (XOClient, error)

type XoObject

type XoObject interface {
	Compare(obj interface{}) bool
}

Jump to

Keyboard shortcuts

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