Skip to main content

clientapi_pve/models/
pve_agent_config.rs

1/*
2 * Proxmox Virtual Environment API
3 *
4 * Generated from apidoc.js. NOT an official Proxmox specification. See https://pve.proxmox.com/pve-docs/api-viewer/ for the upstream documentation.
5 *
6 * The version of the OpenAPI document: 9.x
7 * 
8 * Generated by: https://openapi-generator.tech
9 */
10
11use crate::models;
12use serde::{Deserialize, Serialize};
13
14#[derive(Clone, Default, Debug, PartialEq, Serialize, Deserialize)]
15pub struct PveAgentConfig {
16
17    /// Enable/disable communication with a QEMU Guest Agent (QGA) running in the VM.
18    #[serde(rename = "enabled")]
19    pub enabled: models::PveBoolean,
20
21    /// Whether to issue the guest-fsfreeze-freeze and guest-fsfreeze-thaw QEMU guest agent commands. Backups in snapshot mode, clones, snapshots without RAM, importing disks from a running guest, and replications normally issue a guest-fsfreeze-freeze and a respective thaw command when the QEMU Guest agent option is enabled in the guest's configuration and the agent is running inside of the guest.  The deprecated 'freeze-fs-on-backup' setting is treated as an alias for this setting.
22    #[serde(rename = "freeze-fs", skip_serializing_if = "Option::is_none")]
23    pub freeze_fs: Option<models::PveBoolean>,
24
25    #[serde(rename = "freeze-fs-on-backup", skip_serializing_if = "Option::is_none")]
26    pub freeze_fs_on_backup: Option<String>,
27
28    /// Run fstrim after moving a disk or migrating the VM.
29    #[serde(rename = "fstrim_cloned_disks", skip_serializing_if = "Option::is_none")]
30    pub fstrim_cloned_disks: Option<models::PveBoolean>,
31
32    #[serde(rename = "guest-fsfreeze", skip_serializing_if = "Option::is_none")]
33    pub guest_fsfreeze: Option<String>,
34
35    /// Select the agent type
36    #[serde(rename = "type", skip_serializing_if = "Option::is_none")]
37    pub r#type: Option<models::PveQemuTypeEnum>,
38
39
40}
41
42impl PveAgentConfig {
43    pub fn new(enabled: models::PveBoolean) -> PveAgentConfig {
44        PveAgentConfig {
45            
46            enabled,
47            
48            freeze_fs: None,
49            
50            freeze_fs_on_backup: None,
51            
52            fstrim_cloned_disks: None,
53            
54            guest_fsfreeze: None,
55            
56            r#type: None,
57            
58        }
59    }
60}
61
62
63impl PveAgentConfig {
64    /// Serialise this PveAgentConfig into Proxmox's CLI-style shorthand
65    /// string (`key=value,…`). The property marked `x-pve-default-key`
66    /// is emitted positionally without a `key=` prefix; aliases collapse
67    /// multiple property names to the same wire key.
68    ///
69    /// Example: `PveAgentConfig `
70    /// → `"virtio,bridge=vmbr0"`
71    pub fn to_shorthand(&self) -> String {
72        let mut parts: Vec<String> = Vec::new();
73        
74        
75        parts.push(format!("{}", self.enabled));
76        
77        
78        
79        
80        if let Some(ref v) = self.freeze_fs {
81            parts.push(format!("freeze-fs={}", v));
82        }
83        
84        
85        if let Some(ref v) = self.freeze_fs_on_backup {
86            parts.push(format!("freeze-fs={}", v));
87        }
88        
89        
90        if let Some(ref v) = self.fstrim_cloned_disks {
91            parts.push(format!("fstrim_cloned_disks={}", v));
92        }
93        
94        
95        if let Some(ref v) = self.guest_fsfreeze {
96            parts.push(format!("freeze-fs={}", v));
97        }
98        
99        
100        if let Some(ref v) = self.r#type {
101            parts.push(format!("type={}", v));
102        }
103        
104        parts.join(",")
105    }
106}
107