vim_rs 0.4.4

Rust Bindings for the VMware by Broadcom vCenter VI JSON API
Documentation
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
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// It deprecates vim.VsanUpgradeSystem, to take care of vSAN
/// upgrade process.
/// 
/// It has capability to support additional advanced disk format
/// conversion specification, to help on configuration of
/// latest vSAN advanced features.
/// It supports following vSAN on-disk format versions:
/// - version 1, released by vSAN 1.0, vSphere ESXi 5.5U1;
/// - version 2, released by vSAN 6.0, which supports Virsto file
///   system;
/// - version 3, released by vSAN 6.2, which supports vSAN
///   deduplication and compression.
///   
/// It can be accessed with MOID vsan-upgrade-systemex through vSAN
/// service at vCenter server side.
#[derive(Clone)]
pub struct VsanUpgradeSystemEx {
    client: Arc<dyn VimClient>,
    mo_id: String,
}
impl VsanUpgradeSystemEx {
    pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
        Self {
            client,
            mo_id: mo_id.to_string(),
        }
    }
    /// Start vSAN disk format conversion on a particular cluster.
    /// 
    /// It deprecates API vim.VsanUpgradeSystem.PerformVsanUpgrade,
    /// besides supporting original basic upgrade options, it also supports
    /// advanced disk format conversion spec, to convert vSAN disk
    /// format to support corresponding vSAN advanced features, such
    /// as vSAN deduplication and compression, etc.
    /// 
    /// In order to perform this on-disk format upgrade, the upgrade process
    /// will perform a rolling evacuation/remove/re-add operation to accomplish
    /// the upgrade. In other words, one disk group at a time, it will evacuate
    /// the data from the disk group, then remove the old format from the now
    /// empty disk group, then reformat the disk group with the new format.
    /// Once all disk groups have been upgraded, and if the performObjectUpgrade
    /// parameter is set, the vSAN object version is also upgraded. Before
    /// the object version is upgraded, it is possible to downgrade the cluster
    /// by passing the downgradeFormat parameter. Once objects are of the new
    /// object version however, downgrade (and thus rollback) are no longer
    /// possible. The new object version is required to allow objects to benefit
    /// from new vSAN features.
    /// 
    /// The upgrade process performs additional "preflight checks" before
    /// proceeding to upgrade the next host. The upgrade process will be halted
    /// if any of those preflight checks fail.
    /// 
    /// If the upgrade process has been halted due to a problem, or even due to
    /// a crash or other failure, it can be re-started at any point in time.
    /// The upgrade will resume where it left off and only do the parts that
    /// are still outstanding. If the upgrade process stopped after removing
    /// vSAN from a disk group, but before re-adding those disks to
    /// vSAN, the upgrade process can recover from that. The preflight
    /// check results indicate such a condition.
    ///
    /// ## Parameters:
    ///
    /// ### cluster
    /// The cluster to be upgraded
    /// 
    /// ***Required privileges:*** Host.Config.Storage
    /// 
    /// Refers instance of *ClusterComputeResource*.
    ///
    /// ### perform_object_upgrade
    /// After all disk groups have been updated, also
    /// upgrade all objects. Once started, rollback
    /// of the on disk format is no longer possible.
    /// Object upgrade unlocks new vSAN features. The
    /// default behavior is upgrading objects is this
    /// parameter is not specified.
    ///
    /// ### downgrade_format
    /// Perform a on-disk format downgrade instead of
    /// upgrade. Only possible if no upgraded objects exist.
    ///
    /// ### allow_reduced_redundancy
    /// Removes the need for one disk group worth of
    /// free space, by allowing reduced redundancy
    /// during disk upgrade.
    ///
    /// ### exclude_hosts
    /// Internal debug option meant for functional testing
    /// of vSAN upgrades. Skips upgrade on certain hosts and
    /// implies performObjectUpgrade being false. Should not
    /// be used by customers.
    /// 
    /// Refers instances of *HostSystem*.
    ///
    /// ### spec
    /// The specification of advanced disk format configuration. The
    /// spec cannot be supported in downgrade process, for now we don't
    /// have any advanced features supported by lower disk format.
    ///
    /// ## Returns:
    ///
    /// vim.Task
    /// 
    /// Refers instance of *Task*.
    ///
    /// ## Errors:
    ///
    /// ***VsanFault***: If a current upgrade or precheck is already
    /// in progress
    pub async fn perform_vsan_upgrade_ex(&self, cluster: &crate::types::structs::ManagedObjectReference, perform_object_upgrade: Option<bool>, downgrade_format: Option<bool>, allow_reduced_redundancy: Option<bool>, exclude_hosts: Option<&[crate::types::structs::ManagedObjectReference]>, spec: Option<&crate::types::structs::VsanDiskFormatConversionSpec>) -> Result<crate::types::structs::ManagedObjectReference> {
        let input = PerformVsanUpgradeExRequestType {cluster, perform_object_upgrade, downgrade_format, allow_reduced_redundancy, exclude_hosts, spec, };
        let bytes = self.client.invoke("vsan", "VsanUpgradeSystemEx", &self.mo_id, "PerformVsanUpgradeEx", Some(&input)).await?;
        let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
        Ok(result)
    }
    /// Perform an upgrade preflight check on a cluster asynchronously.
    /// 
    /// Has the same arguments as *VsanUpgradeSystemEx.PerformVsanUpgradePreflightCheckEx* for argument
    /// details.
    /// The checks are performed asynchronously tracked by a task. Upon completion
    /// results can be obtained by calling *VsanUpgradeSystemEx.VsanQueryUpgradeStatusEx*
    ///
    /// ## Parameters:
    ///
    /// ### cluster
    /// The target cluster to process conversion.
    /// 
    /// ***Required privileges:*** Host.Config.Storage
    /// 
    /// Refers instance of *ClusterComputeResource*.
    ///
    /// ### downgrade_format
    /// Intend to perform a on-disk format downgrade
    /// instead of upgrade. Adds additional checks.
    ///
    /// ### spec
    /// The specification of advanced disk format configuration.
    /// Adds additional checks. The specification cannot be
    /// supported in downgrade process, for now we don't
    /// have any advanced features supported by lower disk format.
    ///
    /// ## Returns:
    ///
    /// Refers instance of *Task*.
    ///
    /// ## Errors:
    ///
    /// ***VsanFault***: If a current upgrade or precheck is already
    /// in progress
    pub async fn perform_vsan_upgrade_preflight_async_check_task(&self, cluster: &crate::types::structs::ManagedObjectReference, downgrade_format: Option<bool>, spec: Option<&crate::types::structs::VsanDiskFormatConversionSpec>) -> Result<crate::types::structs::ManagedObjectReference> {
        let input = PerformVsanUpgradePreflightAsyncCheckRequestType {cluster, downgrade_format, spec, };
        let bytes = self.client.invoke("vsan", "VsanUpgradeSystemEx", &self.mo_id, "PerformVsanUpgradePreflightAsyncCheck_Task", Some(&input)).await?;
        let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
        Ok(result)
    }
    /// Perform an upgrade preflight check on a cluster.
    /// 
    /// It deprecates API vim.VsanUpgradeSystem.PerformVsanUpgradePreflightCheck,
    /// and helps to check following issues which would break vSAN upgrade
    /// process:
    /// 1. Any vSAN host is disconnected from vCenter server
    /// 2. ESXi host before vSphere 6.0 exists in vSAN cluster, of
    ///    which on-disk format cannot be upgraded
    /// 3. Any vSAN host enables auto-mode to claim disk
    /// 4. Network issue exists in vSAN cluster, which leads to communication
    ///    problem among vSAN hosts
    /// 5. Not all vSAN member hosts reside in specified vCenter cluster
    /// 6. Any vSAN host contributes in the other vSAN cluster
    /// 7. There is inaccessible vSAN object in vSAN datastore
    /// 8. Any in-use vSAN disk that are unhealthy, such as physical
    ///    disk lost
    /// 9. Hybrid disk group exists in vSAN cluster, and requests to enable
    ///    Deduplication and Compression
    /// 10. To request enable Deduplication and Compression, but there is ESXi host
    ///     software version is below then ESXi 6.0 Update 2
    /// 11. vSAN downgrade is requested, but vSAN objects have already
    ///     been upgraded to 2.0 or above
    /// 12. Any vSAN object that would present an upgrade issue 
    ///     
    /// Any issue detected by preflight check, requires manual fix by end user,
    /// before trigger vSAN upgrade process through PerformVsanUpgradeEx.
    ///
    /// ## Parameters:
    ///
    /// ### cluster
    /// The target cluster to be converted.
    /// 
    /// ***Required privileges:*** Host.Config.Storage
    /// 
    /// Refers instance of *ClusterComputeResource*.
    ///
    /// ### downgrade_format
    /// Intend to perform a on-disk format downgrade
    /// instead of upgrade. Adds additional checks.
    ///
    /// ### spec
    /// The specification of advanced disk format configuration.
    /// Adds additional checks. The specification cannot be
    /// supported in downgrade process, for now we don't
    /// have any advanced features supported by lower disk format.
    ///
    /// ## Returns:
    ///
    /// Preflight check result.
    pub async fn perform_vsan_upgrade_preflight_check_ex(&self, cluster: &crate::types::structs::ManagedObjectReference, downgrade_format: Option<bool>, spec: Option<&crate::types::structs::VsanDiskFormatConversionSpec>) -> Result<crate::types::structs::VsanDiskFormatConversionCheckResult> {
        let input = PerformVsanUpgradePreflightCheckExRequestType {cluster, downgrade_format, spec, };
        let bytes = self.client.invoke("vsan", "VsanUpgradeSystemEx", &self.mo_id, "PerformVsanUpgradePreflightCheckEx", Some(&input)).await?;
        let result: crate::types::structs::VsanDiskFormatConversionCheckResult = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
        Ok(result)
    }
    /// Retrieve the latest status of a running, or the previously completed,
    /// upgrade or precheck process.
    /// 
    /// Information about previous upgrade runs are not
    /// always, e.g. when vCenter gets restarted.
    ///
    /// ## Parameters:
    ///
    /// ### cluster
    /// The cluster for which to retrieve the upgrade status.
    /// 
    /// ***Required privileges:*** System.Read
    /// 
    /// Refers instance of *ClusterComputeResource*.
    ///
    /// ## Returns:
    ///
    /// Status
    pub async fn vsan_query_upgrade_status_ex(&self, cluster: &crate::types::structs::ManagedObjectReference) -> Result<crate::types::structs::VsanUpgradeStatusEx> {
        let input = VsanQueryUpgradeStatusExRequestType {cluster, };
        let bytes = self.client.invoke("vsan", "VsanUpgradeSystemEx", &self.mo_id, "VsanQueryUpgradeStatusEx", Some(&input)).await?;
        let result: crate::types::structs::VsanUpgradeStatusEx = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
        Ok(result)
    }
    /// Process a scan and retrieve the highest vSAN disk format
    /// version that given cluster supports, the version is up to version
    /// of ESXi host in specified cluster:
    /// ESX of VSAN2017Q1, support version is 5.
    /// 
    /// ESX of vSphere6.0u2 and vSphere6.5, support version is 4;
    /// ESX of vSphere6.0 series before vSphere6.0U2, support version is 2;
    /// ESX of lower version, is not supported;
    ///
    /// ## Parameters:
    ///
    /// ### cluster
    /// The target cluster to process scan.
    /// 
    /// ***Required privileges:*** System.Read
    /// 
    /// Refers instance of *ClusterComputeResource*.
    ///
    /// ## Returns:
    ///
    /// int To present the highest supported disk format version.
    pub async fn retrieve_supported_vsan_format_version(&self, cluster: &crate::types::structs::ManagedObjectReference) -> Result<i32> {
        let input = RetrieveSupportedVsanFormatVersionRequestType {cluster, };
        let bytes = self.client.invoke("vsan", "VsanUpgradeSystemEx", &self.mo_id, "RetrieveSupportedVsanFormatVersion", Some(&input)).await?;
        let result: i32 = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
        Ok(result)
    }
}
struct PerformVsanUpgradeExRequestType<'a> {
    cluster: &'a crate::types::structs::ManagedObjectReference,
    perform_object_upgrade: Option<bool>,
    downgrade_format: Option<bool>,
    allow_reduced_redundancy: Option<bool>,
    exclude_hosts: Option<&'a [crate::types::structs::ManagedObjectReference]>,
    spec: Option<&'a crate::types::structs::VsanDiskFormatConversionSpec>,
}

