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
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// The *Datacenter* managed object provides the interface to the common container
/// object for hosts, virtual machines, networks, and datastores.
///
/// These entities
/// must be under a distinct datacenter in the inventory, and datacenters may not
/// be nested under other datacenters.
///
/// Every *Datacenter* has the following set of dedicated folders. These folders are empty
/// until you create entities for the Datacenter.
/// - A folder for *VirtualMachine*, template, and
/// *VirtualApp* objects.
/// - A folder for a *ComputeResource* hierarchy.
/// - A folder for *Network*, *DistributedVirtualSwitch*,
/// and *DistributedVirtualPortgroup* objects.
/// - A folder for *Datastore* objects.
///
/// For a visual representation of the organization of objects in a vCenter
/// hierarchy, see the description of the *ServiceInstance* object.
#[derive(Clone)]
pub struct Datacenter {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl Datacenter {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
/// This interface returns a list of information about the specified hosts
/// without adding them to the vCenter inventory.
///
/// It does so by calling
/// *Datacenter.QueryConnectionInfoViaSpec*.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### host_specs
/// Information about the set of hosts to query.
pub async fn batch_query_connect_info(&self, host_specs: Option<&[crate::types::structs::HostConnectSpec]>) -> Result<Option<Vec<crate::types::structs::DatacenterBasicConnectInfo>>> {
let input = BatchQueryConnectInfoRequestType {host_specs, };
let bytes_opt = self.client.invoke_optional("", "Datacenter", &self.mo_id, "BatchQueryConnectInfo", Some(&input)).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
None => Ok(None),
}
}
/// 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:*** Datacenter.Delete
///
/// ## 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("", "Datacenter", &self.mo_id, "Destroy_Task", None).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Powers on multiple virtual machines in a data center.
///
/// If the virtual
/// machines are suspended, this method resumes execution from the suspend
/// point.
/// The virtual machines can belong to different clusters in the data center.
///
/// If any virtual machine in the list is manually managed by DRS, or DRS
/// has to migrate any manually managed virtual machine or power on any manually
/// managed host in order to power on these virtual machines, a DRS recommendation
/// will be generated, and the users need to manually apply the recommendation
/// for actually powering on these virtual machines.
/// Otherwise, all the virtual machine will be automatically powered on. The
/// virtual machines on stand alone hosts or DRS disabled will be powered-on
/// on the current host. The DRS automatically managed virtual machines will
/// be powered-on on the recommended hosts.
///
/// When powering on a virtual machine in a cluster, the system
/// might do an implicit relocation of the virtual machine to
/// another host.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### vm
/// The virtual machines to power on.
///
/// ***Required privileges:*** VirtualMachine.Interact.PowerOn
///
/// Refers instances of *VirtualMachine*.
///
/// ### option
/// An array of *OptionValue* options
/// for this power-on session. The names and values of the
/// options are defined in
/// *ClusterPowerOnVmOption_enum*.
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor
/// the operation, and also a *ClusterPowerOnVmResult* object.
///
/// Refers instance of *Task*.
pub async fn power_on_multi_vm_task(&self, vm: &[crate::types::structs::ManagedObjectReference], option: Option<&[Box<dyn crate::types::traits::OptionValueTrait>]>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = PowerOnMultiVmRequestType {vm, option, };
let bytes = self.client.invoke("", "Datacenter", &self.mo_id, "PowerOnMultiVM_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// The list of possible choices for
/// *DatacenterConfigSpec.defaultHardwareVersionKey*.
///
/// Descriptors returned by the vCenter implementation do not have
/// *VirtualMachineConfigOptionDescriptor.host* field populated.
///
/// ***Required privileges:*** System.View
pub async fn query_datacenter_config_option_descriptor(&self) -> Result<Option<Vec<crate::types::structs::VirtualMachineConfigOptionDescriptor>>> {
let bytes_opt = self.client.invoke_optional("", "Datacenter", &self.mo_id, "queryDatacenterConfigOptionDescriptor", None).await?;
match bytes_opt {
Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
None => Ok(None),
}
}
/// This method provides a way of getting basic information about a host without
/// adding it to a datacenter.
///
/// Connection wizards typically use this method to show
/// information about a host so a user can confirm a set of changes before applying
/// them.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### hostname
/// The target of the query.
///
/// ### port
/// The port number of the target host. For ESX 2.x this is the authd port
/// (902 by default). For ESX 3.x and above and for VMware Server hosts
/// this is the https port (443 by default). You can specify -1 to have the
/// vCenter Server try the default ports.
///
/// ### username
/// The name of the user.
///
/// ### password
/// The password of the user.
///
/// ### ssl_thumbprint
/// The expected SSL thumbprint of the host's certificate.
///
/// ### ssl_certificate
/// The expected SSL certificate of the host in PEM format.
/// This parameter is a fallback to be used when the certificate provided
/// by the host can not be verified via a trusted CA. A replacement of
/// `sslThumbprint`.
/// Note: `sslThumbprint` and `sslCertificate` parameters are
/// mutually exclusive, and should never be used simultaneously.
///
/// ***Since:*** vSphere API Release 9.0.0.0
///
/// ## Errors:
///
/// ***NotSupported***: if called directly on a host.
///
/// ***NoHost***: if unable to contact the host.
///
/// ***InvalidLogin***: if unable to authenticate with the host.
///
/// ***NotSupportedHost***: if the software version on the host is not supported.
///
/// ***AlreadyConnected***: if the host is already being managed by this server.
///
/// ***HostConnectFault***: if an error occurred when querying about a host.
/// Typically, a more specific subclass, such as AlreadyBeingManaged,
/// is thrown.
///
/// ***SSLDisabledFault***: if the host has SSL access disabled
///
/// ***SSLVerifyFault***: if the host certificate could not be authenticated
///
/// ***InvalidArgument***: if both arguments `sslThumbprint`
/// and `sslCertificate` are set, or if only the `sslThumbprint`
/// argument is set, but the SHA-1 hashing algorithm is currently disabled
/// for computing certificate thumbprints.
pub async fn query_connection_info(&self, hostname: &str, port: i32, username: &str, password: &str, ssl_thumbprint: Option<&str>, ssl_certificate: Option<&str>) -> Result<crate::types::structs::HostConnectInfo> {
let input = QueryConnectionInfoRequestType {hostname, port, username, password, ssl_thumbprint, ssl_certificate, };
let bytes = self.client.invoke("", "Datacenter", &self.mo_id, "QueryConnectionInfo", Some(&input)).await?;
let result: crate::types::structs::HostConnectInfo = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// This method provides a way of getting basic information about a host
/// without adding it to a datacenter.
///
/// This method is similar to
/// *Datacenter.QueryConnectionInfo*, but it takes a *HostConnectSpec*
/// as argument, instead of list of parameters.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### spec
/// The connection spec for the host to be queried. It must contain
/// values for all parameters required by *Datacenter.QueryConnectionInfo*
/// See *Datacenter.QueryConnectionInfo* or a list of thrown expections.
///
/// ## Errors:
///
/// ***InvalidArgument***: if the spec argument does not provide values for
/// all needed connection parameters.
pub async fn query_connection_info_via_spec(&self, spec: &crate::types::structs::HostConnectSpec) -> Result<crate::types::structs::HostConnectInfo> {
let input = QueryConnectionInfoViaSpecRequestType {spec, };
let bytes = self.client.invoke("", "Datacenter", &self.mo_id, "QueryConnectionInfoViaSpec", Some(&input)).await?;
let result: crate::types::structs::HostConnectInfo = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Change the datacenter configuration.
///
/// ***Required privileges:*** Datacenter.Reconfigure
///
/// ## Parameters:
///
/// ### spec
/// A set of configuration changes to apply to the datacenter.
/// The specification can be a complete set of changes or a partial
/// set of changes, applied incrementally.
///
/// ### modify
/// Flag to specify whether the specification ("spec") should
/// be applied incrementally. If "modify" is false and the
/// operation succeeds, then the configuration of the datacenter
/// matches the specification exactly; in this case any unset
/// portions of the specification will result in unset or
/// default portions of the configuration.
///
/// ## Returns:
///
/// This method returns a *Task* object with which to monitor
/// the operation.
///
/// Refers instance of *Task*.
pub async fn reconfigure_datacenter_task(&self, spec: &crate::types::structs::DatacenterConfigSpec, modify: bool) -> Result<crate::types::structs::ManagedObjectReference> {
let input = ReconfigureDatacenterRequestType {spec, modify, };
let bytes = self.client.invoke("", "Datacenter", &self.mo_id, "ReconfigureDatacenter_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("", "Datacenter", &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:*** Datacenter.Rename
///
/// ## 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("", "Datacenter", &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("", "Datacenter", &self.mo_id, "setCustomValue", 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("", "Datacenter", &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("", "Datacenter", &self.mo_id, "availableField").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// 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("", "Datacenter", &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("", "Datacenter", &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)
}
/// Configuration of the datacenter.
///
/// ***Required privileges:*** System.View
pub async fn configuration(&self) -> Result<crate::types::structs::DatacenterConfigInfo> {
let pv_opt = self.client.fetch_property_raw("", "Datacenter", &self.mo_id, "configuration").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property configuration was empty".to_string()))?;
let result: crate::types::structs::DatacenterConfigInfo = 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("", "Datacenter", &self.mo_id, "customValue").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// A collection of references to the datastore objects
/// available in this datacenter.
///
/// ## Returns:
///
/// Refers instances of *Datastore*.
pub async fn datastore(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
let pv_opt = self.client.fetch_property_raw("", "Datacenter", &self.mo_id, "datastore").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// A reference to the folder hierarchy that contains
/// the datastores for this datacenter.
///
/// This folder is guaranteed to exist.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// Refers instance of *Folder*.
pub async fn datastore_folder(&self) -> Result<crate::types::structs::ManagedObjectReference> {
let pv_opt = self.client.fetch_property_raw("", "Datacenter", &self.mo_id, "datastoreFolder").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property datastoreFolder was empty".to_string()))?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// 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("", "Datacenter", &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("", "Datacenter", &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("", "Datacenter", &self.mo_id, "effectiveRole").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// A reference to the folder hierarchy that contains
/// the compute resources, including hosts and clusters, for this datacenter.
///
/// This folder is guaranteed to exist.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// Refers instance of *Folder*.
pub async fn host_folder(&self) -> Result<crate::types::structs::ManagedObjectReference> {
let pv_opt = self.client.fetch_property_raw("", "Datacenter", &self.mo_id, "hostFolder").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property hostFolder was empty".to_string()))?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// 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("", "Datacenter", &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)
}
/// A collection of references to the network objects
/// available in this datacenter.
///
/// ## Returns:
///
/// Refers instances of *Network*.
pub async fn network(&self) -> Result<Option<Vec<crate::types::structs::ManagedObjectReference>>> {
let pv_opt = self.client.fetch_property_raw("", "Datacenter", &self.mo_id, "network").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// A reference to the folder hierarchy that contains the network entities
/// for this datacenter.
///
/// The folder can include *Network*,
/// *DistributedVirtualSwitch*, and
/// *DistributedVirtualPortgroup* objects.
///
/// This folder is guaranteed to exist.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// Refers instance of *Folder*.
pub async fn network_folder(&self) -> Result<crate::types::structs::ManagedObjectReference> {
let pv_opt = self.client.fetch_property_raw("", "Datacenter", &self.mo_id, "networkFolder").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property networkFolder was empty".to_string()))?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::extract_property(pv)?;
Ok(result)
}
/// 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("", "Datacenter", &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)
}
/// 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("", "Datacenter", &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("", "Datacenter", &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("", "Datacenter", &self.mo_id, "recentTask").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// 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("", "Datacenter", &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("", "Datacenter", &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("", "Datacenter", &self.mo_id, "value").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// A reference to the folder hierarchy that contains *VirtualMachine*
/// virtual machine templates (identified by the *VirtualMachineConfigInfo.template*
/// property, and *VirtualApp* objects for this datacenter.
///
/// Note that a VirtualApp that is a child of a *ResourcePool*
/// may also be visible in this folder. VirtualApp objects can be nested,
/// but only the parent VirtualApp can be visible in the folder.
///
/// This folder is guaranteed to exist.
///
/// ***Required privileges:*** System.View
///
/// ## Returns:
///
/// Refers instance of *Folder*.
pub async fn vm_folder(&self) -> Result<crate::types::structs::ManagedObjectReference> {
let pv_opt = self.client.fetch_property_raw("", "Datacenter", &self.mo_id, "vmFolder").await?;
let pv = pv_opt.ok_or_else(|| crate::core::client::VimError::ParseError("property vmFolder was empty".to_string()))?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::extract_property(pv)?;
Ok(result)
}
}
struct BatchQueryConnectInfoRequestType<'a> {
host_specs: Option<&'a [crate::types::structs::HostConnectSpec]>,
}
impl<'a> miniserde::Serialize for BatchQueryConnectInfoRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(BatchQueryConnectInfoRequestTypeSer { data: self, seq: 0 }))
}
}
struct BatchQueryConnectInfoRequestTypeSer<'b, 'a> {
data: &'b BatchQueryConnectInfoRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for BatchQueryConnectInfoRequestTypeSer<'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"), &"BatchQueryConnectInfoRequestType")),
1 => {
let Some(ref val) = self.data.host_specs else { continue; };
return Some((std::borrow::Cow::Borrowed("hostSpecs"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct PowerOnMultiVmRequestType<'a> {
vm: &'a [crate::types::structs::ManagedObjectReference],
option: Option<&'a [Box<dyn crate::types::traits::OptionValueTrait>]>,
}
impl<'a> miniserde::Serialize for PowerOnMultiVmRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(PowerOnMultiVmRequestTypeSer { data: self, seq: 0 }))
}
}
struct PowerOnMultiVmRequestTypeSer<'b, 'a> {
data: &'b PowerOnMultiVmRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for PowerOnMultiVmRequestTypeSer<'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"), &"PowerOnMultiVMRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("vm"), &self.data.vm as &dyn miniserde::Serialize)),
2 => {
let Some(ref val) = self.data.option else { continue; };
return Some((std::borrow::Cow::Borrowed("option"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct QueryConnectionInfoRequestType<'a> {
hostname: &'a str,
port: i32,
username: &'a str,
password: &'a str,
ssl_thumbprint: Option<&'a str>,
ssl_certificate: Option<&'a str>,
}
impl<'a> miniserde::Serialize for QueryConnectionInfoRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(QueryConnectionInfoRequestTypeSer { data: self, seq: 0 }))
}
}
struct QueryConnectionInfoRequestTypeSer<'b, 'a> {
data: &'b QueryConnectionInfoRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for QueryConnectionInfoRequestTypeSer<'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"), &"QueryConnectionInfoRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("hostname"), &self.data.hostname as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("port"), &self.data.port as &dyn miniserde::Serialize)),
3 => return Some((std::borrow::Cow::Borrowed("username"), &self.data.username as &dyn miniserde::Serialize)),
4 => return Some((std::borrow::Cow::Borrowed("password"), &self.data.password as &dyn miniserde::Serialize)),
5 => {
let Some(ref val) = self.data.ssl_thumbprint else { continue; };
return Some((std::borrow::Cow::Borrowed("sslThumbprint"), val as &dyn miniserde::Serialize));
}
6 => {
let Some(ref val) = self.data.ssl_certificate else { continue; };
return Some((std::borrow::Cow::Borrowed("sslCertificate"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct QueryConnectionInfoViaSpecRequestType<'a> {
spec: &'a crate::types::structs::HostConnectSpec,
}
impl<'a> miniserde::Serialize for QueryConnectionInfoViaSpecRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(QueryConnectionInfoViaSpecRequestTypeSer { data: self, seq: 0 }))
}
}
struct QueryConnectionInfoViaSpecRequestTypeSer<'b, 'a> {
data: &'b QueryConnectionInfoViaSpecRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for QueryConnectionInfoViaSpecRequestTypeSer<'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"), &"QueryConnectionInfoViaSpecRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("spec"), &self.data.spec as &dyn miniserde::Serialize)),
_ => return None,
}
}
}
struct ReconfigureDatacenterRequestType<'a> {
spec: &'a crate::types::structs::DatacenterConfigSpec,
modify: bool,
}
impl<'a> miniserde::Serialize for ReconfigureDatacenterRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(ReconfigureDatacenterRequestTypeSer { data: self, seq: 0 }))
}
}
struct ReconfigureDatacenterRequestTypeSer<'b, 'a> {
data: &'b ReconfigureDatacenterRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for ReconfigureDatacenterRequestTypeSer<'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"), &"ReconfigureDatacenterRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("spec"), &self.data.spec as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("modify"), &self.data.modify 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,
}
}
}