-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvapp.go
88 lines (69 loc) · 2.52 KB
/
vapp.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
package vcloudoslicenses
import (
"encoding/xml"
"net/url"
)
type AdminVAppRecord struct {
XMLName string `xml:"AdminVAppRecord"`
VDCName string `xml:"vdcName,attr"`
VDC string `xml:"vdc,attr"`
StorageKB string `xml:"storageKB,attr"`
Status string `xml:"status,attr"`
OwnerName string `xml:"ownerName,attr"`
Org string `xml:"org,attr"`
NumberOfVMs uint `xml:"numberOfVMs,attr"`
Name string `xml:"name,attr"`
MemoryAllocationMB string `xml:"memoryAllocationMB,attr"`
IsExpired string `xml:"isExpired,attr"`
IsEnabled string `xml:"isEnabled,attr"`
IsDeployed string `xml:"isDeployed,attr"`
CreationDate string `xml:"creationDate,attr"`
Href string `xml:"href,attr"`
NumberOfCpus string `xml:"numberOfCpus,attr"`
}
type VAppQueryResultsRecords struct {
XMLName string `xml:"QueryResultRecords"`
Records []*AdminVAppRecord `xml:"AdminVAppRecord"`
}
type VmOS struct {
XMLName string `xml:"OperatingSystemSection"`
Id string `xml:"id,attr"`
Type string `xml:"type,attr"`
Href string `xml:"href,attr"`
OSType string `xml:"osType,attr"`
}
type VAppVm struct {
XMLName string `xml:"Vm"`
Deployed string `xml:"deployed,attr"`
Status string `xml:"status,attr"`
Name string `xml:"name,attr"`
Id string `xml:"id,attr"`
Type string `xml:"type,attr"`
Href string `xml:"href,attr"`
OperatingSystemSection *VmOS `xml:"OperatingSystemSection"`
}
type VAppChildren struct {
XMLName string `xml:"Children"`
VM []*VAppVm `xml:"Vm"`
}
type VDCVApp struct {
XMLName string `xml:"VApp"`
Deployed string `xml:"deployed,attr"`
Status string `xml:"status,attr"`
Name string `xml:"name,attr"`
Id string `xml:"id,attr"`
Type string `xml:"type,attr"`
Href string `xml:"href,attr"`
VMs VAppChildren `xml:"Children"`
}
func (a *VDCVApp) Get (session *VCloudSession, vdc *VdcResourceEntity) {
r, _ := session.Get(vdc.Href)
defer r.Body.Close()
_ = xml.NewDecoder(r.Body).Decode(a)
for k1, v1 := range a.VMs.VM {
u, _ := url.Parse(v1.Href)
a.VMs.VM[k1].Href = u.Path
u, _ = url.Parse(v1.OperatingSystemSection.Href)
a.VMs.VM[k1].OperatingSystemSection.Href = u.Path
}
}