impl<'a> miniserde::Serialize for PerformVsanUpgradeExRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(PerformVsanUpgradeExRequestTypeSer { data: self, seq: 0 }))
    }
}

struct PerformVsanUpgradeExRequestTypeSer<'b, 'a> {
    data: &'b PerformVsanUpgradeExRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for PerformVsanUpgradeExRequestTypeSer<'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"), &"PerformVsanUpgradeExRequestType")),
                1 => return Some((std::borrow::Cow::Borrowed("cluster"), &self.data.cluster as &dyn miniserde::Serialize)),
                2 => {
                    let Some(ref val) = self.data.perform_object_upgrade else { continue; };
                    return Some((std::borrow::Cow::Borrowed("performObjectUpgrade"), val as &dyn miniserde::Serialize));
                }
                3 => {
                    let Some(ref val) = self.data.downgrade_format else { continue; };
                    return Some((std::borrow::Cow::Borrowed("downgradeFormat"), val as &dyn miniserde::Serialize));
                }
                4 => {
                    let Some(ref val) = self.data.allow_reduced_redundancy else { continue; };
                    return Some((std::borrow::Cow::Borrowed("allowReducedRedundancy"), val as &dyn miniserde::Serialize));
                }
                5 => {
                    let Some(ref val) = self.data.exclude_hosts else { continue; };
                    return Some((std::borrow::Cow::Borrowed("excludeHosts"), val as &dyn miniserde::Serialize));
                }
                6 => {
                    let Some(ref val) = self.data.spec else { continue; };
                    return Some((std::borrow::Cow::Borrowed("spec"), val as &dyn miniserde::Serialize));
                }
                _ => return None,
            }
        }
    }
}
struct PerformVsanUpgradePreflightAsyncCheckRequestType<'a> {
    cluster: &'a crate::types::structs::ManagedObjectReference,
    downgrade_format: Option<bool>,
    spec: Option<&'a crate::types::structs::VsanDiskFormatConversionSpec>,
}

