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
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// A singleton managed object that can answer questions about compatibility
/// of a virtual machine with a host.
#[derive(Clone)]
pub struct VirtualMachineCompatibilityChecker {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl VirtualMachineCompatibilityChecker {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
/// Tests whether or not a virtual machine could be placed on
/// the given host in the given resource pool.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### vm
/// The virtual machine we'd like to place.
///
/// Refers instance of *VirtualMachine*.
///
/// ### host
/// The host we would like the virtual machine
/// to execute on. The host parameter may be left unset if the compute
/// resource associated with the pool represents a stand-alone host
/// or a DRS-enabled cluster. In the former case the stand-alone host is
/// used. In the latter case, each connected host in the cluster
/// that is not in maintenance mode is tested. If the virtual machine is a
/// template then either this parameter or the pool parameter must be set.
///
/// Refers instance of *HostSystem*.
///
/// ### pool
/// The resource pool we would like the virtual machine
/// to reside in. If the pool parameter is left unset, then the virtual
/// machine's current pool is assumed. If the virtual machine is a template
/// then either this parameter or the host parameter must be set.
///
/// Refers instance of *ResourcePool*.
///
/// ### 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:
///
/// ***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.
///
/// ***InvalidArgument***: if the desired host and pool are not associated
/// with the same compute resource, the host parameter is left unset
/// when the specified pool is associated with a non-DRS cluster, or
/// if the specified vm does not exist.
///
/// ***DatacenterMismatch***: if the provided host and pool do not belong
/// to the same datacenter.
pub async fn check_compatibility_task(&self, vm: &crate::types::structs::ManagedObjectReference, host: Option<&crate::types::structs::ManagedObjectReference>, pool: Option<&crate::types::structs::ManagedObjectReference>, test_type: Option<&[String]>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CheckCompatibilityRequestType {vm, host, pool, test_type, };
let bytes = self.client.invoke("", "VirtualMachineCompatibilityChecker", &self.mo_id, "CheckCompatibility_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Tests whether the provided virtual machine can be powered on
/// on the given host and/or resource pool.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### vm
/// The virtual machine to power on.
///
/// Refers instance of *VirtualMachine*.
///
/// ### host
/// The host on which we want to power on the virtual machine.
/// The host parameter may be left unset if the compute
/// resource associated with the pool represents a stand-alone host
/// or a DRS-enabled cluster. In the former case the stand-alone host
/// is used. In the latter case, each connected host in the cluster
/// that is not in maintenance mode is tested. Either this parameter
/// or the pool parameter must be set.
///
/// Refers instance of *HostSystem*.
///
/// ### pool
/// The resource pool we would like the virtual machine to run
/// in. If the pool parameter is left unset, we use the host's
/// root resource pool.
///
/// Refers instance of *ResourcePool*.
///
/// ### 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 desired host and pool are not associated
/// with the same compute resource, the host parameter is left unset
/// when the specified pool is associated with a non-DRS cluster, or
/// if the provided vm does not exist.
///
/// ***DatacenterMismatch***: if the provided host and pool do not belong
/// to the same datacenter.
pub async fn check_power_on_task(&self, vm: &crate::types::structs::ManagedObjectReference, host: Option<&crate::types::structs::ManagedObjectReference>, pool: Option<&crate::types::structs::ManagedObjectReference>, test_type: Option<&[String]>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CheckPowerOnRequestType {vm, host, pool, test_type, };
let bytes = self.client.invoke("", "VirtualMachineCompatibilityChecker", &self.mo_id, "CheckPowerOn_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Tests whether the provided virtual machine specification can be applied
/// on the given host and resource pool.
///
/// ***Required privileges:*** System.View
///
/// ## Parameters:
///
/// ### spec
/// The specification of the virtual machine to create.
///
/// ### vm
/// The existing virtual machine to apply the spec to.
/// If this is not provided, the spec is assumed to be for the creation
/// of a new virtual machine.
///
/// Refers instance of *VirtualMachine*.
///
/// ### host
/// The host we would like the virtual machine
/// to execute on. The host parameter may be left unset if the compute
/// resource associated with the pool represents a stand-alone host
/// or a DRS-enabled cluster. In the former case the stand-alone host
/// is used. In the latter case, each connected host in the cluster
/// that is not in maintenance mode is tested. If the virtual machine
/// is a template, then either this parameter or the pool parameter
/// must be set.
///
/// Refers instance of *HostSystem*.
///
/// ### pool
/// The resource pool we would like the virtual machine
/// to reside in. If the pool parameter is left unset, then we use the
/// host's root resource pool.
///
/// Refers instance of *ResourcePool*.
///
/// ### 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 desired host and pool are not associated
/// with the same compute resource, the host parameter is left unset
/// when the specified pool is associated with a non-DRS cluster, or
/// if the provided vm does not exist.
///
/// ***DatacenterMismatch***: if the provided host and pool do not belong
/// to the same datacenter.
pub async fn check_vm_config_task(&self, spec: &crate::types::structs::VirtualMachineConfigSpec, vm: Option<&crate::types::structs::ManagedObjectReference>, host: Option<&crate::types::structs::ManagedObjectReference>, pool: Option<&crate::types::structs::ManagedObjectReference>, test_type: Option<&[String]>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = CheckVmConfigRequestType {spec, vm, host, pool, test_type, };
let bytes = self.client.invoke("", "VirtualMachineCompatibilityChecker", &self.mo_id, "CheckVmConfig_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
}
struct CheckCompatibilityRequestType<'a> {
vm: &'a crate::types::structs::ManagedObjectReference,
host: Option<&'a crate::types::structs::ManagedObjectReference>,
pool: Option<&'a crate::types::structs::ManagedObjectReference>,
test_type: Option<&'a [String]>,
}
impl<'a> miniserde::Serialize for CheckCompatibilityRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CheckCompatibilityRequestTypeSer { data: self, seq: 0 }))
}
}
struct CheckCompatibilityRequestTypeSer<'b, 'a> {
data: &'b CheckCompatibilityRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CheckCompatibilityRequestTypeSer<'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"), &"CheckCompatibilityRequestType")),
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.test_type else { continue; };
return Some((std::borrow::Cow::Borrowed("testType"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct CheckPowerOnRequestType<'a> {
vm: &'a crate::types::structs::ManagedObjectReference,
host: Option<&'a crate::types::structs::ManagedObjectReference>,
pool: Option<&'a crate::types::structs::ManagedObjectReference>,
test_type: Option<&'a [String]>,
}
impl<'a> miniserde::Serialize for CheckPowerOnRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CheckPowerOnRequestTypeSer { data: self, seq: 0 }))
}
}
struct CheckPowerOnRequestTypeSer<'b, 'a> {
data: &'b CheckPowerOnRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CheckPowerOnRequestTypeSer<'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"), &"CheckPowerOnRequestType")),
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.test_type else { continue; };
return Some((std::borrow::Cow::Borrowed("testType"), val as &dyn miniserde::Serialize));
}
_ => return None,
}
}
}
}
struct CheckVmConfigRequestType<'a> {
spec: &'a crate::types::structs::VirtualMachineConfigSpec,
vm: Option<&'a crate::types::structs::ManagedObjectReference>,
host: Option<&'a crate::types::structs::ManagedObjectReference>,
pool: Option<&'a crate::types::structs::ManagedObjectReference>,
test_type: Option<&'a [String]>,
}
impl<'a> miniserde::Serialize for CheckVmConfigRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(CheckVmConfigRequestTypeSer { data: self, seq: 0 }))
}
}
struct CheckVmConfigRequestTypeSer<'b, 'a> {
data: &'b CheckVmConfigRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for CheckVmConfigRequestTypeSer<'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"), &"CheckVmConfigRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("spec"), &self.data.spec as &dyn miniserde::Serialize)),
2 => {
let Some(ref val) = self.data.vm else { continue; };
return Some((std::borrow::Cow::Borrowed("vm"), 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));
}
4 => {
let Some(ref val) = self.data.pool else { continue; };
return Some((std::borrow::Cow::Borrowed("pool"), 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,
}
}
}
}