Skip to content

Commit 37d668c

Browse files
Fix listing virtual machines with vnfnics (#161)
* Fix listing virtual machines with vnfnics * Fix response key for ListVnfTemplates and ListVnfAppliances Both list structs took their json tag from the API name, so they looked for "vnftemplate" and "vnfappliance". Neither key exists in the server response: ListVnfTemplatesCmd is an empty subclass of ListTemplatesCmd and returns its items under "template", and ListVnfAppliancesCmd inherits execute() from ListVMsCmd and returns its items under "virtualmachine". Both calls therefore returned a correct Count with an always-empty slice, which also made GetVnfTemplateByName/ByID and GetVnfApplianceByName/ByID always report that the resource was not found. Adds both to the existing switch of APIs whose response key differs from the API name, alongside cases like listVirtualMachinesUsageHistory, and regenerates. Verified against a 4.22.1.0 server response that returns one VNF template: it decodes to one element instead of zero. ---------
1 parent 35cbeda commit 37d668c

9 files changed

Lines changed: 69 additions & 32 deletions

‎cloudstack/AffinityGroupService.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1233,7 +1233,7 @@ type UpdateVMAffinityGroupResponse struct {
12331233
Videoram int64 `json:"videoram"`
12341234
Vmtype string `json:"vmtype"`
12351235
Vnfdetails map[string]string `json:"vnfdetails"`
1236-
Vnfnics []string `json:"vnfnics"`
1236+
Vnfnics []*VnfNic `json:"vnfnics"`
12371237
Zoneid string `json:"zoneid"`
12381238
Zonename string `json:"zonename"`
12391239
}

‎cloudstack/BackupService.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2347,7 +2347,7 @@ type CreateVMFromBackupResponse struct {
23472347
Videoram int64 `json:"videoram"`
23482348
Vmtype string `json:"vmtype"`
23492349
Vnfdetails map[string]string `json:"vnfdetails"`
2350-
Vnfnics []string `json:"vnfnics"`
2350+
Vnfnics []*VnfNic `json:"vnfnics"`
23512351
Zoneid string `json:"zoneid"`
23522352
Zonename string `json:"zonename"`
23532353
}

‎cloudstack/ISOService.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ type AttachIsoResponse struct {
291291
Videoram int64 `json:"videoram"`
292292
Vmtype string `json:"vmtype"`
293293
Vnfdetails map[string]string `json:"vnfdetails"`
294-
Vnfnics []string `json:"vnfnics"`
294+
Vnfnics []*VnfNic `json:"vnfnics"`
295295
Zoneid string `json:"zoneid"`
296296
Zonename string `json:"zonename"`
297297
}
@@ -926,7 +926,7 @@ type DetachIsoResponse struct {
926926
Videoram int64 `json:"videoram"`
927927
Vmtype string `json:"vmtype"`
928928
Vnfdetails map[string]string `json:"vnfdetails"`
929-
Vnfnics []string `json:"vnfnics"`
929+
Vnfnics []*VnfNic `json:"vnfnics"`
930930
Zoneid string `json:"zoneid"`
931931
Zonename string `json:"zonename"`
932932
}

‎cloudstack/NicService.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ type UpdateVmNicIpResponse struct {
696696
Videoram int64 `json:"videoram"`
697697
Vmtype string `json:"vmtype"`
698698
Vnfdetails map[string]string `json:"vnfdetails"`
699-
Vnfnics []string `json:"vnfnics"`
699+
Vnfnics []*VnfNic `json:"vnfnics"`
700700
Zoneid string `json:"zoneid"`
701701
Zonename string `json:"zonename"`
702702
}

‎cloudstack/SSHService.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ type ResetSSHKeyForVirtualMachineResponse struct {
12461246
Videoram int64 `json:"videoram"`
12471247
Vmtype string `json:"vmtype"`
12481248
Vnfdetails map[string]string `json:"vnfdetails"`
1249-
Vnfnics []string `json:"vnfnics"`
1249+
Vnfnics []*VnfNic `json:"vnfnics"`
12501250
Zoneid string `json:"zoneid"`
12511251
Zonename string `json:"zonename"`
12521252
}

‎cloudstack/SnapshotService.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3862,7 +3862,7 @@ type RevertToVMSnapshotResponse struct {
38623862
Videoram int64 `json:"videoram"`
38633863
Vmtype string `json:"vmtype"`
38643864
Vnfdetails map[string]string `json:"vnfdetails"`
3865-
Vnfnics []string `json:"vnfnics"`
3865+
Vnfnics []*VnfNic `json:"vnfnics"`
38663866
Zoneid string `json:"zoneid"`
38673867
Zonename string `json:"zonename"`
38683868
}

‎cloudstack/VirtualMachineService.go‎

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ type AddNicToVirtualMachineResponse struct {
398398
Videoram int64 `json:"videoram"`
399399
Vmtype string `json:"vmtype"`
400400
Vnfdetails map[string]string `json:"vnfdetails"`
401-
Vnfnics []string `json:"vnfnics"`
401+
Vnfnics []*VnfNic `json:"vnfnics"`
402402
Zoneid string `json:"zoneid"`
403403
Zonename string `json:"zonename"`
404404
}
@@ -762,7 +762,7 @@ type AssignVirtualMachineResponse struct {
762762
Videoram int64 `json:"videoram"`
763763
Vmtype string `json:"vmtype"`
764764
Vnfdetails map[string]string `json:"vnfdetails"`
765-
Vnfnics []string `json:"vnfnics"`
765+
Vnfnics []*VnfNic `json:"vnfnics"`
766766
Zoneid string `json:"zoneid"`
767767
Zonename string `json:"zonename"`
768768
}
@@ -1156,7 +1156,7 @@ type ChangeServiceForVirtualMachineResponse struct {
11561156
Videoram int64 `json:"videoram"`
11571157
Vmtype string `json:"vmtype"`
11581158
Vnfdetails map[string]string `json:"vnfdetails"`
1159-
Vnfnics []string `json:"vnfnics"`
1159+
Vnfnics []*VnfNic `json:"vnfnics"`
11601160
Zoneid string `json:"zoneid"`
11611161
Zonename string `json:"zonename"`
11621162
}
@@ -2956,7 +2956,7 @@ type DeployVirtualMachineResponse struct {
29562956
Videoram int64 `json:"videoram"`
29572957
Vmtype string `json:"vmtype"`
29582958
Vnfdetails map[string]string `json:"vnfdetails"`
2959-
Vnfnics []string `json:"vnfnics"`
2959+
Vnfnics []*VnfNic `json:"vnfnics"`
29602960
Zoneid string `json:"zoneid"`
29612961
Zonename string `json:"zonename"`
29622962
}
@@ -3268,7 +3268,7 @@ type DestroyVirtualMachineResponse struct {
32683268
Videoram int64 `json:"videoram"`
32693269
Vmtype string `json:"vmtype"`
32703270
Vnfdetails map[string]string `json:"vnfdetails"`
3271-
Vnfnics []string `json:"vnfnics"`
3271+
Vnfnics []*VnfNic `json:"vnfnics"`
32723272
Zoneid string `json:"zoneid"`
32733273
Zonename string `json:"zonename"`
32743274
}
@@ -4821,7 +4821,7 @@ type VirtualMachine struct {
48214821
Videoram int64 `json:"videoram"`
48224822
Vmtype string `json:"vmtype"`
48234823
Vnfdetails map[string]string `json:"vnfdetails"`
4824-
Vnfnics []string `json:"vnfnics"`
4824+
Vnfnics []*VnfNic `json:"vnfnics"`
48254825
Zoneid string `json:"zoneid"`
48264826
Zonename string `json:"zonename"`
48274827
}
@@ -6233,7 +6233,7 @@ type VirtualMachinesMetric struct {
62336233
Videoram int64 `json:"videoram"`
62346234
Vmtype string `json:"vmtype"`
62356235
Vnfdetails map[string]string `json:"vnfdetails"`
6236-
Vnfnics []string `json:"vnfnics"`
6236+
Vnfnics []*VnfNic `json:"vnfnics"`
62376237
Zoneid string `json:"zoneid"`
62386238
Zonename string `json:"zonename"`
62396239
}
@@ -6842,7 +6842,7 @@ type MigrateVirtualMachineResponse struct {
68426842
Videoram int64 `json:"videoram"`
68436843
Vmtype string `json:"vmtype"`
68446844
Vnfdetails map[string]string `json:"vnfdetails"`
6845-
Vnfnics []string `json:"vnfnics"`
6845+
Vnfnics []*VnfNic `json:"vnfnics"`
68466846
Zoneid string `json:"zoneid"`
68476847
Zonename string `json:"zonename"`
68486848
}
@@ -7196,7 +7196,7 @@ type MigrateVirtualMachineWithVolumeResponse struct {
71967196
Videoram int64 `json:"videoram"`
71977197
Vmtype string `json:"vmtype"`
71987198
Vnfdetails map[string]string `json:"vnfdetails"`
7199-
Vnfnics []string `json:"vnfnics"`
7199+
Vnfnics []*VnfNic `json:"vnfnics"`
72007200
Zoneid string `json:"zoneid"`
72017201
Zonename string `json:"zonename"`
72027202
}
@@ -7508,7 +7508,7 @@ type RebootVirtualMachineResponse struct {
75087508
Videoram int64 `json:"videoram"`
75097509
Vmtype string `json:"vmtype"`
75107510
Vnfdetails map[string]string `json:"vnfdetails"`
7511-
Vnfnics []string `json:"vnfnics"`
7511+
Vnfnics []*VnfNic `json:"vnfnics"`
75127512
Zoneid string `json:"zoneid"`
75137513
Zonename string `json:"zonename"`
75147514
}
@@ -7750,7 +7750,7 @@ type RecoverVirtualMachineResponse struct {
77507750
Videoram int64 `json:"videoram"`
77517751
Vmtype string `json:"vmtype"`
77527752
Vnfdetails map[string]string `json:"vnfdetails"`
7753-
Vnfnics []string `json:"vnfnics"`
7753+
Vnfnics []*VnfNic `json:"vnfnics"`
77547754
Zoneid string `json:"zoneid"`
77557755
Zonename string `json:"zonename"`
77567756
}
@@ -8037,7 +8037,7 @@ type RemoveNicFromVirtualMachineResponse struct {
80378037
Videoram int64 `json:"videoram"`
80388038
Vmtype string `json:"vmtype"`
80398039
Vnfdetails map[string]string `json:"vnfdetails"`
8040-
Vnfnics []string `json:"vnfnics"`
8040+
Vnfnics []*VnfNic `json:"vnfnics"`
80418041
Zoneid string `json:"zoneid"`
80428042
Zonename string `json:"zonename"`
80438043
}
@@ -8323,7 +8323,7 @@ type ResetPasswordForVirtualMachineResponse struct {
83238323
Videoram int64 `json:"videoram"`
83248324
Vmtype string `json:"vmtype"`
83258325
Vnfdetails map[string]string `json:"vnfdetails"`
8326-
Vnfnics []string `json:"vnfnics"`
8326+
Vnfnics []*VnfNic `json:"vnfnics"`
83278327
Zoneid string `json:"zoneid"`
83288328
Zonename string `json:"zonename"`
83298329
}
@@ -8712,7 +8712,7 @@ type ResetUserDataForVirtualMachineResponse struct {
87128712
Videoram int64 `json:"videoram"`
87138713
Vmtype string `json:"vmtype"`
87148714
Vnfdetails map[string]string `json:"vnfdetails"`
8715-
Vnfnics []string `json:"vnfnics"`
8715+
Vnfnics []*VnfNic `json:"vnfnics"`
87168716
Zoneid string `json:"zoneid"`
87178717
Zonename string `json:"zonename"`
87188718
}
@@ -9099,7 +9099,7 @@ type RestoreVirtualMachineResponse struct {
90999099
Videoram int64 `json:"videoram"`
91009100
Vmtype string `json:"vmtype"`
91019101
Vnfdetails map[string]string `json:"vnfdetails"`
9102-
Vnfnics []string `json:"vnfnics"`
9102+
Vnfnics []*VnfNic `json:"vnfnics"`
91039103
Zoneid string `json:"zoneid"`
91049104
Zonename string `json:"zonename"`
91059105
}
@@ -9741,7 +9741,7 @@ type StartVirtualMachineResponse struct {
97419741
Videoram int64 `json:"videoram"`
97429742
Vmtype string `json:"vmtype"`
97439743
Vnfdetails map[string]string `json:"vnfdetails"`
9744-
Vnfnics []string `json:"vnfnics"`
9744+
Vnfnics []*VnfNic `json:"vnfnics"`
97459745
Zoneid string `json:"zoneid"`
97469746
Zonename string `json:"zonename"`
97479747
}
@@ -10028,7 +10028,7 @@ type StopVirtualMachineResponse struct {
1002810028
Videoram int64 `json:"videoram"`
1002910029
Vmtype string `json:"vmtype"`
1003010030
Vnfdetails map[string]string `json:"vnfdetails"`
10031-
Vnfnics []string `json:"vnfnics"`
10031+
Vnfnics []*VnfNic `json:"vnfnics"`
1003210032
Zoneid string `json:"zoneid"`
1003310033
Zonename string `json:"zonename"`
1003410034
}
@@ -10315,7 +10315,7 @@ type UpdateDefaultNicForVirtualMachineResponse struct {
1031510315
Videoram int64 `json:"videoram"`
1031610316
Vmtype string `json:"vmtype"`
1031710317
Vnfdetails map[string]string `json:"vnfdetails"`
10318-
Vnfnics []string `json:"vnfnics"`
10318+
Vnfnics []*VnfNic `json:"vnfnics"`
1031910319
Zoneid string `json:"zoneid"`
1032010320
Zonename string `json:"zonename"`
1032110321
}
@@ -11094,7 +11094,7 @@ type UpdateVirtualMachineResponse struct {
1109411094
Videoram int64 `json:"videoram"`
1109511095
Vmtype string `json:"vmtype"`
1109611096
Vnfdetails map[string]string `json:"vnfdetails"`
11097-
Vnfnics []string `json:"vnfnics"`
11097+
Vnfnics []*VnfNic `json:"vnfnics"`
1109811098
Zoneid string `json:"zoneid"`
1109911099
Zonename string `json:"zonename"`
1110011100
}
@@ -12667,7 +12667,7 @@ type ImportVmResponse struct {
1266712667
Videoram int64 `json:"videoram"`
1266812668
Vmtype string `json:"vmtype"`
1266912669
Vnfdetails map[string]string `json:"vnfdetails"`
12670-
Vnfnics []string `json:"vnfnics"`
12670+
Vnfnics []*VnfNic `json:"vnfnics"`
1267112671
Zoneid string `json:"zoneid"`
1267212672
Zonename string `json:"zonename"`
1267312673
}
@@ -13621,7 +13621,7 @@ type ImportUnmanagedInstanceResponse struct {
1362113621
Videoram int64 `json:"videoram"`
1362213622
Vmtype string `json:"vmtype"`
1362313623
Vnfdetails map[string]string `json:"vnfdetails"`
13624-
Vnfnics []string `json:"vnfnics"`
13624+
Vnfnics []*VnfNic `json:"vnfnics"`
1362513625
Zoneid string `json:"zoneid"`
1362613626
Zonename string `json:"zonename"`
1362713627
}

0 commit comments

Comments
 (0)