impl<'a> miniserde::Serialize for PerformVsanUpgradePreflightAsyncCheckRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(PerformVsanUpgradePreflightAsyncCheckRequestTypeSer { data: self, seq: 0 }))
    }
}

struct PerformVsanUpgradePreflightAsyncCheckRequestTypeSer<'b, 'a> {
    data: &'b PerformVsanUpgradePreflightAsyncCheckRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for PerformVsanUpgradePreflightAsyncCheckRequestTypeSer<'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"), &"PerformVsanUpgradePreflightAsyncCheckRequestType")),
                1 => return Some((std::borrow::Cow::Borrowed("cluster"), &self.data.cluster as &dyn miniserde::Serialize)),
                2 => {
                    let Some(ref val) = self.data.downgrade_format else { continue; };
                    return Some((std::borrow::Cow::Borrowed("downgradeFormat"), val as &dyn miniserde::Serialize));
                }
                3 => {
                    let Some(ref val) = self.data.spec else { continue; };
                    return Some((std::borrow::Cow::Borrowed("spec"), val as &dyn miniserde::Serialize));
                }
                _ => return None,
            }
        }
    }
}
struct PerformVsanUpgradePreflightCheckExRequestType<'a> {
    cluster: &'a crate::types::structs::ManagedObjectReference,
    downgrade_format: Option<bool>,
    spec: Option<&'a crate::types::structs::VsanDiskFormatConversionSpec>,
}

