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
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// This managed object provides interfaces for mapping VMkernel NIC to
/// iSCSI Host Bus Adapter.
#[derive(Clone)]
pub struct IscsiManager {
    client: Arc<dyn VimClient>,
    mo_id: String,
}
impl IscsiManager {
    pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
        Self {
            client,
            mo_id: mo_id.to_string(),
        }
    }
    /// Bind a Virtual NIC to be used for an iSCSI adapter
    /// 
    /// ***Required privileges:*** Host.Config.Storage
    ///
    /// ## Parameters:
    ///
    /// ### i_scsi_hba_name
    /// iSCSI adapter name for which the Virtual NIC to
    /// be added.
    ///
    /// ### vnic_device
    /// Virtual NIC that is to be bound to the iSCSI HBA
    ///
    /// ## Errors:
    ///
    /// ***IscsiFaultVnicAlreadyBound***: The given Virtual NIC is already bound to the HBA.
    /// 
    /// ***IscsiFaultVnicHasNoUplinks***: The given Virtual NIC has no physical uplinks.
    /// 
    /// ***IscsiFaultVnicHasMultipleUplinks***: The given Virtual NIC has multiple uplinks.
    /// 
    /// ***IscsiFaultVnicHasWrongUplink***: The given Virtual NIC has the wrong uplink and
    /// it can't be used for iSCSI multi-pathing.
    /// 
    /// ***IscsiFaultVnicNotFound***: The given Virtual NIC is not present on the system.
    /// 
    /// ***IscsiFaultInvalidVnic***: The given Virtual NIC is not valid for the HBA.
    /// 
    /// ***PlatformConfigFault***: For platform error that occurs during the operation.
    /// 
    /// ***IscsiFault***: For any problem that is not handled with a more specific fault.
    /// 
    /// ***NotFound***: If the given HBA is not found
    pub async fn bind_vnic(&self, i_scsi_hba_name: &str, vnic_device: &str) -> Result<()> {
        let input = BindVnicRequestType {i_scsi_hba_name, vnic_device, };
        self.client.invoke_void("", "IscsiManager", &self.mo_id, "BindVnic", Some(&input)).await
    }
    /// Query the list of Virtual NICs that are bound to a given iSCSI HBA.
    /// 
    /// ***Required privileges:*** Host.Config.Storage
    ///
    /// ## Parameters:
    ///
    /// ### i_scsi_hba_name
    /// iSCSI adapter name for which the method to be
    /// applied.
    ///
    /// ## Returns:
    ///
    /// An array of *IscsiPortInfo* containing detailed
    /// information on the list of Virtual NICs bound to the adapter
    ///
    /// ## Errors:
    ///
    /// ***IscsiFault***: For any problem that is not handled with a more specific fault.
    /// 
    /// ***NotFound***: If the given HBA is not found
    pub async fn query_bound_vnics(&self, i_scsi_hba_name: &str) -> Result<Option<Vec<crate::types::structs::IscsiPortInfo>>> {
        let input = QueryBoundVnicsRequestType {i_scsi_hba_name, };
        let bytes_opt = self.client.invoke_optional("", "IscsiManager", &self.mo_id, "QueryBoundVnics", Some(&input)).await?;
        match bytes_opt {
            Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
            None => Ok(None),
        }
    }
    /// Query the candidate Virtual NICs and Physical NICs that can be used
    /// for Port-Binding.
    /// 
    /// For dependent offload adapters, the Virtual NIC should be attached
    /// to the physical NIC associated with the hardware function.
    /// 
    /// ***Required privileges:*** Host.Config.Storage
    ///
    /// ## Parameters:
    ///
    /// ### i_scsi_hba_name
    /// iSCSI Adapter name for which the method to be
    /// applied.
    ///
    /// ## Returns:
    ///
    /// Array of *IscsiPortInfo* containing detailed
    /// information on list of eligible Virtual NICs that can be bound
    /// to the adapter. This list will also include details on the
    /// eligible Physical NICs that are not associated with any
    /// Virtual NICs.
    ///
    /// ## Errors:
    ///
    /// ***IscsiFault***: For any problem that is not handled with a more specific fault.
    /// 
    /// ***NotFound***: If the given HBA is not found
    pub async fn query_candidate_nics(&self, i_scsi_hba_name: &str) -> Result<Option<Vec<crate::types::structs::IscsiPortInfo>>> {
        let input = QueryCandidateNicsRequestType {i_scsi_hba_name, };
        let bytes_opt = self.client.invoke_optional("", "IscsiManager", &self.mo_id, "QueryCandidateNics", Some(&input)).await?;
        match bytes_opt {
            Some(ref b) => Ok(Some(crate::core::client::unmarshal_array(self.client.transport(), b)?)),
            None => Ok(None),
        }
    }
    /// Query the dependency table for a migration operation of a given Physical
    /// NIC.
    /// 
    /// ***Required privileges:*** Host.Config.Storage
    ///
    /// ## Parameters:
    ///
    /// ### pnic_device
    /// List of Physical NICs to be migrated
    ///
    /// ## Returns:
    ///
    /// Dependency table, as described in *IscsiMigrationDependency*,
    /// providing the user of all the Virtual NIC and iSCSI resources
    /// affected.
    pub async fn query_migration_dependencies(&self, pnic_device: &[String]) -> Result<crate::types::structs::IscsiMigrationDependency> {
        let input = QueryMigrationDependenciesRequestType {pnic_device, };
        let bytes = self.client.invoke("", "IscsiManager", &self.mo_id, "QueryMigrationDependencies", Some(&input)).await?;
        let result: crate::types::structs::IscsiMigrationDependency = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
        Ok(result)
    }
    /// Query if Physical NIC device is used for iSCSI.
    /// 
    /// ***Required privileges:*** Host.Config.Storage
    ///
    /// ## Parameters:
    ///
    /// ### pnic_device
    /// Physical NIC device name to check the status for
    ///
    /// ## Returns:
    ///
    /// A status object, *IscsiStatus*, indicating
    /// whether Physical NIC is used by iSCSI or not.
    /// - Empty *IscsiStatus* (i.e reason unset)
    ///   if Physical NIC device is not used.
    /// - Fault code *IscsiFaultPnicInUse* if
    ///   Physical NIC is being used.
    ///
    /// ## Errors:
    ///
    /// ***IscsiFault***: For any problem that is not handled with a more specific fault.
    pub async fn query_pnic_status(&self, pnic_device: &str) -> Result<crate::types::structs::IscsiStatus> {
        let input = QueryPnicStatusRequestType {pnic_device, };
        let bytes = self.client.invoke("", "IscsiManager", &self.mo_id, "QueryPnicStatus", Some(&input)).await?;
        let result: crate::types::structs::IscsiStatus = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
        Ok(result)
    }
    /// Query the status of Virtual NIC association with the iSCSI.
    /// 
    /// ***Required privileges:*** Host.Config.Storage
    ///
    /// ## Parameters:
    ///
    /// ### vnic_device
    /// Virtual NIC device to check the status for
    ///
    /// ## Returns:
    ///
    /// A status object *IscsiStatus*, containing
    /// list of the fault codes, providing the user with information as to
    /// whether Virtual NIC is used by iSCSI and list of compliance check
    /// failure codes if any. The returned *IscsiStatus*
    /// object will have an array of *MethodFault* objects providing
    /// following information:
    /// - Empty *IscsiStatus* (i.e reason unset)
    ///   if Virtual NIC device is not used.
    /// - Fault code *IscsiFaultVnicInUse* if Virtual
    ///   NIC is being used by iSCSI.
    /// - This will be followed with list of fault codes
    ///   corresponding to the compliance check failures.
    ///
    /// ## Errors:
    ///
    /// ***IscsiFault***: For any problem that is not handled with a more specific fault.
    pub async fn query_vnic_status(&self, vnic_device: &str) -> Result<crate::types::structs::IscsiStatus> {
        let input = QueryVnicStatusRequestType {vnic_device, };
        let bytes = self.client.invoke("", "IscsiManager", &self.mo_id, "QueryVnicStatus", Some(&input)).await?;
        let result: crate::types::structs::IscsiStatus = crate::core::client::unmarshal(self.client.transport(), &bytes)?;
        Ok(result)
    }
    /// Unbind Virtual NIC binding from an iSCSI adapter.
    /// 
    /// ***Required privileges:*** Host.Config.Storage
    ///
    /// ## Parameters:
    ///
    /// ### i_scsi_hba_name
    /// iSCSI adapter name for which the Virtual NIC to
    /// be removed.
    ///
    /// ### vnic_device
    /// Virtual NIC that is to be removed from the iSCSI HBA
    ///
    /// ### force
    /// -
    ///
    /// ## Errors:
    ///
    /// ***IscsiFaultVnicNotBound***: The given Virtual NIC is not bound to the adapter
    /// 
    /// ***IscsiFaultVnicHasActivePaths***: The given Virtual NIC is associated with "active" paths
    /// to the storage.
    /// 
    /// ***IscsiFaultVnicIsLastPath***: The given Virtual NIC is associated with "only" paths
    /// to the storage.
    /// 
    /// ***PlatformConfigFault***: For platform error that occurs during the operation.
    /// 
    /// ***IscsiFault***: For any problem that is not handled with a more specific fault.
    /// 
    /// ***NotFound***: If the given HBA is not found
    pub async fn unbind_vnic(&self, i_scsi_hba_name: &str, vnic_device: &str, force: bool) -> Result<()> {
        let input = UnbindVnicRequestType {i_scsi_hba_name, vnic_device, force, };
        self.client.invoke_void("", "IscsiManager", &self.mo_id, "UnbindVnic", Some(&input)).await
    }
}
struct BindVnicRequestType<'a> {
    i_scsi_hba_name: &'a str,
    vnic_device: &'a str,
}

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

