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
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// VSAN Upgrade System.
///
/// Used to perform and monitor VSAN on-disk format
/// upgrades.
#[derive(Clone)]
pub struct VsanUpgradeSystem {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl VsanUpgradeSystem {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
/// Start VSAN on-disk format upgrade process on a particular cluster.
///
/// 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.
/// This is a long running (hours to days) task. In addition to normal
/// task progress reporting, use the queryUpgradeStatus() API which allows
/// to retrieve in-depth status updates from the upgrade process. In there
/// will be a detailed log of every operation the upgrade process has taken
/// or issues it encountered. Some are simple log messages, others refer
/// to operations like evacuating a disk group. For such log entries, the
/// task object of the evacuation task is provided to allow "sub-task"
/// tracking.
/// Before starting, the upgrade process will perform a pre-flight check,
/// and abort if any of the pre-conditions are not met. See
///
/// See also *VsanUpgradeSystem.PerformVsanUpgradePreflightCheck*for details on the pre-conditions being checked for.
/// The upgrade process performs additional "pre-flight checks" before
/// proceeding to upgrade the next host. The upgrade process will be halted
/// if any of those pre-flight 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 pre-flight check results
/// indicate such a condition. The upgrade process will however only re-add
/// those disks if the restoreBackup parameter is passed in as true.
/// Privilege "Host.Config.Storage" on all hosts under specified cluster
/// is required..
///
/// ***Required privileges:*** System.Read
///
/// ## Parameters:
///
/// ### cluster
/// The cluster to be upgraded
///
/// 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.
///
/// ### 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*.
///
/// ## Returns:
///
/// Refers instance of *Task*.
///
/// ## Errors:
///
/// Failure
pub async fn perform_vsan_upgrade_task(&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]>) -> Result<crate::types::structs::ManagedObjectReference> {
let input = PerformVsanUpgradeRequestType {cluster, perform_object_upgrade, downgrade_format, allow_reduced_redundancy, exclude_hosts, };
let bytes = self.client.invoke("vsan", "VsanUpgradeSystem", &self.mo_id, "PerformVsanUpgrade_Task", Some(&input)).await?;
let result: crate::types::structs::ManagedObjectReference = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Perform an upgrade pre-flight check on a cluster.
///
/// ***Required privileges:*** System.Read
///
/// ## Parameters:
///
/// ### cluster
/// The cluster for which to perform the check.
///
/// Refers instance of *ClusterComputeResource*.
///
/// ### downgrade_format
/// Intend to perform a on-disk format downgrade instead
/// of upgrade. Adds additional checks.
///
/// ## Returns:
///
/// Pre-flight check result.
///
/// ## Errors:
///
/// Failure
pub async fn perform_vsan_upgrade_preflight_check(&self, cluster: &crate::types::structs::ManagedObjectReference, downgrade_format: Option<bool>) -> Result<Box<dyn crate::types::traits::VsanUpgradeSystemPreflightCheckResultTrait>> {
let input = PerformVsanUpgradePreflightCheckRequestType {cluster, downgrade_format, };
let bytes = self.client.invoke("vsan", "VsanUpgradeSystem", &self.mo_id, "PerformVsanUpgradePreflightCheck", Some(&input)).await?;
let result: Box<dyn crate::types::traits::VsanUpgradeSystemPreflightCheckResultTrait> = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
/// Retrieve the latest status of a running, or the previously completed,
/// upgrade process.
///
/// Information about previous upgrade runs are not
/// always, e.g. when VC gets restarted.
///
/// ***Required privileges:*** System.Read
///
/// ## Parameters:
///
/// ### cluster
/// The cluster for which to retrieve the upgrade status.
///
/// Refers instance of *ClusterComputeResource*.
///
/// ## Returns:
///
/// Status
///
/// ## Errors:
///
/// Failure
pub async fn query_vsan_upgrade_status(&self, cluster: &crate::types::structs::ManagedObjectReference) -> Result<Box<dyn crate::types::traits::VsanUpgradeSystemUpgradeStatusTrait>> {
let input = QueryVsanUpgradeStatusRequestType {cluster, };
let bytes = self.client.invoke("vsan", "VsanUpgradeSystem", &self.mo_id, "QueryVsanUpgradeStatus", Some(&input)).await?;
let result: Box<dyn crate::types::traits::VsanUpgradeSystemUpgradeStatusTrait> = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
Ok(result)
}
}
struct PerformVsanUpgradeRequestType<'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]>,
}
impl<'a> miniserde::Serialize for PerformVsanUpgradeRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(PerformVsanUpgradeRequestTypeSer { data: self, seq: 0 }))
}
}
struct PerformVsanUpgradeRequestTypeSer<'b, 'a> {
data: &'b PerformVsanUpgradeRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for PerformVsanUpgradeRequestTypeSer<'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"), &"PerformVsanUpgradeRequestType")),
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));
}
_ => return None,
}
}
}
}
struct PerformVsanUpgradePreflightCheckRequestType<'a> {
cluster: &'a crate::types::structs::ManagedObjectReference,
downgrade_format: Option<bool>,
}
impl<'a> miniserde::Serialize for PerformVsanUpgradePreflightCheckRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(PerformVsanUpgradePreflightCheckRequestTypeSer { data: self, seq: 0 }))
}
}
struct PerformVsanUpgradePreflightCheckRequestTypeSer<'b, 'a> {
data: &'b PerformVsanUpgradePreflightCheckRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for PerformVsanUpgradePreflightCheckRequestTypeSer<'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"), &"PerformVsanUpgradePreflightCheckRequestType")),
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));
}
_ => return None,
}
}
}
}
struct QueryVsanUpgradeStatusRequestType<'a> {
cluster: &'a crate::types::structs::ManagedObjectReference,
}
impl<'a> miniserde::Serialize for QueryVsanUpgradeStatusRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(QueryVsanUpgradeStatusRequestTypeSer { data: self, seq: 0 }))
}
}
struct QueryVsanUpgradeStatusRequestTypeSer<'b, 'a> {
data: &'b QueryVsanUpgradeStatusRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for QueryVsanUpgradeStatusRequestTypeSer<'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"), &"QueryVsanUpgradeStatusRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("cluster"), &self.data.cluster as &dyn miniserde::Serialize)),
_ => return None,
}
}
}