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
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// A singleton managed object that can answer questions about
/// the feasibility of certain provisioning operations.
#[derive(Clone)]
pub struct VirtualMachineProvisioningChecker {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl VirtualMachineProvisioningChecker {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
/// Tests the feasibility of a proposed
/// *VirtualMachine.CloneVM_Task* operation.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### vm
/// The virtual machine we propose to clone.
///
/// Refers instance of *VirtualMachine*.
///
/// ### folder
/// The location of the new virtual machine.
///
/// Refers instance of *Folder*.
///
/// ### name
/// The name of the new virtual machine.
///
/// ### spec
/// Specifies how to clone the virtual machine. In cases
/// where DRS would automatically select a host, all potential
/// hosts are tested against.
///
/// ### test_type
/// The set of tests to run. If this argument is not set, all
/// tests will be run. See *CheckTestType_enum* for possible values.
///
/// ## Returns:
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidArgument***: in the following cases:
/// - the target host and target pool are not associated with the
/// same compute resource
/// - the target pool represents a cluster without DRS enabled,
/// and the host is not specified
/// - Datastore in a diskLocator entry is not specified
/// - the specified device ID cannot be found in the virtual machine's current
/// configuration
/// - the object specified in relocate cannot be found
/// - the target pool is not specified while checking feasibility of
/// cloning to a different datacenter or a different vCenter
/// service
/// - the datastore is not specified when testType parameter includes
/// datastore tests while checking feasibility of cloning to a
/// different datacenter or a different vCenter service
///
/// ***InvalidState***: if the operation cannot be performed because of the
/// virtual machine's current state. For example, if the virtual machine
/// configuration information is not available.
pub async fn check_clone_task(&self, vm: &crate::types::structs::ManagedObjectReference, folder: &crate::types::structs::ManagedObjectReference, name: &str, spec: &crate::types::structs::VirtualMachineCloneSpec, test_type: Option<&[String]>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CheckCloneRequestType {vm, folder, name, spec, test_type, };
let bytes = self.client.invoke("", "VirtualMachineProvisioningChecker", &self.mo_id, "CheckClone_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Tests the feasibility of a proposed
/// *VirtualMachine.InstantClone_Task* operation.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### vm
/// The virtual machine we propose to instant clone.
///
/// Refers instance of *VirtualMachine*.
///
/// ### spec
/// Specifies how to instant clone the virtual machine.
///
/// ### test_type
/// The set of tests to run. If this argument is not set, all
/// tests will be run. See *CheckTestType_enum* for possible values.
///
/// ## Returns:
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidArgument***: in the following cases:
/// - The destination host does not support Instant Clone.
/// - The source and destination host are not the same.
/// - The relocate spec in the Instant Clone spec has
/// Datastore set.
/// - The relocate spec in the Instant Clone spec has host set.
/// - The Instant clone spec does not have name set.
/// - The source VM is a template.
/// - The source VM is not powered on.
/// - The source VM has PMEM devices/disks configured.
///
/// ***InvalidState***: if the operation cannot be performed because of the
/// virtual machine's current state. For example, if the virtual
/// machine configuration information is not available.
pub async fn check_instant_clone_task(&self, vm: &crate::types::structs::ManagedObjectReference, spec: &crate::types::structs::VirtualMachineInstantCloneSpec, test_type: Option<&[String]>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CheckInstantCloneRequestType {vm, spec, test_type, };
let bytes = self.client.invoke("", "VirtualMachineProvisioningChecker", &self.mo_id, "CheckInstantClone_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Tests the feasibility of a proposed
/// *VirtualMachine.MigrateVM_Task* operation.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### vm
/// The virtual machine we propose to migrate.
///
/// Refers instance of *VirtualMachine*.
///
/// ### host
/// The target host on which the virtual machines will run. The host
/// parameter may be left unset if the compute resource associated with
/// the target pool represents a stand-alone host or a DRS-enabled
/// cluster. In the former case the stand-alone host is used as the
/// target host. In the latter case, each connected host in the cluster
/// that is not in maintenance mode is tested as a target host.
/// If the virtual machine is a template then either this
/// parameter or the pool parameter must be set.
///
/// Refers instance of *HostSystem*.
///
/// ### pool
/// The target resource pool for the virtual machines. If the
/// pool parameter is left unset, the target pool for each particular
/// virtual machine's migration will be that virtual machine's current
/// pool. If the virtual machine is a template then either this
/// parameter or the host parameter must be set.
/// The pool parameter must be set for testing the feasibility of
/// migration to a different datacenter or different vCenter service.
///
/// Refers instance of *ResourcePool*.
///
/// ### state
/// The power state that the virtual machines must have. If
/// this argument is not set, each virtual machine is evaluated
/// according to its current power state.
///
/// ### test_type
/// The set of tests to run. If this argument is not set, all
/// tests will be run. See *CheckTestType_enum* for possible values.
///
/// ## Returns:
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***InvalidArgument***: if the target host(s) and target pool for a
/// migration are not associated with the same compute resource,
/// or if the host parameter is left unset when the target pool is
/// associated with a non-DRS cluster.
///
/// ***InvalidPowerState***: if the state argument is set and at least one
/// of the specified virtual machines is not in that power state.
pub async fn check_migrate_task(&self, vm: &crate::types::structs::ManagedObjectReference, host: Option<&crate::types::structs::ManagedObjectReference>, pool: Option<&crate::types::structs::ManagedObjectReference>, state: Option<crate::types::enums::VirtualMachinePowerStateEnum>, test_type: Option<&[String]>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CheckMigrateRequestType {vm, host, pool, state, test_type, };
let bytes = self.client.invoke("", "VirtualMachineProvisioningChecker", &self.mo_id, "CheckMigrate_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Tests the feasibility of a proposed
/// *VirtualMachine.RelocateVM_Task* operation.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### vm
/// The virtual machine we propose to relocate.
///
/// Refers instance of *VirtualMachine*.
///
/// ### spec
/// The specification of where to relocate the virtual machine.
/// In cases where DRS would automatically select a host, all potential
/// hosts are tested against.
/// The host parameter in the spec may be left unset for checking
/// feasibility of relocation to a different datacenter or different
/// vCenter service, if the compute resource associated with the
/// target pool represents a stand-alone host, the host is tested
/// against, otherwise each connected host in the cluster that is
/// not in maintenance mode represented by the target pool is tested
/// as a target host.
///
/// ### test_type
/// The set of tests to run. If this argument is not set, all
/// tests will be run. See *CheckTestType_enum* for possible values.
///
/// ## Returns:
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// ***NotSupported***: if the virtual machine is marked as a template.
///
/// ***InvalidArgument***: in the following cases:
/// - the target host and target pool are not associated with the
/// same compute resource
/// - the target pool represents a cluster without DRS enabled,
/// and the host is not specified
/// - Datastore in a diskLocator entry is not specified
/// - the specified device ID cannot be found in the virtual machine's current
/// configuration
/// - the object specified in relocate cannot be found
/// - the target pool is not specified while checking feasibility of
/// relocation to a different datacenter or different vCenter
/// service
/// - the datastore is not specified when testType parameter includes
/// datastore tests while checking feasibility of relocation to a
/// different datacenter or a different vCenter service
///
/// ***InvalidState***: if the operation cannot be performed because of the
/// host or virtual machine's current state. For example, if the host is in
/// maintenance mode, or if the virtual machine's configuration information
/// is not available.
pub async fn check_relocate_task(&self, vm: &crate::types::structs::ManagedObjectReference, spec: &crate::types::structs::VirtualMachineRelocateSpec, test_type: Option<&[String]>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CheckRelocateRequestType {vm, spec, test_type, };
let bytes = self.client.invoke("", "VirtualMachineProvisioningChecker", &self.mo_id, "CheckRelocate_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Investigates the general VMotion compatibility of a set of virtual machines
/// with a set of hosts.
///
/// The virtual machine may be in any power state. Hosts
/// may be in any connection state and also may be in maintenance mode.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### vm
/// The set of virtual machines to analyze for compatibility. All
/// virtual machines are assumed to be powered-on for the purposes of
/// this operation.
///
/// Refers instances of *VirtualMachine*.
///
/// ### host
/// The set of hosts to analyze for compatibility. All hosts
/// are assumed to be connected and not in maintenance mode for the
/// purposes of this operation.
///
/// Refers instances of *HostSystem*.
///
/// ## Returns:
///
/// Refers instance of *Task*.
pub async fn query_v_motion_compatibility_ex_task(&self, vm: &[crate::types::structs::ManagedObjectReference], host: &[crate::types::structs::ManagedObjectReference]) -> Result<crate::types::structs::ManagedObjectReference> {
let input = QueryVMotionCompatibilityExRequestType {vm, host, };
let bytes = self.client.invoke("", "VirtualMachineProvisioningChecker", &self.mo_id, "QueryVMotionCompatibilityEx_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
}
struct CheckCloneRequestType<'a> {
vm: &'a crate::types::structs::ManagedObjectReference,
folder: &'a crate::types::structs::ManagedObjectReference,
name: &'a str,
spec: &'a crate::types::structs::VirtualMachineCloneSpec,
test_type: Option<&'a [String]>,
}
impl<'a> miniserde::Serialize for CheckCloneRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CheckCloneRequestTypeSer { data: self, seq: 0 }))
}
}
struct CheckCloneRequestTypeSer<'b, 'a> {
data: &'b CheckCloneRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CheckCloneRequestTypeSer<'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"), &"CheckCloneRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("vm"), &self.data.vm as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("folder"), &self.data.folder as &dyn miniserde::Serialize)),
3 => return Some((std::borrow::Cow::Borrowed("name"), &self.data.name as &dyn miniserde::Serialize)),
4 => return Some((std::borrow::Cow::Borrowed("spec"), &self.data.spec as &dyn miniserde::Serialize)),
5 => {
let Some(ref val) = self.data.test_type else { continue; };
return Some((std::borrow::Cow::Borrowed("testType"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct CheckInstantCloneRequestType<'a> {
vm: &'a crate::types::structs::ManagedObjectReference,
spec: &'a crate::types::structs::VirtualMachineInstantCloneSpec,
test_type: Option<&'a [String]>,
}
impl<'a> miniserde::Serialize for CheckInstantCloneRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CheckInstantCloneRequestTypeSer { data: self, seq: 0 }))
}
}
struct CheckInstantCloneRequestTypeSer<'b, 'a> {
data: &'b CheckInstantCloneRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CheckInstantCloneRequestTypeSer<'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"), &"CheckInstantCloneRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("vm"), &self.data.vm as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("spec"), &self.data.spec as &dyn miniserde::Serialize)),
3 => {
let Some(ref val) = self.data.test_type else { continue; };
return Some((std::borrow::Cow::Borrowed("testType"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct CheckMigrateRequestType<'a> {
vm: &'a crate::types::structs::ManagedObjectReference,
host: Option<&'a crate::types::structs::ManagedObjectReference>,
pool: Option<&'a crate::types::structs::ManagedObjectReference>,
state: Option<crate::types::enums::VirtualMachinePowerStateEnum>,
test_type: Option<&'a [String]>,
}
impl<'a> miniserde::Serialize for CheckMigrateRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CheckMigrateRequestTypeSer { data: self, seq: 0 }))
}
}
struct CheckMigrateRequestTypeSer<'b, 'a> {
data: &'b CheckMigrateRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CheckMigrateRequestTypeSer<'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"), &"CheckMigrateRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("vm"), &self.data.vm 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));
}
3 => {
let Some(ref val) = self.data.pool else { continue; };
return Some((std::borrow::Cow::Borrowed("pool"), val as &dyn miniserde::Serialize));
}
4 => {
let Some(ref val) = self.data.state else { continue; };
return Some((std::borrow::Cow::Borrowed("state"), val as &dyn miniserde::Serialize));
}
5 => {
let Some(ref val) = self.data.test_type else { continue; };
return Some((std::borrow::Cow::Borrowed("testType"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct CheckRelocateRequestType<'a> {
vm: &'a crate::types::structs::ManagedObjectReference,
spec: &'a crate::types::structs::VirtualMachineRelocateSpec,
test_type: Option<&'a [String]>,
}
impl<'a> miniserde::Serialize for CheckRelocateRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CheckRelocateRequestTypeSer { data: self, seq: 0 }))
}
}
struct CheckRelocateRequestTypeSer<'b, 'a> {
data: &'b CheckRelocateRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CheckRelocateRequestTypeSer<'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"), &"CheckRelocateRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("vm"), &self.data.vm as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("spec"), &self.data.spec as &dyn miniserde::Serialize)),
3 => {
let Some(ref val) = self.data.test_type else { continue; };
return Some((std::borrow::Cow::Borrowed("testType"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct QueryVMotionCompatibilityExRequestType<'a> {
vm: &'a [crate::types::structs::ManagedObjectReference],
host: &'a [crate::types::structs::ManagedObjectReference],
}
impl<'a> miniserde::Serialize for QueryVMotionCompatibilityExRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(QueryVMotionCompatibilityExRequestTypeSer { data: self, seq: 0 }))
}
}
struct QueryVMotionCompatibilityExRequestTypeSer<'b, 'a> {
data: &'b QueryVMotionCompatibilityExRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for QueryVMotionCompatibilityExRequestTypeSer<'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"), &"QueryVMotionCompatibilityExRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("vm"), &self.data.vm as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("host"), &self.data.host as &dyn miniserde::Serialize)),
_ => return None,
}
}
}