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
use std::sync::Arc;
use crate::core::client::{VimClient, Result};
/// This managed object provides an interface
/// through which you can gather and configure the host CPU scheduler
/// policies that affect the performance of running virtual machines.
///
/// **Note**: This managed object is useful only on platforms where
/// resource management controls are available to optimize the running
/// of virtual machines.
#[derive(Clone)]
pub struct HostCpuSchedulerSystem {
client: Arc<dyn VimClient>,
mo_id: String,
}
impl HostCpuSchedulerSystem {
pub fn new(client: Arc<dyn VimClient>, mo_id: &str) -> Self {
Self {
client,
mo_id: mo_id.to_string(),
}
}
/// Don't treat hyperthreads as schedulable resources the next time the CPU
/// scheduler starts.
///
/// If successful, this operation will change the
/// configured setting.
///
/// ***Required privileges:*** Host.Config.HyperThreading
pub async fn disable_hyper_threading(&self) -> Result<()> {
self.client.invoke_void("", "HostCpuSchedulerSystem", &self.mo_id, "DisableHyperThreading", None).await
}
/// Treat hyperthreads as schedulable resources the next time the CPU
/// scheduler starts.
///
/// If successful, this operation will set the
/// *config*
/// property to "true".
///
/// ***Required privileges:*** Host.Config.HyperThreading
pub async fn enable_hyper_threading(&self) -> Result<()> {
self.client.invoke_void("", "HostCpuSchedulerSystem", &self.mo_id, "EnableHyperThreading", None).await
}
/// Assigns a value to a custom field.
///
/// The setCustomValue method requires
/// whichever updatePrivilege is defined as one of the
/// *CustomFieldDef.fieldInstancePrivileges*
/// for the CustomFieldDef whose value is being changed.
///
/// ## Parameters:
///
/// ### key
/// The name of the field whose value is to be updated.
///
/// ### value
/// Value to be assigned to the custom field.
pub async fn set_custom_value(&self, key: &str, value: &str) -> Result<()> {
let input = SetCustomValueRequestType {key, value, };
self.client.invoke_void("", "HostCpuSchedulerSystem", &self.mo_id, "setCustomValue", Some(&input)).await
}
/// List of custom field definitions that are valid for the object's type.
///
/// The fields are sorted by *CustomFieldDef.name*.
///
/// ***Required privileges:*** System.View
pub async fn available_field(&self) -> Result<Option<Vec<crate::types::structs::CustomFieldDef>>> {
let pv_opt = self.client.fetch_property_raw("", "HostCpuSchedulerSystem", &self.mo_id, "availableField").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// Information about the current CPU scheduler of the host.
///
/// Populates *HostCpuSchedulerInfo.policy* with the active *CPU Scheduling Policy*.
///
/// ***Since:*** vSphere API Release 8.0.3.0
pub async fn cpu_scheduler_info(&self) -> Result<Option<crate::types::structs::HostCpuSchedulerInfo>> {
let pv_opt = self.client.fetch_property_raw("", "HostCpuSchedulerSystem", &self.mo_id, "cpuSchedulerInfo").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// The hyperthread configuration for the CpuSchedulerSystem.
///
/// The
/// existence of this data object type indicates if the CPU scheduler
/// is capable of scheduling hyperthreads as resources.
pub async fn hyperthread_info(&self) -> Result<Option<crate::types::structs::HostHyperThreadScheduleInfo>> {
let pv_opt = self.client.fetch_property_raw("", "HostCpuSchedulerSystem", &self.mo_id, "hyperthreadInfo").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
/// List of custom field values.
///
/// Each value uses a key to associate
/// an instance of a *CustomFieldStringValue* with
/// a custom field definition.
///
/// ***Required privileges:*** System.View
pub async fn value(&self) -> Result<Option<Vec<Box<dyn crate::types::traits::CustomFieldValueTrait>>>> {
let pv_opt = self.client.fetch_property_raw("", "HostCpuSchedulerSystem", &self.mo_id, "value").await?;
match pv_opt {
Some(pv) => Ok(Some(crate::core::client::extract_property(pv)?)),
None => Ok(None),
}
}
}
struct SetCustomValueRequestType<'a> {
key: &'a str,
value: &'a str,
}
impl<'a> miniserde::Serialize for SetCustomValueRequestType<'a> {
fn begin(&self) -> miniserde::ser::Fragment<'_> {
miniserde::ser::Fragment::Map(Box::new(SetCustomValueRequestTypeSer { data: self, seq: 0 }))
}
}
struct SetCustomValueRequestTypeSer<'b, 'a> {
data: &'b SetCustomValueRequestType<'a>,
seq: usize,
}
impl<'b, 'a> miniserde::ser::Map for SetCustomValueRequestTypeSer<'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"), &"setCustomValueRequestType")),
1 => return Some((std::borrow::Cow::Borrowed("key"), &self.data.key as &dyn miniserde::Serialize)),
2 => return Some((std::borrow::Cow::Borrowed("value"), &self.data.value as &dyn miniserde::Serialize)),
_ => return None,
}
}
}