Documentation
¶
Overview ¶
Package xapi is a generic binding of the Citrix XenServer API. Read more here: http://docs.vmd.citrix.com/XenServer/6.0.0/1.0/en_gb/api/
Index ¶
- func OpaqueRefIsEmpty(a string) bool
- func TimeoutDialer() func(net, addr string) (c net.Conn, err error)
- type Client
- func (client *Client) Call(result Response, call string, params ...interface{}) error
- func (client *Client) GetHost(opref string) (host Host, err error)
- func (client *Client) GetHostname(opref string) (hostname string, err error)
- func (client *Client) GetPIF(opref string) (pif PIF, err error)
- func (client *Client) GetSession() (session Session, err error)
- func (client *Client) GetVIF(opref string) (vif VIF, err error)
- func (client *Client) GetVM(opref string) (vm VM, err error)
- func (client *Client) GetVMs() (machines []string, err error)
- func (client *Client) Login() error
- func (client *Client) NextEvent() (ev []Event, err error)
- func (client *Client) RegisterEvent(classes ...interface{}) error
- func (client *Client) SessionCall(result Response, call string, params ...interface{}) (err error)
- func (client *Client) UnregisterAllEvents() error
- type Event
- type EventResponse
- type EventsResponse
- type Host
- type HostResponse
- type PIF
- type PIFResponse
- type Response
- type ResponseBase
- type Session
- type SessionResponse
- type StringResponse
- type StringsResponse
- type VDB
- type VDBResponse
- type VDI
- type VDIResponse
- type VIF
- type VIFResponse
- type VM
- type VMResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OpaqueRefIsEmpty ¶
OpaqueRefIsEmpty checks to see if a field that should be an OpaqueRef is actually empty. Sometimes it's an empty string (rare) but other times it's OpaqueRef:NULL which is good to know.
func TimeoutDialer ¶
TimeoutDialer is a custom Dialer for HTTP so that the initial connection only lasts for 1 minute and that the lifetime of the connection is only 1 minute as well. See http://golang.org/pkg/net/#Conn You shouldn't need to use this directly.
Types ¶
type Client ¶
type Client struct {
Session string
URI string
Username string
Password string
Version string
// contains filtered or unexported fields
}
Client is the Xen API client
func NewClient ¶
NewClient stand up a new XapiClient. Version should probably be "1.2" unless you know what you are doing.
func (*Client) Call ¶
Call makes a generic RPC call passing in a pointer to a struct (or f). The call parameter is a combination of class.message. For example: VIF.get_record, host.evacuate, pool.eject. Any time the XAPI specifies a `type ref` it's really an OpaqueReference, which is a UUID, and as far as xmlrpc and like library are concerned, a string.
x := xapi.NewClient("http://localhost/", "username", "password", "1.2")
host := xapi.HostResult{}
err := x.Call(&host, "host.get_record", "324c2264-d86f-4a42-a971-bb5fd6203877")
if err != nil {
fmt.Printf("%v", host)
}
func (*Client) GetHostname ¶
GetHostname gets the hostname of a Host. Useful in combination with GetSession and session.This_host
func (*Client) GetSession ¶
func (*Client) RegisterEvent ¶
func (*Client) SessionCall ¶
SessionCall is a useful for making multiple calls that require the session ID. Automatically prepends the existing session OpaqRef to the beginning of the API call. You can see the session ID by looking at Client.Session.
func (*Client) UnregisterAllEvents ¶
type EventResponse ¶
type EventResponse struct {
ResponseBase
Value Event
}
type EventsResponse ¶
type EventsResponse struct {
ResponseBase
Value []Event
}
type Host ¶
type Host struct {
Address string
AllowedOperations []string `json:"Allowed_operations"`
CurrentOperations map[string]string `json:"Current_operations"`
APIVersionMajor int `json:"API_version_major"`
APIVersionMinor int `json:"API_version_minor"`
APIVersionVendor string `json:"API_version_vendor"`
APIVersionVendorImplementation map[string]string `json:"API_version_vendor_implementation"`
BiosStrings map[string]string `json:"Bios_strings"`
Blobs map[string][]byte
Capabilities []string
ChipsetInfo map[string]string `json:"Chipset_info"`
CPUConfiguration map[string]string `json:"Cpu_configuration"`
CPUInfo map[string]string `json:"Cpu_info"`
CrashDumpSR string `json:"Crash_dump_sr"`
Crashdumps []string
Edition string
Enabled bool
ExternalAuthConfiguration map[string]string `json:"External_auth_configuration"`
ExternalAuthType string `json:"External_auth_type"`
ExternalAuthServiceName string `json:"External_auth_service_name"`
HaNetworkPeers []string `json:"Ha_network_peers"`
HaStatefiles []string `json:"Ha_statefiles"`
HostCPUs []string `json:"Host_CPUs"`
Hostname string
LicenseParams map[string]string `json:"License_params"`
LicenseServer map[string]string `json:"License_server"`
LocalCacheSR string `json:"Local_cache_sr"`
Logging map[string]string
MemoryOverhead int `json:"Memory_overhead"`
Metrics string
NameDescription string `json:"Name_description"`
NameLabel string `json:"Name_label"`
OtherConfig map[string]string `json:"Other_config"`
Patches []string
PBDs []string
PCIs []string
PGPUs []string
PIFs []string
PowerOnConfig map[string]string `json:"Power_on_config"`
ResidentVMs []string `json:"Resident_VMs"`
SchedPolicy string `json:"Sched_policy"`
SoftwareVersion map[string]string `json:"Software_version"`
SupportedBootloaders []string `json:"Supported_bootloaders"`
SuspendImageSR string `json:"Suspend_image_sr"`
UUID string `json:"uuid"`
Tags []string
}
type HostResponse ¶
type HostResponse struct {
ResponseBase
Value Host
}
type PIF ¶
type PIF struct {
BondMasterOf []string `json:"Bond_master_of"`
BondSlaveOf string `json:"Bond_slave_of"`
CurrentlyAttached bool `json:"Currently_attached"`
Device string
DisallowUnplug bool `json:"Disallow_unplug"`
DNS string
Gateway string
Host string
IP string
IPConfigurationMode string `json:"Ip_configuration_mode"`
MAC string
Management bool
Metrics string
MTU int
Netmask string
Network string
OtherConfig map[string]string `json:"Other_config"`
Physical bool
TunnelAccessPIFOf string `json:"Tunnel_access_PIF_of"`
TunnelTransportPIFOf string `json:"Tunnel_transport_PIF_of"`
UUID string `json:"uuid"`
VLAN int
VLANMasterOf string `json:"VLAN_master_of"`
VLANSlaveOf []string `json:"VLAN_slave_of"`
}
type PIFResponse ¶
type PIFResponse struct {
ResponseBase
Value PIF
}
type ResponseBase ¶
type ResponseBase struct {
// contains filtered or unexported fields
}
func (ResponseBase) ErrorDescription ¶
func (resp ResponseBase) ErrorDescription() string
func (ResponseBase) Status ¶
func (resp ResponseBase) Status() string
type Session ¶
type Session struct {
AuthUserName string `xmlrpc:"Auth_user_name"`
AuthUserSid string `xmlrpc:"Auth_user_sid"`
IsLocalSuperuser bool `xmlrpc:"Is_local_superuser"`
LastActive time.Time `xmlrpc:"Last_active"`
OtherConfig map[string]string `xmlrpc:"Other_config"`
Parent string
Pool bool
RbacPermissions []string `xmlrpc:"Rbac_permissions"`
Subject string
Tasks []string
ThisHost string `xmlrpc:"This_host"`
ThisUser string `xmlrpc:"This_user"`
UUID string `xmlrpc:"Uuid"`
ValidationTime time.Time `xmlrpc:"Validation_time"`
}
type SessionResponse ¶
type SessionResponse struct {
ResponseBase
Value Session
}
type StringResponse ¶
type StringResponse struct {
ResponseBase
Value string
}
type StringsResponse ¶
type StringsResponse struct {
ResponseBase
Value []string
}
type VDB ¶
type VDB struct {
AllowedOperations []string `xmlrpc:"Allowed_operations"`
CurrentOperations map[string]string `xmlrpc:"Current_operations"`
Bootable bool
CurrentlyAttached bool `xmlrpc:"Currently_attached"`
Device string
Empty bool
Metrics string
Mode string
OtherConfig map[string]string `xmlrpc:"Other_config"`
QosAlgorithmParams map[string]string `xmlrpc:"Qos_algorithm_params"`
QosAlgorithmType string `xmlrpc:"Qos_algorithm_type"`
QosSupportedAlgorithms []string `xmlrpc:"Qos_supported_algorithms"`
RuntimeProperties map[string]string `xmlrpc:"Runtime_properties"`
StatusCode int `xmlrpc:"Status_code"`
StatusDetail string `xmlrpc:"Status_detail"`
UUID string `json:"uuid"`
VDI string
VM string
StorageLock bool `xmlrpc:"Storage_lock"`
Type string `json:"type"`
Unpluggable bool
Userdevice string
}
type VDBResponse ¶
type VDBResponse struct {
ResponseBase
Value VDB
}
type VDI ¶
type VDI struct {
AllowCaching bool `xmlrpc:"Allow_caching"`
AllowedOperations []string `xmlrpc:"Allowed_operations"`
CrashDumps []string `xmlrpc:"Crash_dumps"`
CurrentOperations map[string]string `xmlrpc:"Current_operations"`
IsAsnapshot bool `xmlrpc:"Is_a_snapshot"`
Location string
Managed bool
MetadataLatest bool `xmlrpc:"Metadata_latest"`
Missing bool
NameDescription string `xmlrpc:"Name_description"`
NameLabel string `xmlrpc:"Name_label"`
OnBoot string `xmlrpc:"On_boot"`
OtherConfig map[string]string `xmlrpc:"Other_config"`
Parent string
PhyscialUtilisation int `xmlrpc:"Physcial_utilisation"`
ReadOnly bool `xmlrpc:"Read_only"`
Sharable bool
SmConfig map[string]string `xmlrpc:"Sm_config"`
SnapshotOf []string `xmlrpc:"Snapshot_of"`
SR []string
StorageLock bool `xmlrpc:"Storage_lock"`
Tags string
Type string `json:"type"`
UUID string `json:"uuid"`
VDBs []string
VirtualSize int `xmlrpc:"Virtual_size"`
XenstoreData map[string]string `xmlrpc:"Xenstore_data"`
}
type VDIResponse ¶
type VDIResponse struct {
ResponseBase
Value VDI
}
type VIF ¶
type VIF struct {
AllowedOperations []string `xmlrpc:"Allowed_operations"`
CurrentOperations map[string]string `xmlrpc:"Current_operations"`
CurrentlyAttached bool `xmlrpc:"Currently_attached"`
Device string
MAC string
MACAutogenerated bool `xmlrpc:"MAC_autogenerated"`
Metrics string
MTU int
Network string
OtherConfig map[string]string `xmlrpc:"Other_config"`
QosAlgorithmParams map[string]string `xmlrpc:"Qos_algorithm_params"`
QosAlgorithmType string `xmlrpc:"Qos_algorithm_type"`
QosSupportedAlgorithms []string `xmlrpc:"Qos_supported_algorithms"`
RuntimeProperties map[string]string `xmlrpc:"Runtime_properties"`
StatusCode int `xmlrpc:"Status_code"`
StatusDetail string `xmlrpc:"Status_detail"`
UUID string `json:"uuid"`
VM string
}
type VIFResponse ¶
type VIFResponse struct {
ResponseBase
Value VIF
}
type VM ¶
type VM struct {
ActionsAfterCrash string `xmlrpc:"Actions_after_crash"`
ActionsAfterReboot string `xmlrpc:"Actions_after_reboot"`
ActionsAfterShutdown string `xmlrpc:"Actions_after_shutdown"`
Affinity string
AllowedOperations []string `xmlrpc:"Allowed_operations"`
Appliance string
AttachedPCIs []string `xmlrpc:"Attached_PCIs"`
BiosStrings map[string]string `xmlrpc:"Bios_strings"`
Blobs map[string][]byte
BlockedOperations map[string]string `xmlrpc:"Blocked_operations"`
Children []string
Consoles []string
CrashDumps []string `xmlrpc:"Crash_dumps"`
CurrentOperations map[string]string `xmlrpc:"Current_operations"`
Domarch string
Domid int
GuestMetrics string `xmlrpc:"Guest_metrics"`
HaAlwaysRun bool `xmlrpc:"Ha_always_run"`
HaRestartPriority string `xmlrpc:"Ha_restart_priority"`
HVMBootParams map[string]string `xmlrpc:"HVM_boot_params"`
HVMBootPolicy string `xmlrpc:"HVM_boot_policy"`
HVMShadowMultiplier float64 `xmlrpc:"HVM_shadow_multiplier"`
IsASnapshot bool `xmlrpc:"Is_a_snapshot"`
IsATemplate bool `xmlrpc:"Is_a_template"`
IsControlDomain bool `xmlrpc:"Is_control_domain"`
IsSnapshotFromVmpp bool `xmlrpc:"Is_snapshot_from_vmpp"`
LastBootCPUFlags map[string]string `xmlrpc:"Last_boot_CPU_flags"`
LastBootedRecord string `xmlrpc:"Last_booted_record"`
MemoryDynamicMax int `xmlrpc:"Memory_dynamic_max"`
MemoryDynamicMin int `xmlrpc:"Memory_dynamic_min"`
MemoryOverhead int `xmlrpc:"Memory_overhead"`
MemoryStaticMax int `xmlrpc:"Memory_static_max"`
MemoryStaticMin int `xmlrpc:"Memory_static_min"`
MemoryTarget int `xmlrpc:"Memory_target"`
Metrics string
NameDescription string `xmlrpc:"Name_description"`
NameLabel string `xmlrpc:"Name_label"`
Order int
OtherConfig map[string]string `xmlrpc:"Other_config"`
Parent string
PCIBus string `xmlrpc:"PCI_bus"`
Platform map[string]string
PowerStatus string `xmlrpc:"Power_status"`
ProtectionPolicy string `xmlrpc:"Protection_policy"`
PVArgs string `xmlrpc:"PV_args"`
PVBootloader string `xmlrpc:"PV_bootloader"`
PVBootloaderArgs string `xmlrpc:"PV_bootloader_args"`
PVKernel string `xmlrpc:"PV_kernel"`
PVLegacyArgs string `xmlrpc:"PV_legacy_args"`
PVRamdisk string `xmlrpc:"PV_ramdisk"`
Recommendations string
ResidentOn string `xmlrpc:"Resident_on"`
ShutdownDelay int `xmlrpc:"Shutdown_delay"`
SnapshotInfo map[string]string `xmlrpc:"Snapshot_info"`
SnapshotMetadata string `xmlrpc:"Snapshot_metadata"`
SnapshotTime time.Time `xmlrpc:"Snapshot_time"`
StartDelay int `xmlrpc:"Start_delay"`
SuspendSR string `xmlrpc:"Suspend_SR"`
SuspendVDI string `xmlrpc:"Suspend_VDI"`
Tags []string
TransportableSnapshotID string `xmlrpc:"Transportable_snapshot_id"`
UserVersion int `xmlrpc:"User_version"`
UUID string `json:"uuid"`
VBDs []string
VCPUsAtStartup int `xmlrpc:"VCPUs_at_startup"`
VCPUsMax int `xmlrpc:"VCPUs_max"`
VCPUsParams map[string]string `xmlrpc:"VCPUs_params"`
Version int
VGPUs []string
VIFs []string
VTPM []string
XenstoreData map[string]string `xmlrpc:"Xenstore_data"`
}
type VMResponse ¶
type VMResponse struct {
ResponseBase
Value VM
}