pve/nodes/node/qemu/vmid/
migrate.rs

1#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
2pub struct GetParameters {
3    #[doc = "Target node."]
4    #[serde(skip_serializing_if = "Option::is_none", default)]
5    pub target: Option<String>,
6}
7
8#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
9pub struct GetResponseItem {
10    #[doc = "List nodes allowed for offline migration, only passed if VM is offline"]
11    #[serde(skip_serializing_if = "Option::is_none", default)]
12    pub allowed_nodes: Option<Vec<serde_json::Value>>,
13    #[doc = "List local disks including CD-Rom, unsused and not referenced disks"]
14    pub local_disks: Vec<serde_json::Value>,
15    #[doc = "List local resources e.g. pci, usb"]
16    pub local_resources: Vec<serde_json::Value>,
17    #[doc = "List not allowed nodes with additional informations, only passed if VM is offline"]
18    #[serde(skip_serializing_if = "Option::is_none", default)]
19    pub not_allowed_nodes: Option<NotAllowedNodes>,
20    #[serde(
21        deserialize_with = "crate::common::deserialize_bool_lax",
22        serialize_with = "crate::common::serialize_bool_as_u64"
23    )]
24    pub running: bool,
25}
26
27#[doc = "List not allowed nodes with additional informations, only passed if VM is offline"]
28#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, Default)]
29pub struct NotAllowedNodes {}
30
31#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
32pub struct PostParameters {
33    #[doc = "Override I/O bandwidth limit (in KiB/s)."]
34    #[serde(skip_serializing_if = "Option::is_none", default)]
35    pub bwlimit: Option<u64>,
36    #[doc = "Allow to migrate VMs which use local devices. Only root may use this option."]
37    #[serde(
38        skip_serializing_if = "Option::is_none",
39        default,
40        deserialize_with = "crate::common::deserialize_option_bool_lax",
41        serialize_with = "crate::common::serialize_option_bool_as_u64"
42    )]
43    pub force: Option<bool>,
44    #[doc = "CIDR of the (sub) network that is used for migration."]
45    #[serde(skip_serializing_if = "Option::is_none", default)]
46    pub migration_network: Option<String>,
47    #[doc = "Migration traffic is encrypted using an SSH tunnel by default. On secure, completely private networks this can be disabled to increase performance."]
48    #[serde(skip_serializing_if = "Option::is_none", default)]
49    pub migration_type: Option<String>,
50    #[doc = "Use online/live migration if VM is running. Ignored if VM is stopped."]
51    #[serde(
52        skip_serializing_if = "Option::is_none",
53        default,
54        deserialize_with = "crate::common::deserialize_option_bool_lax",
55        serialize_with = "crate::common::serialize_option_bool_as_u64"
56    )]
57    pub online: Option<bool>,
58    #[doc = "Target node."]
59    pub target: String,
60    #[doc = "Mapping from source to target storages. Providing only a single storage ID maps all source storages to that storage. Providing the special value '1' will map each source storage to itself."]
61    #[serde(skip_serializing_if = "Option::is_none", default)]
62    pub targetstorage: Option<String>,
63    #[doc = "Enable live storage migration for local disk"]
64    #[serde(
65        rename = "with-local-disks",
66        skip_serializing_if = "Option::is_none",
67        default,
68        deserialize_with = "crate::common::deserialize_option_bool_lax",
69        serialize_with = "crate::common::serialize_option_bool_as_u64"
70    )]
71    pub with_local_disks: Option<bool>,
72}
73
74#[derive(Debug, Clone)]
75pub struct MigrateClient<T> {
76    client: T,
77    path: String,
78}
79
80impl<T> MigrateClient<T>
81where
82    T: Clone,
83{
84    pub fn new(client: T, parent_path: &str) -> Self {
85        Self {
86            client,
87            path: format!("{}/{}", parent_path, "migrate"),
88        }
89    }
90}
91impl<T> MigrateClient<T>
92where
93    T: crate::client::HttpClient,
94{
95    #[doc = "Get preconditions for migration."]
96    pub fn get(&self, parameters: GetParameters) -> Result<GetResponseItem, T::Error> {
97        self.client.get(&self.path, &parameters)
98    }
99
100    #[doc = "Migrate virtual machine. Creates a new migration task."]
101    pub fn post(&self, parameters: PostParameters) -> Result<String, T::Error> {
102        self.client.post(&self.path, &parameters)
103    }
104}
105#[derive(Debug, Clone)]
106pub struct AsyncMigrateClient<T> {
107    client: T,
108    path: String,
109}
110
111impl<T> AsyncMigrateClient<T>
112where
113    T: Clone,
114{
115    pub fn new(client: T, parent_path: &str) -> Self {
116        Self {
117            client,
118            path: format!("{}/{}", parent_path, "migrate"),
119        }
120    }
121}
122impl<T> AsyncMigrateClient<T>
123where
124    T: crate::client::AsyncHttpClient,
125{
126    #[doc = "Get preconditions for migration."]
127    pub async fn get(&self, parameters: GetParameters) -> Result<GetResponseItem, T::Error> {
128        self.client.get(&self.path, &parameters).await
129    }
130
131    #[doc = "Migrate virtual machine. Creates a new migration task."]
132    pub async fn post(&self, parameters: PostParameters) -> Result<String, T::Error> {
133        self.client.post(&self.path, &parameters).await
134    }
135}