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
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// Represents a set of physical resources: a single host,
/// a subset of a host's resources, or resources spanning multiple hosts.
///
/// Resource pools can be subdivided by creating child resource pools. In
/// order to run, a virtual machine must be associated as a child of a resource
/// pool.
///
/// In a parent/child hierarchy of resource pools and virtual machines, the
/// single resource pool that has no parent pool is known as the _root resource
/// pool_.
///
/// **Configuration**
///
/// A resource pool is configured with a set of CPU (in MHz) and memory (in MB)
/// resources. These resources are specified in absolute terms with a resource
/// reservation and a resource limit, along with a shares setting. The shares
/// are used during resource contention, to ensure graceful degradation.
///
/// For the root resource pool, the values of the reservation and
/// the limit are set by the system and are not configurable. The
/// reservation and limit are set to the same value, indicating the total amount
/// of resources the system has available to run virtual machines. This is
/// computed as the aggregated CPU and memory resources provided by the set
/// of current available hosts in the parent compute resource minus the
/// overhead of the virtualization layer.
///
/// Since the resource pool configuration is absolute (in MHz or MB), the
/// configuration can become invalid when resources are removed. This can
/// happen if a host is removed from the cluster, if a host becomes
/// unavailable, or if a host is placed in maintenance mode. When this
/// happens, the system flags misconfigured resource pools and displays the
/// reservations and limits that are in effect. Further, in a DRS enabled cluster,
/// the tree can be misconfigured if the user bypasses VirtualCenter and powers on
/// VMs directly on the host.
///
/// **A General Discussion of Resource pool states and admission control**
/// There are three states that the resource pool tree can be in: undercommited
/// (green), overcommited (yellow), and inconsistent (red). Depending on the
/// state, different resource pool configuration policies are enforced. The
/// states are described in more detail below:
/// - **GREEN (aka undercommitted)**: We have a tree that is
/// in a _good_ state. Every node has a reservation greater than the sum of
/// the reservations for its children. We have enough capacity at the root to
/// satisfy all the resources reserved by the children. All operations
/// performed on the tree, such as powering on virtual machines, creating
/// new resource pools, or reconfiguring resource settings, will ensure
/// that the above constraints are maintained.
/// - **RED (aka. inconsistent)**: One or more nodes in the
/// tree has children whose reservations are greater than the node is configured to
/// support. For example, i) a resource pool with a fixed reservation has a running
/// virtual machine with a reservation that is higher than the reservation on
/// resource pool itself., or ii) the child reservations are greater than the limit.
///
/// In this state, the DRS algorithm is disabled until the resource pool tree's
/// configuration has been brought back into a consistent state. We also restrict
/// the resources that such invalid nodes request from their parents to the
/// configured reservation/limit, in an attempt to isolate the problem to a small
/// subtree. For the rest of the tree, we determine whether the cluster is
/// undercommitted or overcommitted according to the existing rules and perform
/// admission control accordingly.
///
/// Note that since all changes to the resource settings are validated on the
/// VirtualCenter server, the system cannot be brought into this state by simply
/// manipulating a cluster resource pool tree through VirtualCenter. It can only
/// happen if a virtual machine gets powered on directly on a host that is part of
/// a DRS cluster.
/// - **YELLOW (aka overcommitted)**: In this state, the tree is
/// consistent internally, but the root resource pool does not have the capacity at
/// to meet the reservation of its children. We can only go from GREEN -> YELLOW if
/// we lose resources at the root. For example, hosts becomes unavailable or is
/// put into maintenance mode. Note that we will always have enough capacity at the root
/// to run all currently powered on VMs. However, we may not be able to satisfy all
/// resource pool reservations in the tree. In this state, the reservation configured for
/// a resource pool is no longer guaranteed, but the limits are still enforced.
/// This provides additional flexibility for bringing the tree back into a
/// consistent state, without risking bringing the tree into a RED state. In
/// more detail:
/// - **Resource Pool** The root is considered to have unlimited
/// capacity. You can reserve resources without any check except the
/// requirement that the tree remains consistent. This means that
/// nodes whose parents are all configured with expandable reservations and no limit
/// will have unlimited available resources. However, if there is an ancestor with
/// a fixed reservation or an expandable reservation with a limit somewhere, then the
/// node will be limited by the reservation/limit of the ancestor.
/// - **Virtual Machine** Virtual machines are limited by ancestors
/// with a fixed reservation and the capacity at the root.
///
/// **Destroying a ResourcePool**
///
/// When a ResourcePool is destroyed, all the virtual machines are reassigned to its
/// parent pool. The root resource pool cannot be destroyed, and invoking destroy
/// on it will throw an InvalidType fault.
///
/// Any vApps in the ResourcePool will be moved to the ResourcePool's parent
/// before the pool is destroyed.
///
/// The Resource.DeletePool privilege must be held on the pool as well as the parent
/// of the resource pool. Also, the Resource.AssignVMToPool privilege must be held
/// on the resource pool's parent pool and any virtual machines that are reassigned.
#[derive(Clone)]
pub struct ResourcePool {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl ResourcePool {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
/// Creates a new resource pool.
///
/// ***Required privileges:*** Resource.CreatePool
///
/// ## Parameters:
///
/// ### name
/// The name of the ResourcePool. Any % (percent) character
/// used in this parameter must be escaped, unless it is used
/// to start an escape sequence. Clients may also escape any
/// other characters in this parameter.
///
/// ### spec
/// The spec for the ResourcePool.
/// All values in ResourceAllocationInfo must be specified and
/// are not optional.
///
/// ## Returns:
///
/// A reference to the new resource pool.
///
/// Refers instance of *ResourcePool*.
///
/// ## Errors:
///
/// ***NotSupported***: if the ComputeResource does not support
/// nested resource pools.
///
/// ***InvalidName***: if the name is not a valid entity name.
///
/// ***DuplicateName***: if this pool already contains an object
/// with the given name.
///
/// ***InvalidArgument***: if the pool specification is invalid.
///
/// ***InsufficientResourcesFault***: if the operation would violate a resource
/// usage policy. Typically, a more specific subclass, such as
/// InsufficientCpuResourcesFault will be thrown.
pub async fn create_resource_pool(&self, name: &str, spec: &crate::types::structs::ResourceConfigSpec) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CreateResourcePoolRequestType {name, spec, };
let bytes = self.client.invoke("", "ResourcePool", &self.mo_id, "CreateResourcePool", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Creates a new vApp container.
///
/// Any % (percent) character used in this name parameter must be escaped, unless it
/// is used to start an escape sequence. Clients may also escape any other characters
/// in this name parameter.
///
/// ***Required privileges:*** VApp.Create
///
/// ## Parameters:
///
/// ### name
/// The name of the vApp container in the inventory
///
/// ### res_spec
/// The resource configuration for the vApp container (same as for a
/// regular resource pool).
///
/// ### config_spec
/// The specification of the vApp specific meta-data.
///
/// ### vm_folder
/// The parent folder for the vApp. This must be null if this is
/// a child vApp.
///
/// Refers instance of *Folder*.
///
/// ## Returns:
///
/// The created vApp object.
///
/// Refers instance of *VirtualApp*.
///
/// ## Errors:
///
/// ***NotSupported***: if the ComputeResource does not support
/// nested resource pools.
///
/// ***InvalidName***: if the name is not a valid entity name.
///
/// ***DuplicateName***: if this pool already contains an object
/// with the given name.
///
/// ***InvalidArgument***: if the pool specification is invalid.
///
/// ***InsufficientResourcesFault***: if the operation would violate a resource
/// usage policy. Typically, a more specific subclass, such as
/// InsufficientCpuResourcesFault will be thrown.
///
/// ***InvalidState***: if the resource pool does not support the operation in
/// its current state. This will typically be a subclass such
/// as *NoActiveHostInCluster*.
///
/// ***VmConfigFault***: or a more specific subclass, if errors are found in
/// the supplied in VApp configuration.
pub async fn create_v_app(&self, name: &str, res_spec: &crate::types::structs::ResourceConfigSpec, config_spec: &crate::types::structs::VAppConfigSpec, vm_folder: Option<&crate::types::structs::ManagedObjectReference>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CreateVAppRequestType {name, res_spec, config_spec, vm_folder, };
let bytes = self.client.invoke("", "ResourcePool", &self.mo_id, "CreateVApp", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Creates a new virtual machine in a vApp container.
///
/// This method supports creating a virtual machine directly in a vApp. A
/// virtual machine in a vApp is not associated with a VM folder and therefore
/// cannot be created using the method on a *Folder*.
///
/// This method can only be called directly on a *vApp*
/// or on a resource pool that is a child of a vApp.
///
/// The privilege VirtualMachine.Inventory.Create is required on this entity. Further,
/// if this is a resource pool, the privilege Resource.AssignVMToPool is required. If
/// this is a vApp, the privilege VApp.AssignVM is required.
///
/// Depending on the properties of the virtual machine bring created, additional
/// privileges may be required. See *Folder.CreateVM_Task* for a description of
/// these privileges.
///
/// ***Required privileges:*** VirtualMachine.Inventory.Create
///
/// ## Parameters:
///
/// ### config
/// The configuration of the virtual machine hardware.
///
/// ### host
/// The target host on which the virtual machine will run. This must
/// specify a host that is a member of the ComputeResource indirectly
/// specified by the pool. For a stand-alone host or a cluster with DRS,
/// host can be omitted, and the system selects a default.
///
/// Refers instance of *HostSystem*.
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor the
/// operation. The *info.result* property in the
/// *Task* contains the newly created *VirtualMachine*
/// upon success.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***VmConfigFault***: if the configSpec has incorrect values. Typically, a more
/// specific subclass is thrown.
///
/// ***OutOfBounds***: if Host.capability.maxSupportedVMs is exceeded.
///
/// ***FileAlreadyExists***: if the requested cfgPath for the virtual machine's
/// configuration file already exists.
///
/// ***FileFault***: if there is a problem creating the virtual machine on disk.
/// Typically, a more specific subclass, such as NoDiskSpace, will be thrown.
///
/// ***InvalidName***: if the name is not a valid entity name.
///
/// ***InsufficientResourcesFault***: if this operation would violate a resource
/// usage policy.
///
/// ***InvalidDatastore***: if the operation cannot be performed on the
/// target datastores.
///
/// ***VmWwnConflict***: if the WWN of the virtual machine has been used by
/// other virtual machines.
///
/// ***NotSupported***: if this resource pool is not a vApp or is a child
/// of a vApp.
pub async fn create_child_vm_task(&self, config: &crate::types::structs::VirtualMachineConfigSpec, host: Option<&crate::types::structs::ManagedObjectReference>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CreateChildVmRequestType {config, host, };
let bytes = self.client.invoke("", "ResourcePool", &self.mo_id, "CreateChildVM_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Destroys this object, deleting its contents and removing it from its parent
/// folder (if any).
///
/// NOTE: The appropriate privilege must be held on the parent of the destroyed
/// entity as well as the entity itself.
/// This method can throw one of several exceptions. The exact set of exceptions
/// depends on the kind of entity that is being removed. See comments for
/// each entity for more information on destroy behavior.
///
/// ***Required privileges:*** Resource.DeletePool
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor the
/// operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// Failure
pub async fn destroy_task(&self) -> Result<crate::types::structs::ManagedObjectReference> {
let bytes = self.client.invoke("", "ResourcePool", &self.mo_id, "Destroy_Task", None).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Removes all child resource pools recursively.
///
/// All virtual machines and vApps
/// associated with the child resource pools get associated with this resource pool.
///
/// Note that resource pools contained in child vApps are not affected.
///
/// The privilege checks performed are the following.
/// - Resource.DeletePool privilege must be held on this object and each of it's
/// immediate children to be destroyed.
/// - If VMs are being moved, the privilege Resource.AssignVMToPool must be held
/// on this resource pool as well as on any virtual machines being moved.
/// - If vApps are being moved, the privilege Resource.AssignVAppToPool
/// must be held on this resource pool as well as on any vApps being
/// moved.
pub async fn destroy_children(&self) -> Result<()> {
self.client.invoke_void("", "ResourcePool", &self.mo_id, "DestroyChildren", None).await
}
/// Creates a new entity in this resource pool.
///
/// The import process consists of two
/// steps:
/// 1. Create the VMs and/or vApps that make up the entity.
/// 2. Upload virtual disk contents.
///
/// In step 1, the client must wait for the server to create all inventory
/// objects. It does that by monitoring the *HttpNfcLease.state*
/// property on the *HttpNfcLease* object returned from this call.
/// When the server is done creating objects, the lease will change to the
/// ready state, and step 2 begins. If an error occurs while the server is
/// creating inventory objects, the lease will change to the error state, and
/// the import process is aborted.
///
/// In step 2, the client uploads disk contents using the URLs provided in the
/// *HttpNfcLease.info* property of the lease. The client must call
/// *HttpNfcLease.HttpNfcLeaseProgress* on the lease periodically to keep the
/// lease alive and report progress to the server. Failure to do so will cause
/// the lease to time out, and the import process will be aborted.
///
/// When the client is done uploading disks, it completes the lease by calling
/// *HttpNfcLease.HttpNfcLeaseComplete*. The client can also abort the import
/// process by calling *HttpNfcLease.HttpNfcLeaseAbort*.
///
/// If the import process fails, is aborted, or times out, all created inventory
/// objects are removed, including all virtual disks.
///
/// This operation only works if the folder's childType includes VirtualMachine.
///
/// Depending on the properties of the virtual machine bring imported, additional
/// privileges may be required. See *Folder.CreateVM_Task* for a description of
/// these privileges.
///
/// ***Required privileges:*** VApp.Import
///
/// ## Parameters:
///
/// ### spec
/// An *ImportSpec* describing what to import.
///
/// ### folder
/// The folder to which the entity will be attached.
///
/// ***Required privileges:*** VApp.Import
///
/// Refers instance of *Folder*.
///
/// ### host
/// The target host on which the entity will run. This must
/// specify a host that is a member of the ComputeResource indirectly
/// specified by the pool. For a stand-alone host or a cluster with DRS,
/// host can be omitted, and the system selects a default.
///
/// Refers instance of *HostSystem*.
///
/// ## Returns:
///
/// a *HttpNfcLease* object which is used to drive the import
/// session.
///
/// Refers instance of *HttpNfcLease*.
///
/// ## Errors:
///
/// ***VmConfigFault***: if a VM configSpec has incorrect values. Typically, a more
/// specific subclass is thrown.
///
/// ***OutOfBounds***: if Host.capability.maxSupportedVMs is exceeded.
///
/// ***FileAlreadyExists***: if the requested cfgPath for the virtual machine's
/// configuration file already exists.
///
/// ***FileFault***: if there is a problem creating the virtual machine on disk.
/// Typically, a more specific subclass, such as NoDiskSpace, will be thrown.
///
/// ***DuplicateName***: if another virtual machine in the same folder already has
/// the specified target name.
///
/// ***InvalidName***: if the name is not a valid entity name.
///
/// ***NotSupported***: if the virtual machine is being created within a folder
/// whose *Folder.childType* property is not set to "VirtualMachine",
/// a vApp is being imported into a resource pool that does not support
/// nested resource pools, or a virtual machine is being imported into a resource
/// pool and no folder is given.
///
/// ***InsufficientResourcesFault***: if this operation would violate a resource
/// usage policy.
///
/// ***InvalidDatastore***: if the operation cannot be performed on the
/// target datastores.
///
/// ***VmWwnConflict***: if the WWN of the virtual machine has been used by
/// other virtual machines.
pub async fn import_v_app(&self, spec: &dyn crate::types::traits::ImportSpecTrait, folder: Option<&crate::types::structs::ManagedObjectReference>, host: Option<&crate::types::structs::ManagedObjectReference>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = ImportVAppRequestType {spec, folder, host, };
let bytes = self.client.invoke("", "ResourcePool", &self.mo_id, "ImportVApp", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Moves a set of resource pools, vApps or virtual machines into this pool.
///
/// The
/// pools, vApps and virtual machines must be part of the cluster or standalone
/// host that contains this pool.
///
/// For each entity being moved, the move is subject to the following privilege
/// checks:
/// - If the object being moved is a ResourcePool, then Resource.MovePool must be
/// held on the pool being moved and it's former parent pool or vApp. If the
/// target is a vApp, the privilege VApp.AssignResourcePool must be held on
/// it. If the target is a ResourcePool, Resource.MovePool must be held on it.
/// - If the object being moved is a VirtualApp, VApp.Move must be held on
/// the vApp being moved and it's former parent pool or vApp. If the target
/// entity is a resource pool, Resource.AssignVAppToPool must be held on the
/// target. If the target is a vApp, the privilege VApp.AssignVApp must
/// be held on the target vApp.
/// - If the object being moved is a VirtualMachine, then if the target is a
/// ResourcePool, Resource.AssignVMToPool is required on the VirtualMachine and the
/// target pool. If the target is a vApp, VApp.AssignVM is required on both
/// the VirtualMachine and the target pool.
///
/// This operation is typically used by clients when they implement a drag-and-drop
/// interface to move a set of objects into a folder.
///
/// This operation is only transactional with respect to each individual entity.
/// The set of entities is moved sequentially, as specified in the list,
/// and committed one at a time. If a failure is detected, then the method
/// terminates with an exception.
///
/// The root resource pool cannot be moved.
///
/// ## Parameters:
///
/// ### list
/// A list of ResourcePool and VirtualMachine objects.
///
/// Refers instances of *ManagedEntity*.
///
/// ## Errors:
///
/// ***DuplicateName***: if this pool already contains an object with
/// the given name.
///
/// ***InvalidArgument***: if an ancestor of this pool is in the list.
///
/// ***InsufficientResourcesFault***: if the move would violate the resource usage
/// policy. Typically, a more specific subclass, such as
/// InsufficientMemoryResourcesFault.
pub async fn move_into_resource_pool(&self, list: &[crate::types::structs::ManagedObjectReference]) -> Result<()> {
let input = MoveIntoResourcePoolRequestType {list, };
self.client.invoke_void("", "ResourcePool", &self.mo_id, "MoveIntoResourcePool", Some(&input)).await
}
/// Deprecated as of vSphere API 6.5.
///
/// Get a value range and default values for *ResourceConfigSpec*.
///
/// This API was never implemented, and there is no replacement for it.
///
/// ***Required privileges:*** Resource.EditPool
///
/// ## Returns:
///
/// *ResourceConfigOption* object.
pub async fn query_resource_config_option(&self) -> Result<crate::types::structs::ResourceConfigOption> {
let bytes = self.client.invoke("", "ResourcePool", &self.mo_id, "QueryResourceConfigOption", None).await?;
let result: crate::types::structs::ResourceConfigOption = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Refreshes the resource usage data that is available in
/// *ResourcePoolRuntimeInfo*.
///
/// The latest runtime resource usage of this resource pool may not be
/// available immediately after operations that alter resource usage,
/// such as powering on a virtual machine. Invoke this method when resource
/// usage may have recently changed, and the most up-to-date value in the
/// *ResourcePoolRuntimeInfo* is needed.
///
/// ***Required privileges:*** System.View
pub async fn refresh_runtime(&self) -> Result<()> {
self.client.invoke_void("", "ResourcePool", &self.mo_id, "RefreshRuntime", None).await
}
/// Adds an existing virtual machine to this resource pool or vApp.
///
/// This operation only works for vApps or resource pools that are children of
/// vApps. To register a VM in a folder, see *Folder.RegisterVM_Task*.
///
/// Any % (percent) character used in this name parameter must be escaped, unless it
/// is used to start an escape sequence. Clients may also escape any other characters
/// in this name parameter.
/// In addition to the VirtualMachine.Inventory.Register privilege, it
/// requires System.Read privilege on the datastore that the existing virtual
/// machine resides on.
///
/// ***Required privileges:*** VirtualMachine.Inventory.Register
///
/// ## Parameters:
///
/// ### path
/// A datastore path to the virtual machine. If the path ends with
/// ".vmtx", indicating that it refers to a VM template, an InvalidArgument
/// fault is thrown.
///
/// ### name
/// The name to be assigned to the virtual machine. If this parameter is
/// not set, the displayName configuration parameter of the virtual machine is
/// used. An entity name must be a non-empty string of less than 80
/// characters. The slash (/), backslash (\\) and percent (%) will be
/// escaped using the URL syntax. For example, %2F.
///
/// ### host
/// The target host on which the virtual machine will run. This parameter
/// must specify a host that is a member of the ComputeResource to which this
/// resource pool belongs. For a stand-alone host or a cluster with DRS,
/// the parameter can be omitted, and the system selects a default.
///
/// Refers instance of *HostSystem*.
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor the
/// operation. The *info.result* property in the
/// *Task* contains the newly registered *VirtualMachine*
/// upon success.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***NotSupported***: if the operation is not supported. For example, if the
/// operation is invoked on a resource pool that is unrelated to a vApp.
///
/// ***OutOfBounds***: if the maximum number of VMs has been exceeded.
///
/// ***AlreadyExists***: if the virtual machine is already registered.
///
/// ***InvalidDatastore***: if the operation cannot be performed on the
/// target datastores.
///
/// ***NotFound***: if the configuration file is not found on the system.
///
/// ***InvalidName***: if the entity name is invalid.
///
/// ***InvalidArgument***: if any of the arguments are invalid and a more specific
/// fault type does not apply.
///
/// ***VmConfigFault***: if the format / configuration of the virtual machine
/// is invalid. Typically, a more specific fault is thrown such as
/// InvalidFormat if the configuration file cannot be read, or
/// InvalidDiskFormat if the disks cannot be read.
///
/// ***FileFault***: if there is an error accessing the files on disk.
///
/// ***InsufficientResourcesFault***: if this operation would violate a resource
/// usage policy.
pub async fn register_child_vm_task(&self, path: &str, name: Option<&str>, host: Option<&crate::types::structs::ManagedObjectReference>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = RegisterChildVmRequestType {path, name, host, };
let bytes = self.client.invoke("", "ResourcePool", &self.mo_id, "RegisterChildVM_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Reload the entity state.
///
/// Clients only need to call this method
/// if they changed some external state that affects the service
/// without using the Web service interface to perform the change.
/// For example, hand-editing a virtual machine configuration file
/// affects the configuration of the associated virtual machine but
/// the service managing the virtual machine might not monitor the
/// file for changes. In this case, after such an edit, a client
/// would call "reload" on the associated virtual machine to ensure
/// the service and its clients have current data for the
/// virtual machine.
///
/// ***Required privileges:*** System.Read
pub async fn reload(&self) -> Result<()> {
self.client.invoke_void("", "ResourcePool", &self.mo_id, "Reload", None).await
}
/// Renames this managed entity.
///
/// Any % (percent) character used in this name parameter
/// must be escaped, unless it is used to start an escape
/// sequence. Clients may also escape any other characters in
/// this name parameter.
///
/// See also *ManagedEntity.name*.
///
/// ***Required privileges:*** Resource.RenamePool
///
/// ## Parameters:
///
/// ### new_name
/// -
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor the
/// operation.
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***DuplicateName***: If another object in the same folder has the target name.
///
/// ***InvalidName***: If the new name is not a valid entity name.
pub async fn rename_task(&self, new_name: &str) -> Result<crate::types::structs::ManagedObjectReference> {
let input = RenameRequestType {new_name, };
let bytes = self.client.invoke("", "ResourcePool", &self.mo_id, "Rename_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Assigns a value to a custom field.
///
/// The setCustomValue method requires
/// whichever updatePrivilege is defined as one of the
/// *CustomFieldDef.fieldInstancePrivileges*
/// for the CustomFieldDef whose value is being changed.
///
/// ## Parameters:
///
/// ### key
/// The name of the field whose value is to be updated.
///
/// ### value
/// Value to be assigned to the custom field.
pub async fn set_custom_value(&self, key: &str, value: &str) -> Result<()> {
let input = SetCustomValueRequestType {key, value, };
self.client.invoke_void("", "ResourcePool", &self.mo_id, "setCustomValue", Some(&input)).await
}
/// Changes resource configuration of a set of children of this resource pool.
///
/// The
/// method allows bulk modifications of the set of the direct children
/// (virtual machines and resource pools).
///
/// Bulk modifications are not transactional. Each modification is made individually.
/// If a failure is encountered while applying the changes, then the processing stops,
/// meaning at least one and as many as all of the changes are not applied.
///
/// A set can include a subset of the resources. Children that are not
/// mentioned in the list are not changed.
///
/// For each ResourceConfigSpec, the following privilege checks apply:
/// - If the ResourceConfigSpec refers to a child resource pool or a child
/// vApp, the privileges required are the same as would be required for
/// calling *ResourcePool.UpdateConfig* on that entity.
/// - If the ResourceConfigSpec refers to a virtual machine,
/// VirtualMachine.Config.Resource must be held on the virtual machine.
///
/// ## Parameters:
///
/// ### spec
/// -
///
/// ## Errors:
///
/// ***InvalidArgument***: if a managed entity that is not a child of this group
/// is included.
///
/// ***InsufficientResourcesFault***: if the operation would violate a resource
/// usage policy. Typically, a more specific subclass, such as
/// InsufficientMemoryResourcesFault will be thrown.
pub async fn update_child_resource_configuration(&self, spec: &[crate::types::structs::ResourceConfigSpec]) -> Result<()> {
let input = UpdateChildResourceConfigurationRequestType {spec, };
self.client.invoke_void("", "ResourcePool", &self.mo_id, "UpdateChildResourceConfiguration", Some(&input)).await
}
/// Updates the configuration of the resource pool.
///
/// Any % (percent) character used in this name parameter must be escaped, unless it
/// is used to start an escape sequence. Clients may also escape any other characters
/// in this name parameter.
///
/// The privilege checks for this operation are as follows:
/// - If this is a resource pool, the privilege Resource.EditPool is required on
/// this and on the parent pool or vApp.
/// - If this is a vApp, the privilege VApp.ResourceConfig is required on
/// this and on the parent pool or vApp.
///
/// ## Parameters:
///
/// ### name
/// If set, then the new name of the resource pool.
///
/// ### config
/// If set, then the new resource allocation for this
/// resource pool.
///
/// ## Errors:
///
/// ***InvalidName***: if the name is not a valid entity name.
///
/// ***DuplicateName***: if the name is changed to an already existing name.
///
/// ***InvalidArgument***: if the parameters are out of range,
/// or if the reservationLimit field is set.
///
/// ***InsufficientResourcesFault***: if the pool specification cannot be
/// supported by the parent resource pool or vApp.
///
/// ***ConcurrentAccess***: if the changeVersion does not match the server's
/// changeVersion for the configuration.
pub async fn update_config(&self, name: Option<&str>, config: Option<&crate::types::structs::ResourceConfigSpec>) -> Result<()> {
let input = UpdateConfigRequestType {name, config, };
self.client.invoke_void("", "ResourcePool", &self.mo_id, "UpdateConfig", Some(&input)).await
}
/// Whether alarm actions are enabled for this entity.
///
/// True if enabled; false otherwise.
///
/// ***Required privileges:*** System.Read
pub async fn alarm_actions_enabled(&self) -> Result<Option<bool>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "alarmActionsEnabled").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// List of custom field definitions that are valid for the object's type.
///
/// The fields are sorted by *CustomFieldDef.name*.
///
/// ***Required privileges:*** System.View
pub async fn available_field(&self) -> Result<Option<Vec<crate::types::structs::CustomFieldDef>>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "availableField").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// The resource configuration of all direct children (VirtualMachine and
/// ResourcePool) of this resource group.
///
/// Property collector update notifications might not be generated for this
/// property. To listen for the child configuration change, please create
/// PropertyCollector filter on the child entities directly.
pub async fn child_configuration(&self) -> Result<Option<Vec<crate::types::structs::ResourceConfigSpec>>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "childConfiguration").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Configuration of this resource pool.
pub async fn config(&self) -> Result<crate::types::structs::ResourceConfigSpec> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "config").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property config was empty".to_string()))?;
let result: crate::types::structs::ResourceConfigSpec = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// Current configuration issues that have been detected for this entity.
///
/// Typically,
/// these issues have already been logged as events. The entity stores these
/// events as long as they are still current. The
/// *configStatus* property provides an overall status
/// based on these events.
pub async fn config_issue(&self) -> Result<Option<Vec<crate::types::structs::Event>>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "configIssue").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// The configStatus indicates whether or not the system has detected a configuration
/// issue involving this entity.
///
/// For example, it might have detected a
/// duplicate IP address or MAC address, or a host in a cluster
/// might be out of compliance. The meanings of the configStatus values are:
/// - red: A problem has been detected involving the entity.
/// - yellow: A problem is about to occur or a transient condition
/// has occurred (For example, reconfigure fail-over policy).
/// - green: No configuration issues have been detected.
/// - gray: The configuration status of the entity is not being monitored.
///
/// A green status indicates only that a problem has not been detected;
/// it is not a guarantee that the entity is problem-free.
///
/// The *configIssue* property contains a list of the
/// problems that have been detected.
/// In releases after vSphere API 5.0, vSphere Servers might not
/// generate property collector update notifications for this property.
/// To obtain the latest value of the property, you can use
/// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
/// If you use the PropertyCollector.WaitForUpdatesEx method, specify
/// an empty string for the version parameter. Any other version value will not
/// produce any property values as no updates are generated.
pub async fn config_status(&self) -> Result<crate::types::enums::ManagedEntityStatusEnum> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "configStatus").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property configStatus was empty".to_string()))?;
let result: crate::types::enums::ManagedEntityStatusEnum = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// Custom field values.
///
/// ***Required privileges:*** System.View
pub async fn custom_value(&self) -> Result<Option<Vec<Box<dyn crate::types::traits::CustomFieldValueTrait>>>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "customValue").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// A set of alarm states for alarms that apply to this managed entity.
///
/// The set includes alarms defined on this entity
/// and alarms inherited from the parent entity,
/// or from any ancestors in the inventory hierarchy.
///
/// Alarms are inherited if they can be triggered by this entity or its descendants.
/// This set does not include alarms that are defined on descendants of this entity.
///
/// ***Required privileges:*** System.View
pub async fn declared_alarm_state(&self) -> Result<Option<Vec<crate::types::structs::AlarmState>>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "declaredAlarmState").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// List of operations that are disabled, given the current runtime
/// state of the entity.
///
/// For example, a power-on operation always fails if a
/// virtual machine is already powered on. This list can be used by clients to
/// enable or disable operations in a graphical user interface.
///
/// Note: This list is determined by the current runtime state of an entity,
/// not by its permissions.
///
/// This list may include the following operations for a HostSystem:
/// - *HostSystem.EnterMaintenanceMode_Task*
/// - *HostSystem.ExitMaintenanceMode_Task*
/// - *HostSystem.RebootHost_Task*
/// - *HostSystem.ShutdownHost_Task*
/// - *HostSystem.ReconnectHost_Task*
/// - *HostSystem.DisconnectHost_Task*
///
/// This list may include the following operations for a VirtualMachine:
/// - *VirtualMachine.AnswerVM*
/// - *ManagedEntity.Rename_Task*
/// - *VirtualMachine.CloneVM_Task*
/// - *VirtualMachine.PowerOffVM_Task*
/// - *VirtualMachine.PowerOnVM_Task*
/// - *VirtualMachine.SuspendVM_Task*
/// - *VirtualMachine.ResetVM_Task*
/// - *VirtualMachine.ReconfigVM_Task*
/// - *VirtualMachine.RelocateVM_Task*
/// - *VirtualMachine.MigrateVM_Task*
/// - *VirtualMachine.CustomizeVM_Task*
/// - *VirtualMachine.ShutdownGuest*
/// - *VirtualMachine.StandbyGuest*
/// - *VirtualMachine.RebootGuest*
/// - *VirtualMachine.CreateSnapshot_Task*
/// - *VirtualMachine.RemoveAllSnapshots_Task*
/// - *VirtualMachine.RevertToCurrentSnapshot_Task*
/// - *VirtualMachine.MarkAsTemplate*
/// - *VirtualMachine.MarkAsVirtualMachine*
/// - *VirtualMachine.ResetGuestInformation*
/// - *VirtualMachine.MountToolsInstaller*
/// - *VirtualMachine.UnmountToolsInstaller*
/// - *ManagedEntity.Destroy_Task*
/// - *VirtualMachine.UpgradeVM_Task*
/// - *VirtualMachine.ExportVm*
///
/// This list may include the following operations for a ResourcePool:
/// - *ResourcePool.ImportVApp*
/// - *ResourcePool.CreateChildVM_Task*
/// - *ResourcePool.UpdateConfig*
/// - *Folder.CreateVM_Task*
/// - *ManagedEntity.Destroy_Task*
/// - *ManagedEntity.Rename_Task*
///
/// This list may include the following operations for a VirtualApp:
/// - *ManagedEntity.Destroy_Task*
/// - *VirtualApp.CloneVApp_Task*
/// - *VirtualApp.unregisterVApp_Task*
/// - *VirtualApp.ExportVApp*
/// - *VirtualApp.PowerOnVApp_Task*
/// - *VirtualApp.PowerOffVApp_Task*
/// - *VirtualApp.UpdateVAppConfig*
///
/// In releases after vSphere API 5.0, vSphere Servers might not
/// generate property collector update notifications for this property.
/// To obtain the latest value of the property, you can use
/// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
/// If you use the PropertyCollector.WaitForUpdatesEx method, specify
/// an empty string for the version parameter. Any other version value will not
/// produce any property values as no updates are generated.
pub async fn disabled_method(&self) -> Result<Option<Vec<String>>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "disabledMethod").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Access rights the current session has to this entity.
///
/// ***Required privileges:*** System.View
pub async fn effective_role(&self) -> Result<Option<Vec<i32>>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "effectiveRole").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Name of this entity, unique relative to its parent.
///
/// Any / (slash), \\ (backslash), character used in this
/// name element will be escaped. Similarly, any % (percent) character used in
/// this name element will be escaped, unless it is used to start an escape
/// sequence. A slash is escaped as %2F or %2f. A backslash is escaped as %5C or
/// %5c, and a percent is escaped as %25.
///
/// ***Required privileges:*** System.View
pub async fn name(&self) -> Result<String> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "name").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property name was empty".to_string()))?;
let result: String = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// The namespace with which the ResourcePool is associated.
///
/// Namespace is a
/// vAPI resource which divides cluster resources and allows administrators
/// to give Kubernetes environments to their development teams.
/// This property is set only at the time of creation and cannot change.
///
/// ***Required privileges:*** System.View
pub async fn namespace(&self) -> Result<Option<String>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "namespace").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// General health of this managed entity.
///
/// The overall status of the managed entity is computed as the worst status
/// among its alarms and the configuration issues detected on the entity.
/// The status is reported as one of the following values:
/// - red: The entity has alarms or configuration issues with a red status.
/// - yellow: The entity does not have alarms or configuration issues with a
/// red status, and has at least one with a yellow status.
/// - green: The entity does not have alarms or configuration issues with a
/// red or yellow status, and has at least one with a green status.
/// - gray: All of the entity's alarms have a gray status and the
/// configuration status of the entity is not being monitored.
///
/// In releases after vSphere API 5.0, vSphere Servers might not
/// generate property collector update notifications for this property.
/// To obtain the latest value of the property, you can use
/// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
/// If you use the PropertyCollector.WaitForUpdatesEx method, specify
/// an empty string for the version parameter. Any other version value will not
/// produce any property values as no updates are generated.
pub async fn overall_status(&self) -> Result<crate::types::enums::ManagedEntityStatusEnum> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "overallStatus").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property overallStatus was empty".to_string()))?;
let result: crate::types::enums::ManagedEntityStatusEnum = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// The ComputeResource to which this set of one or more nested resource pools
/// belong.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// Refers instance of *ComputeResource*.
pub async fn owner(&self) -> Result<crate::types::structs::ManagedObjectReference> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "owner").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property owner was empty".to_string()))?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// Parent of this entity.
///
/// This value is null for the root object and for
/// *VirtualMachine* objects that are part of
/// a *VirtualApp*.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// Refers instance of *ManagedEntity*.
pub async fn parent(&self) -> Result<Option<crate::types::structs::ManagedObjectReference>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "parent").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// List of permissions defined for this entity.
pub async fn permission(&self) -> Result<Option<Vec<crate::types::structs::Permission>>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "permission").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// The set of recent tasks operating on this managed entity.
///
/// This is a subset
/// of *TaskManager.recentTask* belong to this entity. A task in this
/// list could be in one of the four states: pending, running, success or error.
///
/// This property can be used to deduce intermediate power states for
/// a virtual machine entity. For example, if the current powerState is "poweredOn"
/// and there is a running task performing the "suspend" operation, then the virtual
/// machine's intermediate state might be described as "suspending."
///
/// Most tasks (such as power operations) obtain exclusive access to the virtual
/// machine, so it is unusual for this list to contain more than one running task.
/// One exception, however, is the task of cloning a virtual machine.
/// In releases after vSphere API 5.0, vSphere Servers might not
/// generate property collector update notifications for this property.
/// To obtain the latest value of the property, you can use
/// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
/// If you use the PropertyCollector.WaitForUpdatesEx method, specify
/// an empty string for the version parameter. Any other version value will not
/// produce any property values as no updates are generated.
///
/// ## Returns:
///
/// Refers instances of *Task*.
pub async fn recent_task(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "recentTask").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// The set of child resource pools.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// Refers instances of *ResourcePool*.
pub async fn resource_pool(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "resourcePool").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Runtime information about a resource pool.
///
/// The *ResourcePoolResourceUsage* information within
/// *ResourcePoolRuntimeInfo* can be transiently stale.
/// Use *ResourcePool.RefreshRuntime* method to
/// update the information.
/// In releases after vSphere API 5.0, vSphere Servers might not
/// generate property collector update notifications for this property.
/// To obtain the latest value of the property, you can use
/// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
/// If you use the PropertyCollector.WaitForUpdatesEx method, specify
/// an empty string for the version parameter. Any other version value will not
/// produce any property values as no updates are generated.
pub async fn runtime(&self) -> Result<crate::types::structs::ResourcePoolRuntimeInfo> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "runtime").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property runtime was empty".to_string()))?;
let result: crate::types::structs::ResourcePoolRuntimeInfo = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// Basic information about a resource pool.
///
/// In releases after vSphere API 5.0, vSphere Servers might not
/// generate property collector update notifications for this property.
/// To obtain the latest value of the property, you can use
/// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
/// If you use the PropertyCollector.WaitForUpdatesEx method, specify
/// an empty string for the version parameter. Any other version value will not
/// produce any property values as no updates are generated.
pub async fn summary(&self) -> Result<Box<dyn crate::types::traits::ResourcePoolSummaryTrait>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "summary").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property summary was empty".to_string()))?;
let result: Box<dyn crate::types::traits::ResourcePoolSummaryTrait> = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// The set of tags associated with this managed entity.
///
/// Experimental. Subject to change.
///
/// ***Required privileges:*** System.View
pub async fn tag(&self) -> Result<Option<Vec<crate::types::structs::Tag>>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "tag").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// A set of alarm states for alarms triggered by this entity
/// or by its descendants.
///
/// Triggered alarms are propagated up the inventory hierarchy
/// so that a user can readily tell when a descendant has triggered an alarm.
/// In releases after vSphere API 5.0, vSphere Servers might not
/// generate property collector update notifications for this property.
/// To obtain the latest value of the property, you can use
/// PropertyCollector methods RetrievePropertiesEx or WaitForUpdatesEx.
/// If you use the PropertyCollector.WaitForUpdatesEx method, specify
/// an empty string for the version parameter. Any other version value will not
/// produce any property values as no updates are generated.
///
/// ***Required privileges:*** System.View
pub async fn triggered_alarm_state(&self) -> Result<Option<Vec<crate::types::structs::AlarmState>>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "triggeredAlarmState").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// List of custom field values.
///
/// Each value uses a key to associate
/// an instance of a *CustomFieldStringValue* with
/// a custom field definition.
///
/// ***Required privileges:*** System.View
pub async fn value(&self) -> Result<Option<Vec<Box<dyn crate::types::traits::CustomFieldValueTrait>>>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "value").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// The set of virtual machines associated with this resource pool.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// Refers instances of *VirtualMachine*.
pub async fn vm(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
let pv_opt = self.client.fetch_property_raw("", "ResourcePool", &self.mo_id, "vm").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
}
struct CreateResourcePoolRequestType<'a> {
name: &'a str,
spec: &'a crate::types::structs::ResourceConfigSpec,
}
impl<'a> miniserde::Serialize for CreateResourcePoolRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CreateResourcePoolRequestTypeSer { data: self, seq: 0 }))
}
}
struct CreateResourcePoolRequestTypeSer<'b, 'a> {
data: &'b CreateResourcePoolRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CreateResourcePoolRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CreateResourcePoolRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("name"), &self.data.name as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("spec"), &self.data.spec as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct CreateVAppRequestType<'a> {
name: &'a str,
res_spec: &'a crate::types::structs::ResourceConfigSpec,
config_spec: &'a crate::types::structs::VAppConfigSpec,
vm_folder: Option<&'a crate::types::structs::ManagedObjectReference>,
}
impl<'a> miniserde::Serialize for CreateVAppRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CreateVAppRequestTypeSer { data: self, seq: 0 }))
}
}
struct CreateVAppRequestTypeSer<'b, 'a> {
data: &'b CreateVAppRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CreateVAppRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
loop {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CreateVAppRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("name"), &self.data.name as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("resSpec"), &self.data.res_spec as &dyn miniserde::Serialize)),
3 => return Some((std::borrow::Cow::Borrowed("configSpec"), &self.data.config_spec as &dyn miniserde::Serialize)),
4 => {
let Some(ref val) = self.data.vm_folder else { continue; };
return Some((std::borrow::Cow::Borrowed("vmFolder"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct CreateChildVmRequestType<'a> {
config: &'a crate::types::structs::VirtualMachineConfigSpec,
host: Option<&'a crate::types::structs::ManagedObjectReference>,
}
impl<'a> miniserde::Serialize for CreateChildVmRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CreateChildVmRequestTypeSer { data: self, seq: 0 }))
}
}
struct CreateChildVmRequestTypeSer<'b, 'a> {
data: &'b CreateChildVmRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CreateChildVmRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
loop {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"CreateChildVMRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("config"), &self.data.config as &dyn miniserde::Serialize)),
2 => {
let Some(ref val) = self.data.host else { continue; };
return Some((std::borrow::Cow::Borrowed("host"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct ImportVAppRequestType<'a> {
spec: &'a dyn crate::types::traits::ImportSpecTrait,
folder: Option<&'a crate::types::structs::ManagedObjectReference>,
host: Option<&'a crate::types::structs::ManagedObjectReference>,
}
impl<'a> miniserde::Serialize for ImportVAppRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(ImportVAppRequestTypeSer { data: self, seq: 0 }))
}
}
struct ImportVAppRequestTypeSer<'b, 'a> {
data: &'b ImportVAppRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for ImportVAppRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
loop {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"ImportVAppRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("spec"), &self.data.spec as &dyn miniserde::Serialize)),
2 => {
let Some(ref val) = self.data.folder else { continue; };
return Some((std::borrow::Cow::Borrowed("folder"), val as &dyn miniserde::Serialize));
}
3 => {
let Some(ref val) = self.data.host else { continue; };
return Some((std::borrow::Cow::Borrowed("host"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct MoveIntoResourcePoolRequestType<'a> {
list: &'a [crate::types::structs::ManagedObjectReference],
}
impl<'a> miniserde::Serialize for MoveIntoResourcePoolRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(MoveIntoResourcePoolRequestTypeSer { data: self, seq: 0 }))
}
}
struct MoveIntoResourcePoolRequestTypeSer<'b, 'a> {
data: &'b MoveIntoResourcePoolRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for MoveIntoResourcePoolRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"MoveIntoResourcePoolRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("list"), &self.data.list as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct RegisterChildVmRequestType<'a> {
path: &'a str,
name: Option<&'a str>,
host: Option<&'a crate::types::structs::ManagedObjectReference>,
}
impl<'a> miniserde::Serialize for RegisterChildVmRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(RegisterChildVmRequestTypeSer { data: self, seq: 0 }))
}
}
struct RegisterChildVmRequestTypeSer<'b, 'a> {
data: &'b RegisterChildVmRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for RegisterChildVmRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
loop {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"RegisterChildVMRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("path"), &self.data.path as &dyn miniserde::Serialize)),
2 => {
let Some(ref val) = self.data.name else { continue; };
return Some((std::borrow::Cow::Borrowed("name"), val as &dyn miniserde::Serialize));
}
3 => {
let Some(ref val) = self.data.host else { continue; };
return Some((std::borrow::Cow::Borrowed("host"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct RenameRequestType<'a> {
new_name: &'a str,
}
impl<'a> miniserde::Serialize for RenameRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(RenameRequestTypeSer { data: self, seq: 0 }))
}
}
struct RenameRequestTypeSer<'b, 'a> {
data: &'b RenameRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for RenameRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"RenameRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("newName"), &self.data.new_name as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct SetCustomValueRequestType<'a> {
key: &'a str,
value: &'a str,
}
impl<'a> miniserde::Serialize for SetCustomValueRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(SetCustomValueRequestTypeSer { data: self, seq: 0 }))
}
}
struct SetCustomValueRequestTypeSer<'b, 'a> {
data: &'b SetCustomValueRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for SetCustomValueRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"setCustomValueRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("key"), &self.data.key as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("value"), &self.data.value as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct UpdateChildResourceConfigurationRequestType<'a> {
spec: &'a [crate::types::structs::ResourceConfigSpec],
}
impl<'a> miniserde::Serialize for UpdateChildResourceConfigurationRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(UpdateChildResourceConfigurationRequestTypeSer { data: self, seq: 0 }))
}
}
struct UpdateChildResourceConfigurationRequestTypeSer<'b, 'a> {
data: &'b UpdateChildResourceConfigurationRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for UpdateChildResourceConfigurationRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"UpdateChildResourceConfigurationRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("spec"), &self.data.spec as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct UpdateConfigRequestType<'a> {
name: Option<&'a str>,
config: Option<&'a crate::types::structs::ResourceConfigSpec>,
}
impl<'a> miniserde::Serialize for UpdateConfigRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(UpdateConfigRequestTypeSer { data: self, seq: 0 }))
}
}
struct UpdateConfigRequestTypeSer<'b, 'a> {
data: &'b UpdateConfigRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for UpdateConfigRequestTypeSer<'b, 'a> {
fn next(&mut self) -> Option<(std::borrow::Cow<'_, str>, &dyn miniserde::Serialize)> {
loop {
let seq = self.seq;
self.seq += 1;
match seq {
0 => return Some((std::borrow::Cow::Borrowed("_typeName"), &"UpdateConfigRequestType")),
1 => {
let Some(ref val) = self.data.name else { continue; };
return Some((std::borrow::Cow::Borrowed("name"), val as &dyn miniserde::Serialize));
}
2 => {
let Some(ref val) = self.data.config else { continue; };
return Some((std::borrow::Cow::Borrowed("config"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}