-
Notifications
You must be signed in to change notification settings - Fork 0
/
ProbeResult.gen.go
90 lines (73 loc) · 2.9 KB
/
ProbeResult.gen.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
// This is a generated file. DO NOT EDIT manually.
//go:generate goimports -w ProbeResult.gen.go
package go_xen_client
import (
"reflect"
"github.com/nilshell/xmlrpc"
)
//ProbeResult: A set of properties that describe one result element of SR.probe. Result elements and properties can change dynamically based on changes to the the SR.probe input-parameters or the target.
type ProbeResult struct {
Configuration map[string]string // Plugin-specific configuration which describes where and how to locate the storage repository. This may include the physical block device name, a remote NFS server and path or an RBD storage pool.
Complete bool // True if this configuration is complete and can be used to call SR.create. False if it requires further iterative calls to SR.probe, to potentially narrow down on a configuration that can be used.
Sr interface{} // Existing SR found for this configuration
ExtraInfo map[string]string // Additional plugin-specific information about this configuration, that might be of use for an API user. This can for example include the LUN or the WWPN.
}
func FromProbeResultToXml(probe_result *ProbeResult) (result xmlrpc.Struct) {
result = make(xmlrpc.Struct)
configuration := make(xmlrpc.Struct)
for key, value := range probe_result.Configuration {
configuration[key] = value
}
result["configuration"] = configuration
result["complete"] = probe_result.Complete
result["sr"] = probe_result.Sr
extra_info := make(xmlrpc.Struct)
for key, value := range probe_result.ExtraInfo {
extra_info[key] = value
}
result["extra_info"] = extra_info
return result
}
func ToProbeResult(obj interface{}) (resultObj *ProbeResult) {
objValue := reflect.ValueOf(obj)
resultObj = &ProbeResult{}
for _, oKey := range objValue.MapKeys() {
keyName := oKey.String()
keyValue := objValue.MapIndex(oKey).Interface()
switch keyName {
case "configuration":
resultObj.Configuration = map[string]string{}
interimMap := reflect.ValueOf(keyValue).MapKeys()
for _, mapKey := range interimMap {
mapKeyName := mapKey.String()
mapKeyValue := reflect.ValueOf(keyValue).MapIndex(mapKey).Interface()
if v, ok := mapKeyValue.(string); ok {
resultObj.Configuration[mapKeyName] = v
} else {
resultObj.Configuration[mapKeyName] = ""
}
}
case "complete":
if v, ok := keyValue.(bool); ok {
resultObj.Complete = v
}
case "sr":
if v, ok := keyValue.(interface{}); ok {
resultObj.Sr = v
}
case "extra_info":
resultObj.ExtraInfo = map[string]string{}
interimMap := reflect.ValueOf(keyValue).MapKeys()
for _, mapKey := range interimMap {
mapKeyName := mapKey.String()
mapKeyValue := reflect.ValueOf(keyValue).MapIndex(mapKey).Interface()
if v, ok := mapKeyValue.(string); ok {
resultObj.ExtraInfo[mapKeyName] = v
} else {
resultObj.ExtraInfo[mapKeyName] = ""
}
}
}
}
return resultObj
}