forked from xenserver/go-xenserver-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
host.go
46 lines (39 loc) · 1.06 KB
/
host.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package client
import (
"github.com/nilshell/xmlrpc"
)
type Host XenAPIObject
func (self *Host) CallPlugin(plugin, method string, params map[string]string) (response string, err error) {
result := APIResult{}
params_rec := make(xmlrpc.Struct)
for key, value := range params {
params_rec[key] = value
}
err = self.Client.APICall(&result, "host.call_plugin", self.Ref, plugin, method, params_rec)
if err != nil {
return "", err
}
response = result.Value.(string)
return
}
func (self *Host) GetAddress() (address string, err error) {
result := APIResult{}
err = self.Client.APICall(&result, "host.get_address", self.Ref)
if err != nil {
return "", err
}
address = result.Value.(string)
return address, nil
}
func (self *Host) GetSoftwareVersion() (versions map[string]interface{}, err error) {
versions = make(map[string]interface{})
result := APIResult{}
err = self.Client.APICall(&result, "host.get_software_version", self.Ref)
if err != nil {
return nil, err
}
for k, v := range result.Value.(xmlrpc.Struct) {
versions[k] = v.(string)
}
return
}