struct BindVnicRequestTypeSer<'b, 'a> {
    data: &'b BindVnicRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for BindVnicRequestTypeSer<'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"), &"BindVnicRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("iScsiHbaName"), &self.data.i_scsi_hba_name as &dyn miniserde::Serialize)),
            2 => return Some((std::borrow::Cow::Borrowed("vnicDevice"), &self.data.vnic_device as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct QueryBoundVnicsRequestType<'a> {
    i_scsi_hba_name: &'a str,
}

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

struct QueryBoundVnicsRequestTypeSer<'b, 'a> {
    data: &'b QueryBoundVnicsRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for QueryBoundVnicsRequestTypeSer<'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"), &"QueryBoundVnicsRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("iScsiHbaName"), &self.data.i_scsi_hba_name as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct QueryCandidateNicsRequestType<'a> {
    i_scsi_hba_name: &'a str,
}

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

struct QueryCandidateNicsRequestTypeSer<'b, 'a> {
    data: &'b QueryCandidateNicsRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for QueryCandidateNicsRequestTypeSer<'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"), &"QueryCandidateNicsRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("iScsiHbaName"), &self.data.i_scsi_hba_name as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct QueryMigrationDependenciesRequestType<'a> {
    pnic_device: &'a [String],
}

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

struct QueryMigrationDependenciesRequestTypeSer<'b, 'a> {
    data: &'b QueryMigrationDependenciesRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for QueryMigrationDependenciesRequestTypeSer<'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"), &"QueryMigrationDependenciesRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("pnicDevice"), &self.data.pnic_device as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct QueryPnicStatusRequestType<'a> {
    pnic_device: &'a str,
}

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

struct QueryPnicStatusRequestTypeSer<'b, 'a> {
    data: &'b QueryPnicStatusRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for QueryPnicStatusRequestTypeSer<'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"), &"QueryPnicStatusRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("pnicDevice"), &self.data.pnic_device as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct QueryVnicStatusRequestType<'a> {
    vnic_device: &'a str,
}

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

struct QueryVnicStatusRequestTypeSer<'b, 'a> {
    data: &'b QueryVnicStatusRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for QueryVnicStatusRequestTypeSer<'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"), &"QueryVnicStatusRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("vnicDevice"), &self.data.vnic_device as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}
struct UnbindVnicRequestType<'a> {
    i_scsi_hba_name: &'a str,
    vnic_device: &'a str,
    force: bool,
}

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

struct UnbindVnicRequestTypeSer<'b, 'a> {
    data: &'b UnbindVnicRequestType<'a>,
    seq: usize,
}

impl<'b, 'a> miniserde::ser::Map for UnbindVnicRequestTypeSer<'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"), &"UnbindVnicRequestType")),
            1 => return Some((std::borrow::Cow::Borrowed("iScsiHbaName"), &self.data.i_scsi_hba_name as &dyn miniserde::Serialize)),
            2 => return Some((std::borrow::Cow::Borrowed("vnicDevice"), &self.data.vnic_device as &dyn miniserde::Serialize)),
            3 => return Some((std::borrow::Cow::Borrowed("force"), &self.data.force as &dyn miniserde::Serialize)),
            _ => return None,
        }
    }
}