Skip to content

Commit d0a8e7d

Browse files
authored
Better fix for #4 that also work on 4.12. (#6)
1 parent 46b776e commit d0a8e7d

1 file changed

Lines changed: 72 additions & 60 deletions

File tree

cloudstack/HostService.go

Lines changed: 72 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ type AddBaremetalHostResponse struct {
215215
Jobstatus int `json:"jobstatus"`
216216
Lastannotated string `json:"lastannotated"`
217217
Lastpinged string `json:"lastpinged"`
218-
Managementserverid string `json:"managementserverid"`
218+
Managementserverid ManagementServerId `json:"managementserverid"`
219219
Memoryallocated int64 `json:"memoryallocated"`
220220
Memoryallocatedbytes int64 `json:"memoryallocatedbytes"`
221221
Memoryallocatedpercentage string `json:"memoryallocatedpercentage"`
@@ -537,7 +537,7 @@ type AddHostResponse struct {
537537
Jobstatus int `json:"jobstatus"`
538538
Lastannotated string `json:"lastannotated"`
539539
Lastpinged string `json:"lastpinged"`
540-
Managementserverid string `json:"managementserverid"`
540+
Managementserverid ManagementServerId `json:"managementserverid"`
541541
Memoryallocated int64 `json:"memoryallocated"`
542542
Memoryallocatedbytes int64 `json:"memoryallocatedbytes"`
543543
Memoryallocatedpercentage string `json:"memoryallocatedpercentage"`
@@ -754,7 +754,7 @@ type CancelHostMaintenanceResponse struct {
754754
Jobstatus int `json:"jobstatus"`
755755
Lastannotated string `json:"lastannotated"`
756756
Lastpinged string `json:"lastpinged"`
757-
Managementserverid string `json:"managementserverid"`
757+
Managementserverid ManagementServerId `json:"managementserverid"`
758758
Memoryallocated int64 `json:"memoryallocated"`
759759
Memoryallocatedbytes int64 `json:"memoryallocatedbytes"`
760760
Memoryallocatedpercentage string `json:"memoryallocatedpercentage"`
@@ -1240,58 +1240,58 @@ func (s *HostService) FindHostsForMigration(p *FindHostsForMigrationParams) (*Fi
12401240
}
12411241

12421242
type FindHostsForMigrationResponse struct {
1243-
Averageload int64 `json:"averageload"`
1244-
Capabilities string `json:"capabilities"`
1245-
Clusterid string `json:"clusterid"`
1246-
Clustername string `json:"clustername"`
1247-
Clustertype string `json:"clustertype"`
1248-
Cpuallocated string `json:"cpuallocated"`
1249-
Cpuallocatedpercentage string `json:"cpuallocatedpercentage"`
1250-
Cpuallocatedvalue int64 `json:"cpuallocatedvalue"`
1251-
Cpuallocatedwithoverprovisioning string `json:"cpuallocatedwithoverprovisioning"`
1252-
Cpunumber int `json:"cpunumber"`
1253-
Cpuspeed int64 `json:"cpuspeed"`
1254-
Cpuused string `json:"cpuused"`
1255-
Cpuwithoverprovisioning string `json:"cpuwithoverprovisioning"`
1256-
Created string `json:"created"`
1257-
Disconnected string `json:"disconnected"`
1258-
Disksizeallocated int64 `json:"disksizeallocated"`
1259-
Disksizetotal int64 `json:"disksizetotal"`
1260-
Events string `json:"events"`
1261-
Hahost bool `json:"hahost"`
1262-
Hasenoughcapacity bool `json:"hasenoughcapacity"`
1263-
Hosttags string `json:"hosttags"`
1264-
Hypervisor string `json:"hypervisor"`
1265-
Hypervisorversion string `json:"hypervisorversion"`
1266-
Id string `json:"id"`
1267-
Ipaddress string `json:"ipaddress"`
1268-
Islocalstorageactive bool `json:"islocalstorageactive"`
1269-
JobID string `json:"jobid"`
1270-
Jobstatus int `json:"jobstatus"`
1271-
Lastpinged string `json:"lastpinged"`
1272-
Managementserverid string `json:"managementserverid"`
1273-
Memoryallocated string `json:"memoryallocated"`
1274-
Memoryallocatedbytes int64 `json:"memoryallocatedbytes"`
1275-
Memoryallocatedpercentage string `json:"memoryallocatedpercentage"`
1276-
Memorytotal int64 `json:"memorytotal"`
1277-
Memoryused int64 `json:"memoryused"`
1278-
Memorywithoverprovisioning string `json:"memorywithoverprovisioning"`
1279-
Name string `json:"name"`
1280-
Networkkbsread int64 `json:"networkkbsread"`
1281-
Networkkbswrite int64 `json:"networkkbswrite"`
1282-
Oscategoryid string `json:"oscategoryid"`
1283-
Oscategoryname string `json:"oscategoryname"`
1284-
Podid string `json:"podid"`
1285-
Podname string `json:"podname"`
1286-
Removed string `json:"removed"`
1287-
RequiresStorageMotion bool `json:"requiresStorageMotion"`
1288-
Resourcestate string `json:"resourcestate"`
1289-
State string `json:"state"`
1290-
Suitableformigration bool `json:"suitableformigration"`
1291-
Type string `json:"type"`
1292-
Version string `json:"version"`
1293-
Zoneid string `json:"zoneid"`
1294-
Zonename string `json:"zonename"`
1243+
Averageload int64 `json:"averageload"`
1244+
Capabilities string `json:"capabilities"`
1245+
Clusterid string `json:"clusterid"`
1246+
Clustername string `json:"clustername"`
1247+
Clustertype string `json:"clustertype"`
1248+
Cpuallocated string `json:"cpuallocated"`
1249+
Cpuallocatedpercentage string `json:"cpuallocatedpercentage"`
1250+
Cpuallocatedvalue int64 `json:"cpuallocatedvalue"`
1251+
Cpuallocatedwithoverprovisioning string `json:"cpuallocatedwithoverprovisioning"`
1252+
Cpunumber int `json:"cpunumber"`
1253+
Cpuspeed int64 `json:"cpuspeed"`
1254+
Cpuused string `json:"cpuused"`
1255+
Cpuwithoverprovisioning string `json:"cpuwithoverprovisioning"`
1256+
Created string `json:"created"`
1257+
Disconnected string `json:"disconnected"`
1258+
Disksizeallocated int64 `json:"disksizeallocated"`
1259+
Disksizetotal int64 `json:"disksizetotal"`
1260+
Events string `json:"events"`
1261+
Hahost bool `json:"hahost"`
1262+
Hasenoughcapacity bool `json:"hasenoughcapacity"`
1263+
Hosttags string `json:"hosttags"`
1264+
Hypervisor string `json:"hypervisor"`
1265+
Hypervisorversion string `json:"hypervisorversion"`
1266+
Id string `json:"id"`
1267+
Ipaddress string `json:"ipaddress"`
1268+
Islocalstorageactive bool `json:"islocalstorageactive"`
1269+
JobID string `json:"jobid"`
1270+
Jobstatus int `json:"jobstatus"`
1271+
Lastpinged string `json:"lastpinged"`
1272+
Managementserverid ManagementServerId `json:"managementserverid"`
1273+
Memoryallocated string `json:"memoryallocated"`
1274+
Memoryallocatedbytes int64 `json:"memoryallocatedbytes"`
1275+
Memoryallocatedpercentage string `json:"memoryallocatedpercentage"`
1276+
Memorytotal int64 `json:"memorytotal"`
1277+
Memoryused int64 `json:"memoryused"`
1278+
Memorywithoverprovisioning string `json:"memorywithoverprovisioning"`
1279+
Name string `json:"name"`
1280+
Networkkbsread int64 `json:"networkkbsread"`
1281+
Networkkbswrite int64 `json:"networkkbswrite"`
1282+
Oscategoryid string `json:"oscategoryid"`
1283+
Oscategoryname string `json:"oscategoryname"`
1284+
Podid string `json:"podid"`
1285+
Podname string `json:"podname"`
1286+
Removed string `json:"removed"`
1287+
RequiresStorageMotion bool `json:"requiresStorageMotion"`
1288+
Resourcestate string `json:"resourcestate"`
1289+
State string `json:"state"`
1290+
Suitableformigration bool `json:"suitableformigration"`
1291+
Type string `json:"type"`
1292+
Version string `json:"version"`
1293+
Zoneid string `json:"zoneid"`
1294+
Zonename string `json:"zonename"`
12951295
}
12961296

12971297
type ListDedicatedHostsParams struct {
@@ -1867,7 +1867,7 @@ type Host struct {
18671867
Jobstatus int `json:"jobstatus"`
18681868
Lastannotated string `json:"lastannotated"`
18691869
Lastpinged string `json:"lastpinged"`
1870-
Managementserverid string `json:"managementserverid"`
1870+
Managementserverid ManagementServerId `json:"managementserverid"`
18711871
Memoryallocated int64 `json:"memoryallocated"`
18721872
Memoryallocatedbytes int64 `json:"memoryallocatedbytes"`
18731873
Memoryallocatedpercentage string `json:"memoryallocatedpercentage"`
@@ -1915,6 +1915,18 @@ type HostHostha struct {
19151915
Hastate string `json:"hastate"`
19161916
}
19171917

1918+
type ManagementServerId string
1919+
1920+
func (id *ManagementServerId) UnmarshalJSON(b []byte) error {
1921+
unquoted, err := strconv.Unquote(string(b))
1922+
if err != nil {
1923+
*id = ManagementServerId(string(b))
1924+
return nil
1925+
}
1926+
*id = ManagementServerId(unquoted)
1927+
return nil
1928+
}
1929+
19181930
type ListHostsMetricsParams struct {
19191931
p map[string]interface{}
19201932
}
@@ -2257,7 +2269,7 @@ type HostsMetric struct {
22572269
Jobstatus int `json:"jobstatus"`
22582270
Lastannotated string `json:"lastannotated"`
22592271
Lastpinged string `json:"lastpinged"`
2260-
Managementserverid string `json:"managementserverid"`
2272+
Managementserverid ManagementServerId `json:"managementserverid"`
22612273
Memoryallocated int64 `json:"memoryallocated"`
22622274
Memoryallocatedbytes int64 `json:"memoryallocatedbytes"`
22632275
Memoryallocateddisablethreshold bool `json:"memoryallocateddisablethreshold"`
@@ -2412,7 +2424,7 @@ type PrepareHostForMaintenanceResponse struct {
24122424
Jobstatus int `json:"jobstatus"`
24132425
Lastannotated string `json:"lastannotated"`
24142426
Lastpinged string `json:"lastpinged"`
2415-
Managementserverid string `json:"managementserverid"`
2427+
Managementserverid ManagementServerId `json:"managementserverid"`
24162428
Memoryallocated int64 `json:"memoryallocated"`
24172429
Memoryallocatedbytes int64 `json:"memoryallocatedbytes"`
24182430
Memoryallocatedpercentage string `json:"memoryallocatedpercentage"`
@@ -2557,7 +2569,7 @@ type ReconnectHostResponse struct {
25572569
Jobstatus int `json:"jobstatus"`
25582570
Lastannotated string `json:"lastannotated"`
25592571
Lastpinged string `json:"lastpinged"`
2560-
Managementserverid string `json:"managementserverid"`
2572+
Managementserverid ManagementServerId `json:"managementserverid"`
25612573
Memoryallocated int64 `json:"memoryallocated"`
25622574
Memoryallocatedbytes int64 `json:"memoryallocatedbytes"`
25632575
Memoryallocatedpercentage string `json:"memoryallocatedpercentage"`
@@ -2879,7 +2891,7 @@ type UpdateHostResponse struct {
28792891
Jobstatus int `json:"jobstatus"`
28802892
Lastannotated string `json:"lastannotated"`
28812893
Lastpinged string `json:"lastpinged"`
2882-
Managementserverid string `json:"managementserverid"`
2894+
Managementserverid ManagementServerId `json:"managementserverid"`
28832895
Memoryallocated int64 `json:"memoryallocated"`
28842896
Memoryallocatedbytes int64 `json:"memoryallocatedbytes"`
28852897
Memoryallocatedpercentage string `json:"memoryallocatedpercentage"`

0 commit comments

Comments
 (0)