-
Notifications
You must be signed in to change notification settings - Fork 0
/
VM.gen.go
3190 lines (2787 loc) · 98.2 KB
/
VM.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// This is a generated file. DO NOT EDIT manually.
//go:generate goimports -w VM.gen.go
package go_xen_client
import (
"log"
"reflect"
"strconv"
"time"
"github.com/nilshell/xmlrpc"
)
//VM: A virtual machine (or 'guest').
type VM struct {
Uuid string // Unique identifier/object reference
AllowedOperations []VmOperations // list of the operations allowed in this state. This list is advisory only and the server state may have changed by the time this field is read by a client.
CurrentOperations map[string]VmOperations // links each of the running tasks using this object (by reference) to a current_operation enum which describes the nature of the task.
PowerState VmPowerState // Current power state of the machine
NameLabel string // a human-readable name
NameDescription string // a notes field containing human-readable description
UserVersion int // Creators of VMs and templates may store version information here.
IsATemplate bool // true if this is a template. Template VMs can never be started, they are used only for cloning other VMs
IsDefaultTemplate bool // true if this is a default template. Default template VMs can never be started or migrated, they are used only for cloning other VMs
SuspendVDI string // The VDI that a suspend image is stored on. (Only has meaning if VM is currently suspended)
ResidentOn string // the host the VM is currently resident on
Affinity string // A host which the VM has some affinity for (or NULL). This is used as a hint to the start call when it decides where to run the VM. Resource constraints may cause the VM to be started elsewhere.
MemoryOverhead int // Virtualization memory overhead (bytes).
MemoryTarget int // Dynamically-set memory target (bytes). The value of this field indicates the current target for memory available to this VM.
MemoryStaticMax int // Statically-set (i.e. absolute) maximum (bytes). The value of this field at VM start time acts as a hard limit of the amount of memory a guest can use. New values only take effect on reboot.
MemoryDynamicMax int // Dynamic maximum (bytes)
MemoryDynamicMin int // Dynamic minimum (bytes)
MemoryStaticMin int // Statically-set (i.e. absolute) mininum (bytes). The value of this field indicates the least amount of memory this VM can boot with without crashing.
VCPUsParams map[string]string // configuration parameters for the selected VCPU policy
VCPUsMax int // Max number of VCPUs
VCPUsAtStartup int // Boot number of VCPUs
ActionsAfterShutdown OnNormalExit // action to take after the guest has shutdown itself
ActionsAfterReboot OnNormalExit // action to take after the guest has rebooted itself
ActionsAfterCrash OnCrashBehaviour // action to take if the guest crashes
Consoles []string // virtual console devices
VIFs []string // virtual network interfaces
VBDs []string // virtual block devices
VUSBs []string // vitual usb devices
CrashDumps []string // crash dumps associated with this VM
VTPMs []string // virtual TPMs
PVBootloader string // name of or path to bootloader
PVKernel string // path to the kernel
PVRamdisk string // path to the initrd
PVArgs string // kernel command-line arguments
PVBootloaderArgs string // miscellaneous arguments for the bootloader
PVLegacyArgs string // to make Zurich guests boot
HVMBootPolicy string // HVM boot policy
HVMBootParams map[string]string // HVM boot params
HVMShadowMultiplier float32 // multiplier applied to the amount of shadow that will be made available to the guest
Platform map[string]string // platform-specific configuration
PCIBus string // PCI bus path for pass-through devices
OtherConfig map[string]string // additional configuration
Domid int // domain ID (if available, -1 otherwise)
Domarch string // Domain architecture (if available, null string otherwise)
LastBootCPUFlags map[string]string // describes the CPU flags on which the VM was last booted
IsControlDomain bool // true if this is a control domain (domain 0 or a driver domain)
Metrics string // metrics associated with this VM
GuestMetrics string // metrics associated with the running guest
LastBootedRecord string // marshalled value containing VM record at time of last boot, updated dynamically to reflect the runtime state of the domain
Recommendations string // An XML specification of recommended values and ranges for properties of this VM
XenstoreData map[string]string // data to be inserted into the xenstore tree (/local/domain/<domid>/vm-data) after the VM is created.
HaAlwaysRun bool // if true then the system will attempt to keep the VM running as much as possible.
HaRestartPriority string // has possible values: "best-effort" meaning "try to restart this VM if possible but don't consider the Pool to be overcommitted if this is not possible"; "restart" meaning "this VM should be restarted"; "" meaning "do not try to restart this VM"
IsASnapshot bool // true if this is a snapshot. Snapshotted VMs can never be started, they are used only for cloning other VMs
SnapshotOf string // Ref pointing to the VM this snapshot is of.
Snapshots []string // List pointing to all the VM snapshots.
SnapshotTime time.Time // Date/time when this snapshot was created.
TransportableSnapshotId string // Transportable ID of the snapshot VM
Blobs map[string]string // Binary blobs associated with this VM
Tags []string // user-specified tags for categorization purposes
BlockedOperations map[VmOperations]string // List of operations which have been explicitly blocked and an error code
SnapshotInfo map[string]string // Human-readable information concerning this snapshot
SnapshotMetadata string // Encoded information about the VM's metadata this is a snapshot of
Parent string // Ref pointing to the parent of this VM
Children []string // List pointing to all the children of this VM
BiosStrings map[string]string // BIOS strings
ProtectionPolicy string // Ref pointing to a protection policy for this VM
IsSnapshotFromVmpp bool // true if this snapshot was created by the protection policy
SnapshotSchedule string // Ref pointing to a snapshot schedule for this VM
IsVmssSnapshot bool // true if this snapshot was created by the snapshot schedule
Appliance string // the appliance to which this VM belongs
StartDelay int // The delay to wait before proceeding to the next order in the startup sequence (seconds)
ShutdownDelay int // The delay to wait before proceeding to the next order in the shutdown sequence (seconds)
Order int // The point in the startup or shutdown sequence at which this VM will be started
VGPUs []string // Virtual GPUs
AttachedPCIs []string // Currently passed-through PCI devices
SuspendSR string // The SR on which a suspend image is stored
Version int // The number of times this VM has been recovered
GenerationId string // Generation ID of the VM
HardwarePlatformVersion int // The host virtual hardware platform version the VM can run on
HasVendorDevice bool // When an HVM guest starts, this controls the presence of the emulated C000 PCI device which triggers Windows Update to fetch or update PV drivers.
RequiresReboot bool // Indicates whether a VM requires a reboot in order to update its configuration, e.g. its memory allocation.
ReferenceLabel string // Textual reference to the template used to create a VM. This can be used by clients in need of an immutable reference to the template since the latter's uuid and name_label may change, for example, after a package installation or upgrade.
DomainType DomainType // The type of domain that will be created when the VM is started
NVRAM map[string]string // initial value for guest NVRAM (containing UEFI variables, etc). Cannot be changed while the VM is running
}
func FromVMToXml(VM *VM) (result xmlrpc.Struct) {
result = make(xmlrpc.Struct)
result["uuid"] = VM.Uuid
result["allowed_operations"] = VM.AllowedOperations
current_operations := make(xmlrpc.Struct)
for key, value := range VM.CurrentOperations {
current_operations[key] = value
}
result["current_operations"] = current_operations
result["power_state"] = VM.PowerState.String()
result["name_label"] = VM.NameLabel
result["name_description"] = VM.NameDescription
result["user_version"] = strconv.Itoa(VM.UserVersion)
result["is_a_template"] = VM.IsATemplate
result["is_default_template"] = VM.IsDefaultTemplate
result["suspend_VDI"] = VM.SuspendVDI
result["resident_on"] = VM.ResidentOn
result["affinity"] = VM.Affinity
result["memory_overhead"] = strconv.Itoa(VM.MemoryOverhead)
result["memory_target"] = strconv.Itoa(VM.MemoryTarget)
result["memory_static_max"] = strconv.Itoa(VM.MemoryStaticMax)
result["memory_dynamic_max"] = strconv.Itoa(VM.MemoryDynamicMax)
result["memory_dynamic_min"] = strconv.Itoa(VM.MemoryDynamicMin)
result["memory_static_min"] = strconv.Itoa(VM.MemoryStaticMin)
VCPUs_params := make(xmlrpc.Struct)
for key, value := range VM.VCPUsParams {
VCPUs_params[key] = value
}
result["VCPUs_params"] = VCPUs_params
result["VCPUs_max"] = strconv.Itoa(VM.VCPUsMax)
result["VCPUs_at_startup"] = strconv.Itoa(VM.VCPUsAtStartup)
result["actions_after_shutdown"] = VM.ActionsAfterShutdown.String()
result["actions_after_reboot"] = VM.ActionsAfterReboot.String()
result["actions_after_crash"] = VM.ActionsAfterCrash.String()
result["consoles"] = VM.Consoles
result["VIFs"] = VM.VIFs
result["VBDs"] = VM.VBDs
result["VUSBs"] = VM.VUSBs
result["crash_dumps"] = VM.CrashDumps
result["VTPMs"] = VM.VTPMs
result["PV_bootloader"] = VM.PVBootloader
result["PV_kernel"] = VM.PVKernel
result["PV_ramdisk"] = VM.PVRamdisk
result["PV_args"] = VM.PVArgs
result["PV_bootloader_args"] = VM.PVBootloaderArgs
result["PV_legacy_args"] = VM.PVLegacyArgs
result["HVM_boot_policy"] = VM.HVMBootPolicy
HVM_boot_params := make(xmlrpc.Struct)
for key, value := range VM.HVMBootParams {
HVM_boot_params[key] = value
}
result["HVM_boot_params"] = HVM_boot_params
result["HVM_shadow_multiplier"] = VM.HVMShadowMultiplier
platform := make(xmlrpc.Struct)
for key, value := range VM.Platform {
platform[key] = value
}
result["platform"] = platform
result["PCI_bus"] = VM.PCIBus
other_config := make(xmlrpc.Struct)
for key, value := range VM.OtherConfig {
other_config[key] = value
}
result["other_config"] = other_config
result["domid"] = strconv.Itoa(VM.Domid)
result["domarch"] = VM.Domarch
last_boot_CPU_flags := make(xmlrpc.Struct)
for key, value := range VM.LastBootCPUFlags {
last_boot_CPU_flags[key] = value
}
result["last_boot_CPU_flags"] = last_boot_CPU_flags
result["is_control_domain"] = VM.IsControlDomain
result["metrics"] = VM.Metrics
result["guest_metrics"] = VM.GuestMetrics
result["last_booted_record"] = VM.LastBootedRecord
result["recommendations"] = VM.Recommendations
xenstore_data := make(xmlrpc.Struct)
for key, value := range VM.XenstoreData {
xenstore_data[key] = value
}
result["xenstore_data"] = xenstore_data
result["ha_always_run"] = VM.HaAlwaysRun
result["ha_restart_priority"] = VM.HaRestartPriority
result["is_a_snapshot"] = VM.IsASnapshot
result["snapshot_of"] = VM.SnapshotOf
result["snapshots"] = VM.Snapshots
result["snapshot_time"] = VM.SnapshotTime
result["transportable_snapshot_id"] = VM.TransportableSnapshotId
blobs := make(xmlrpc.Struct)
for key, value := range VM.Blobs {
blobs[key] = value
}
result["blobs"] = blobs
result["tags"] = VM.Tags
blocked_operations := make(xmlrpc.Struct)
for key, value := range VM.BlockedOperations {
blocked_operations[key.String()] = value
}
result["blocked_operations"] = blocked_operations
snapshot_info := make(xmlrpc.Struct)
for key, value := range VM.SnapshotInfo {
snapshot_info[key] = value
}
result["snapshot_info"] = snapshot_info
result["snapshot_metadata"] = VM.SnapshotMetadata
result["parent"] = VM.Parent
result["children"] = VM.Children
bios_strings := make(xmlrpc.Struct)
for key, value := range VM.BiosStrings {
bios_strings[key] = value
}
result["bios_strings"] = bios_strings
result["protection_policy"] = VM.ProtectionPolicy
result["is_snapshot_from_vmpp"] = VM.IsSnapshotFromVmpp
result["snapshot_schedule"] = VM.SnapshotSchedule
result["is_vmss_snapshot"] = VM.IsVmssSnapshot
result["appliance"] = VM.Appliance
result["start_delay"] = strconv.Itoa(VM.StartDelay)
result["shutdown_delay"] = strconv.Itoa(VM.ShutdownDelay)
result["order"] = strconv.Itoa(VM.Order)
result["VGPUs"] = VM.VGPUs
result["attached_PCIs"] = VM.AttachedPCIs
result["suspend_SR"] = VM.SuspendSR
result["version"] = strconv.Itoa(VM.Version)
result["generation_id"] = VM.GenerationId
result["hardware_platform_version"] = strconv.Itoa(VM.HardwarePlatformVersion)
result["has_vendor_device"] = VM.HasVendorDevice
result["requires_reboot"] = VM.RequiresReboot
result["reference_label"] = VM.ReferenceLabel
result["domain_type"] = VM.DomainType.String()
NVRAM := make(xmlrpc.Struct)
for key, value := range VM.NVRAM {
NVRAM[key] = value
}
result["NVRAM"] = NVRAM
return result
}
func ToVM(obj interface{}) (resultObj *VM) {
objValue := reflect.ValueOf(obj)
resultObj = &VM{}
for _, oKey := range objValue.MapKeys() {
keyName := oKey.String()
keyValue := objValue.MapIndex(oKey).Interface()
switch keyName {
case "uuid":
if v, ok := keyValue.(string); ok {
resultObj.Uuid = v
}
case "allowed_operations":
if interim, ok := keyValue.([]interface{}); ok {
resultObj.AllowedOperations = make([]VmOperations, len(interim))
for i, interimValue := range interim {
if v, ok := interimValue.(VmOperations); ok {
resultObj.AllowedOperations[i] = v
}
}
}
case "current_operations":
resultObj.CurrentOperations = map[string]VmOperations{}
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.CurrentOperations[mapKeyName] = ToVmOperations(v)
} else {
resultObj.CurrentOperations[mapKeyName] = 0
}
}
case "power_state":
if v, ok := keyValue.(VmPowerState); ok {
resultObj.PowerState = v
}
case "name_label":
if v, ok := keyValue.(string); ok {
resultObj.NameLabel = v
}
case "name_description":
if v, ok := keyValue.(string); ok {
resultObj.NameDescription = v
}
case "user_version":
if v, ok := keyValue.(int); ok {
resultObj.UserVersion = v
}
case "is_a_template":
if v, ok := keyValue.(bool); ok {
resultObj.IsATemplate = v
}
case "is_default_template":
if v, ok := keyValue.(bool); ok {
resultObj.IsDefaultTemplate = v
}
case "suspend_VDI":
if v, ok := keyValue.(string); ok {
resultObj.SuspendVDI = v
}
case "resident_on":
if v, ok := keyValue.(string); ok {
resultObj.ResidentOn = v
}
case "affinity":
if v, ok := keyValue.(string); ok {
resultObj.Affinity = v
}
case "memory_overhead":
if v, ok := keyValue.(int); ok {
resultObj.MemoryOverhead = v
}
case "memory_target":
if v, ok := keyValue.(int); ok {
resultObj.MemoryTarget = v
}
case "memory_static_max":
if v, ok := keyValue.(int); ok {
resultObj.MemoryStaticMax = v
}
case "memory_dynamic_max":
if v, ok := keyValue.(int); ok {
resultObj.MemoryDynamicMax = v
}
case "memory_dynamic_min":
if v, ok := keyValue.(int); ok {
resultObj.MemoryDynamicMin = v
}
case "memory_static_min":
if v, ok := keyValue.(int); ok {
resultObj.MemoryStaticMin = v
}
case "VCPUs_params":
resultObj.VCPUsParams = 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.VCPUsParams[mapKeyName] = v
} else {
resultObj.VCPUsParams[mapKeyName] = ""
}
}
case "VCPUs_max":
if v, ok := keyValue.(int); ok {
resultObj.VCPUsMax = v
}
case "VCPUs_at_startup":
if v, ok := keyValue.(int); ok {
resultObj.VCPUsAtStartup = v
}
case "actions_after_shutdown":
if v, ok := keyValue.(OnNormalExit); ok {
resultObj.ActionsAfterShutdown = v
}
case "actions_after_reboot":
if v, ok := keyValue.(OnNormalExit); ok {
resultObj.ActionsAfterReboot = v
}
case "actions_after_crash":
if v, ok := keyValue.(OnCrashBehaviour); ok {
resultObj.ActionsAfterCrash = v
}
case "consoles":
if interim, ok := keyValue.([]interface{}); ok {
resultObj.Consoles = make([]string, len(interim))
for i, interimValue := range interim {
if v, ok := interimValue.(string); ok {
resultObj.Consoles[i] = v
}
}
}
case "VIFs":
if interim, ok := keyValue.([]interface{}); ok {
resultObj.VIFs = make([]string, len(interim))
for i, interimValue := range interim {
if v, ok := interimValue.(string); ok {
resultObj.VIFs[i] = v
}
}
}
case "VBDs":
if interim, ok := keyValue.([]interface{}); ok {
resultObj.VBDs = make([]string, len(interim))
for i, interimValue := range interim {
if v, ok := interimValue.(string); ok {
resultObj.VBDs[i] = v
}
}
}
case "VUSBs":
if interim, ok := keyValue.([]interface{}); ok {
resultObj.VUSBs = make([]string, len(interim))
for i, interimValue := range interim {
if v, ok := interimValue.(string); ok {
resultObj.VUSBs[i] = v
}
}
}
case "crash_dumps":
if interim, ok := keyValue.([]interface{}); ok {
resultObj.CrashDumps = make([]string, len(interim))
for i, interimValue := range interim {
if v, ok := interimValue.(string); ok {
resultObj.CrashDumps[i] = v
}
}
}
case "VTPMs":
if interim, ok := keyValue.([]interface{}); ok {
resultObj.VTPMs = make([]string, len(interim))
for i, interimValue := range interim {
if v, ok := interimValue.(string); ok {
resultObj.VTPMs[i] = v
}
}
}
case "PV_bootloader":
if v, ok := keyValue.(string); ok {
resultObj.PVBootloader = v
}
case "PV_kernel":
if v, ok := keyValue.(string); ok {
resultObj.PVKernel = v
}
case "PV_ramdisk":
if v, ok := keyValue.(string); ok {
resultObj.PVRamdisk = v
}
case "PV_args":
if v, ok := keyValue.(string); ok {
resultObj.PVArgs = v
}
case "PV_bootloader_args":
if v, ok := keyValue.(string); ok {
resultObj.PVBootloaderArgs = v
}
case "PV_legacy_args":
if v, ok := keyValue.(string); ok {
resultObj.PVLegacyArgs = v
}
case "HVM_boot_policy":
if v, ok := keyValue.(string); ok {
resultObj.HVMBootPolicy = v
}
case "HVM_boot_params":
resultObj.HVMBootParams = 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.HVMBootParams[mapKeyName] = v
} else {
resultObj.HVMBootParams[mapKeyName] = ""
}
}
case "HVM_shadow_multiplier":
if v, ok := keyValue.(float32); ok {
resultObj.HVMShadowMultiplier = v
}
case "platform":
resultObj.Platform = 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.Platform[mapKeyName] = v
} else {
resultObj.Platform[mapKeyName] = ""
}
}
case "PCI_bus":
if v, ok := keyValue.(string); ok {
resultObj.PCIBus = v
}
case "other_config":
resultObj.OtherConfig = 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.OtherConfig[mapKeyName] = v
} else {
resultObj.OtherConfig[mapKeyName] = ""
}
}
case "domid":
if v, ok := keyValue.(int); ok {
resultObj.Domid = v
}
case "domarch":
if v, ok := keyValue.(string); ok {
resultObj.Domarch = v
}
case "last_boot_CPU_flags":
resultObj.LastBootCPUFlags = 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.LastBootCPUFlags[mapKeyName] = v
} else {
resultObj.LastBootCPUFlags[mapKeyName] = ""
}
}
case "is_control_domain":
if v, ok := keyValue.(bool); ok {
resultObj.IsControlDomain = v
}
case "metrics":
if v, ok := keyValue.(string); ok {
resultObj.Metrics = v
}
case "guest_metrics":
if v, ok := keyValue.(string); ok {
resultObj.GuestMetrics = v
}
case "last_booted_record":
if v, ok := keyValue.(string); ok {
resultObj.LastBootedRecord = v
}
case "recommendations":
if v, ok := keyValue.(string); ok {
resultObj.Recommendations = v
}
case "xenstore_data":
resultObj.XenstoreData = 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.XenstoreData[mapKeyName] = v
} else {
resultObj.XenstoreData[mapKeyName] = ""
}
}
case "ha_always_run":
if v, ok := keyValue.(bool); ok {
resultObj.HaAlwaysRun = v
}
case "ha_restart_priority":
if v, ok := keyValue.(string); ok {
resultObj.HaRestartPriority = v
}
case "is_a_snapshot":
if v, ok := keyValue.(bool); ok {
resultObj.IsASnapshot = v
}
case "snapshot_of":
if v, ok := keyValue.(string); ok {
resultObj.SnapshotOf = v
}
case "snapshots":
if interim, ok := keyValue.([]interface{}); ok {
resultObj.Snapshots = make([]string, len(interim))
for i, interimValue := range interim {
if v, ok := interimValue.(string); ok {
resultObj.Snapshots[i] = v
}
}
}
case "snapshot_time":
if v, ok := keyValue.(time.Time); ok {
resultObj.SnapshotTime = v
}
case "transportable_snapshot_id":
if v, ok := keyValue.(string); ok {
resultObj.TransportableSnapshotId = v
}
case "blobs":
resultObj.Blobs = 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.Blobs[mapKeyName] = v
} else {
resultObj.Blobs[mapKeyName] = ""
}
}
case "tags":
if interim, ok := keyValue.([]interface{}); ok {
resultObj.Tags = make([]string, len(interim))
for i, interimValue := range interim {
if v, ok := interimValue.(string); ok {
resultObj.Tags[i] = v
}
}
}
case "blocked_operations":
case "snapshot_info":
resultObj.SnapshotInfo = 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.SnapshotInfo[mapKeyName] = v
} else {
resultObj.SnapshotInfo[mapKeyName] = ""
}
}
case "snapshot_metadata":
if v, ok := keyValue.(string); ok {
resultObj.SnapshotMetadata = v
}
case "parent":
if v, ok := keyValue.(string); ok {
resultObj.Parent = v
}
case "children":
if interim, ok := keyValue.([]interface{}); ok {
resultObj.Children = make([]string, len(interim))
for i, interimValue := range interim {
if v, ok := interimValue.(string); ok {
resultObj.Children[i] = v
}
}
}
case "bios_strings":
resultObj.BiosStrings = 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.BiosStrings[mapKeyName] = v
} else {
resultObj.BiosStrings[mapKeyName] = ""
}
}
case "protection_policy":
if v, ok := keyValue.(string); ok {
resultObj.ProtectionPolicy = v
}
case "is_snapshot_from_vmpp":
if v, ok := keyValue.(bool); ok {
resultObj.IsSnapshotFromVmpp = v
}
case "snapshot_schedule":
if v, ok := keyValue.(string); ok {
resultObj.SnapshotSchedule = v
}
case "is_vmss_snapshot":
if v, ok := keyValue.(bool); ok {
resultObj.IsVmssSnapshot = v
}
case "appliance":
if v, ok := keyValue.(string); ok {
resultObj.Appliance = v
}
case "start_delay":
if v, ok := keyValue.(int); ok {
resultObj.StartDelay = v
}
case "shutdown_delay":
if v, ok := keyValue.(int); ok {
resultObj.ShutdownDelay = v
}
case "order":
if v, ok := keyValue.(int); ok {
resultObj.Order = v
}
case "VGPUs":
if interim, ok := keyValue.([]interface{}); ok {
resultObj.VGPUs = make([]string, len(interim))
for i, interimValue := range interim {
if v, ok := interimValue.(string); ok {
resultObj.VGPUs[i] = v
}
}
}
case "attached_PCIs":
if interim, ok := keyValue.([]interface{}); ok {
resultObj.AttachedPCIs = make([]string, len(interim))
for i, interimValue := range interim {
if v, ok := interimValue.(string); ok {
resultObj.AttachedPCIs[i] = v
}
}
}
case "suspend_SR":
if v, ok := keyValue.(string); ok {
resultObj.SuspendSR = v
}
case "version":
if v, ok := keyValue.(int); ok {
resultObj.Version = v
}
case "generation_id":
if v, ok := keyValue.(string); ok {
resultObj.GenerationId = v
}
case "hardware_platform_version":
if v, ok := keyValue.(int); ok {
resultObj.HardwarePlatformVersion = v
}
case "has_vendor_device":
if v, ok := keyValue.(bool); ok {
resultObj.HasVendorDevice = v
}
case "requires_reboot":
if v, ok := keyValue.(bool); ok {
resultObj.RequiresReboot = v
}
case "reference_label":
if v, ok := keyValue.(string); ok {
resultObj.ReferenceLabel = v
}
case "domain_type":
if v, ok := keyValue.(DomainType); ok {
resultObj.DomainType = v
}
case "NVRAM":
resultObj.NVRAM = 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.NVRAM[mapKeyName] = v
} else {
resultObj.NVRAM[mapKeyName] = ""
}
}
}
}
return resultObj
}
/* GetAllRecords: Return a map of VM references to VM records for all VMs known to the system. */
func (client *XenClient) VMGetAllRecords() (result map[string]VM, err error) {
obj, err := client.APICall("VM.get_all_records")
if err != nil {
return
}
interim := reflect.ValueOf(obj)
result = map[string]VM{}
for _, key := range interim.MapKeys() {
obj := interim.MapIndex(key)
mapObj := ToVM(obj.Interface())
result[key.String()] = *mapObj
}
return
}
/* GetAll: Return a list of all the VMs known to the system. */
func (client *XenClient) VMGetAll() (result []string, err error) {
obj, err := client.APICall("VM.get_all")
if err != nil {
return
}
result = make([]string, len(obj.([]interface{})))
for i, value := range obj.([]interface{}) {
result[i] = value.(string)
}
return
}
/* SetHVMBootPolicy: Set the VM.HVM_boot_policy field of the given VM, which will take effect when it is next started */
func (client *XenClient) VMSetHVMBootPolicy(self string, value string) (err error) {
_, err = client.APICall("VM.set_HVM_boot_policy", self, value)
if err != nil {
return
}
// no return result
return
}
/* SetDomainType: Set the VM.domain_type field of the given VM, which will take effect when it is next started */
func (client *XenClient) VMSetDomainType(self string, value DomainType) (err error) {
_, err = client.APICall("VM.set_domain_type", self, value.String())
if err != nil {
return
}
// no return result
return
}
/* SetActionsAfterCrash: Sets the actions_after_crash parameter */
func (client *XenClient) VMSetActionsAfterCrash(self string, value OnCrashBehaviour) (err error) {
_, err = client.APICall("VM.set_actions_after_crash", self, value.String())
if err != nil {
return
}
// no return result
return
}
/* Import: Import an XVA from a URI */
func (client *XenClient) VMImport(url string, sr string, full_restore bool, force bool) (result []string, err error) {
obj, err := client.APICall("VM.import", url, sr, full_restore, force)
if err != nil {
return
}
result = make([]string, len(obj.([]interface{})))
for i, value := range obj.([]interface{}) {
result[i] = value.(string)
}
return
}
/* SetHasVendorDevice: Controls whether, when the VM starts in HVM mode, its virtual hardware will include the emulated PCI device for which drivers may be available through Windows Update. Usually this should never be changed on a VM on which Windows has been installed: changing it on such a VM is likely to lead to a crash on next start. */
func (client *XenClient) VMSetHasVendorDevice(self string, value bool) (err error) {
_, err = client.APICall("VM.set_has_vendor_device", self, value)
if err != nil {
return
}
// no return result
return
}
/* CallPlugin: Call an API plugin on this vm */
func (client *XenClient) VMCallPlugin(vm string, plugin string, fn string, args map[string]string) (result string, err error) {
obj, err := client.APICall("VM.call_plugin", vm, plugin, fn, args)
if err != nil {
return
}
result = obj.(string)
return
}
/* QueryServices: Query the system services advertised by this VM and register them. This can only be applied to a system domain. */
func (client *XenClient) VMQueryServices(self string) (result map[string]string, err error) {
obj, err := client.APICall("VM.query_services", self)
if err != nil {
return
}
interim := reflect.ValueOf(obj)
result = map[string]string{}
for _, key := range interim.MapKeys() {
obj := interim.MapIndex(key)
result[key.String()] = obj.String()
}
return
}
/* SetAppliance: Assign this VM to an appliance. */
func (client *XenClient) VMSetAppliance(self string, value string) (err error) {
_, err = client.APICall("VM.set_appliance", self, value)
if err != nil {
return
}
// no return result
return
}
/* ImportConvert: Import using a conversion service. */
func (client *XenClient) VMImportConvert(xtype string, username string, password string, sr string, remote_config map[string]string) (err error) {
_, err = client.APICall("VM.import_convert", xtype, username, password, sr, remote_config)
if err != nil {
return
}
// no return result
return
}
/* Recover: Recover the VM */
func (client *XenClient) VMRecover(self string, session_to string, force bool) (err error) {
_, err = client.APICall("VM.recover", self, session_to, force)
if err != nil {
return
}
// no return result
return
}
/* GetSRsRequiredForRecovery: List all the SR's that are required for the VM to be recovered */
func (client *XenClient) VMGetSRsRequiredForRecovery(self string, session_to string) (result []string, err error) {
obj, err := client.APICall("VM.get_SRs_required_for_recovery", self, session_to)
if err != nil {
return
}
result = make([]string, len(obj.([]interface{})))
for i, value := range obj.([]interface{}) {
result[i] = value.(string)
}
return
}