impl<'a> miniserde::Serialize for PerformVsanUpgradePreflightCheckExRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(PerformVsanUpgradePreflightCheckExRequestTypeSer { data: self, seq: 0 }))
    }
}

struct PerformVsanUpgradePreflightCheckExRequestTypeSer<'b, 'a> {
    data: &'b PerformVsanUpgradePreflightCheckExRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for PerformVsanUpgradePreflightCheckExRequestTypeSer<'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"), &"PerformVsanUpgradePreflightCheckExRequestType")),
                1 => return Some((std::borrow::Cow::Borrowed("cluster"), &self.data.cluster as &dyn miniserde::Serialize)),
                2 => {
                    let Some(ref val) = self.data.downgrade_format else { continue; };
                    return Some((std::borrow::Cow::Borrowed("downgradeFormat"), val as &dyn miniserde::Serialize));
                }
                3 => {
                    let Some(ref val) = self.data.spec else { continue; };
                    return Some((std::borrow::Cow::Borrowed("spec"), val as &dyn miniserde::Serialize));
                }
                _ => return None,
            }
        }
    }
}
struct VsanQueryUpgradeStatusExRequestType<'a> {
    cluster: &'a crate::types::structs::ManagedObjectReference,
}

impl<'a> miniserde::Serialize for VsanQueryUpgradeStatusExRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(VsanQueryUpgradeStatusExRequestTypeSer { data: self, seq: 0 }))
    }
}

struct VsanQueryUpgradeStatusExRequestTypeSer<'b, 'a> {
    data: &'b VsanQueryUpgradeStatusExRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for VsanQueryUpgradeStatusExRequestTypeSer<'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"), &"VsanQueryUpgradeStatusExRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("cluster"), &self.data.cluster as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct RetrieveSupportedVsanFormatVersionRequestType<'a> {
    cluster: &'a crate::types::structs::ManagedObjectReference,
}

impl<'a> miniserde::Serialize for RetrieveSupportedVsanFormatVersionRequestType<'a> {
    fn begin(&self) -> miniserde::ser::Fragment<'_> {
        miniserde::ser::Fragment::Map(Box::new(RetrieveSupportedVsanFormatVersionRequestTypeSer { data: self, seq: 0 }))
    }
}

struct RetrieveSupportedVsanFormatVersionRequestTypeSer<'b, 'a> {
    data: &'b RetrieveSupportedVsanFormatVersionRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for RetrieveSupportedVsanFormatVersionRequestTypeSer<'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"), &"RetrieveSupportedVsanFormatVersionRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("cluster"), &self.data.cluster as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}