Skip to main content

clientapi_pve/models/
pve_mp_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 PveMpConfig {
16
17    /// Explicitly enable or disable ACL support.
18    #[serde(rename = "acl", skip_serializing_if = "Option::is_none")]
19    pub acl: Option<models::PveBoolean>,
20
21    /// Whether to include the mount point in backups (only used for volume mount points).
22    #[serde(rename = "backup", skip_serializing_if = "Option::is_none")]
23    pub backup: Option<models::PveBoolean>,
24
25    /// Customize UID/GID mappings that override the container's `lxc.idmap` for this mount point. Accepts a semicolon-separated list of `type:container:disk:range-size` entries.  `type` is `u` for UID or `g` for GID.  `container` is the first ID as seen inside the container.  `disk` is the first corresponding ID on the underlying filesystem.  `range-size` is the number of consecutive IDs to map.  Unmapped IDs fall back to the container's `lxc.idmap`.  Example 1: `u:123:456:1` maps UID 123 in the container to UID 456 on the disk. Files owned by UID 456 on the disk will appear as UID 123 inside the container.  Example 2: `g:100:50:5` maps 5 consecutive GIDs, such that GIDs 100-104 in the container are mapped to GIDs 50-54 on the disk.  Example 3: `passthrough` identity-maps all UIDs and GIDs, meaning IDs inside the container will match the IDs on the disk.
26    #[serde(rename = "idmap", skip_serializing_if = "Option::is_none")]
27    pub idmap: Option<String>,
28
29    /// Inherit UID, GID and access mode from the mount point directory, if it exists already.
30    #[serde(rename = "keepattrs", skip_serializing_if = "Option::is_none")]
31    pub keepattrs: Option<models::PveBoolean>,
32
33    /// Extra mount options for rootfs/mps.
34    #[serde(rename = "mountoptions", skip_serializing_if = "Option::is_none")]
35    pub mountoptions: Option<String>,
36
37    /// Path to the mount point as seen from inside the container.  NOTE: Must not contain any symlinks for security reasons.
38    #[serde(rename = "mp")]
39    pub mp: String,
40
41    /// Enable user quotas inside the container (not supported with zfs subvolumes)
42    #[serde(rename = "quota", skip_serializing_if = "Option::is_none")]
43    pub quota: Option<models::PveBoolean>,
44
45    /// Will include this volume to a storage replica job.
46    #[serde(rename = "replicate", skip_serializing_if = "Option::is_none")]
47    pub replicate: Option<models::PveBoolean>,
48
49    /// Read-only mount point
50    #[serde(rename = "ro", skip_serializing_if = "Option::is_none")]
51    pub ro: Option<models::PveBoolean>,
52
53    /// Mark this non-volume mount point as available on all nodes.  WARNING: This option does not share the mount point automatically, it assumes it is shared already!
54    #[serde(rename = "shared", skip_serializing_if = "Option::is_none")]
55    pub shared: Option<models::PveBoolean>,
56
57    /// Volume size (read only value).
58    #[serde(rename = "size", skip_serializing_if = "Option::is_none")]
59    pub size: Option<String>,
60
61    /// Volume, device or directory to mount into the container.
62    #[serde(rename = "volume")]
63    pub volume: String,
64
65
66}
67
68impl PveMpConfig {
69    pub fn new(mp: String, volume: String) -> PveMpConfig {
70        PveMpConfig {
71            
72            acl: None,
73            
74            backup: None,
75            
76            idmap: None,
77            
78            keepattrs: None,
79            
80            mountoptions: None,
81            
82            mp,
83            
84            quota: None,
85            
86            replicate: None,
87            
88            ro: None,
89            
90            shared: None,
91            
92            size: None,
93            
94            volume,
95            
96        }
97    }
98}
99
100
101impl PveMpConfig {
102    /// Serialise this PveMpConfig into Proxmox's CLI-style shorthand
103    /// string (`key=value,…`). The property marked `x-pve-default-key`
104    /// is emitted positionally without a `key=` prefix; aliases collapse
105    /// multiple property names to the same wire key.
106    ///
107    /// Example: `PveMpConfig `
108    /// → `"virtio,bridge=vmbr0"`
109    pub fn to_shorthand(&self) -> String {
110        let mut parts: Vec<String> = Vec::new();
111        
112        
113        parts.push(format!("{}", self.volume));
114        
115        
116        
117        
118        if let Some(ref v) = self.acl {
119            parts.push(format!("acl={}", v));
120        }
121        
122        
123        if let Some(ref v) = self.backup {
124            parts.push(format!("backup={}", v));
125        }
126        
127        
128        if let Some(ref v) = self.idmap {
129            parts.push(format!("idmap={}", v));
130        }
131        
132        
133        if let Some(ref v) = self.keepattrs {
134            parts.push(format!("keepattrs={}", v));
135        }
136        
137        
138        if let Some(ref v) = self.mountoptions {
139            parts.push(format!("mountoptions={}", v));
140        }
141        
142        
143        parts.push(format!("mp={}", self.mp));
144        
145        
146        
147        if let Some(ref v) = self.quota {
148            parts.push(format!("quota={}", v));
149        }
150        
151        
152        if let Some(ref v) = self.replicate {
153            parts.push(format!("replicate={}", v));
154        }
155        
156        
157        if let Some(ref v) = self.ro {
158            parts.push(format!("ro={}", v));
159        }
160        
161        
162        if let Some(ref v) = self.shared {
163            parts.push(format!("shared={}", v));
164        }
165        
166        
167        if let Some(ref v) = self.size {
168            parts.push(format!("size={}", v));
169        }
170        
171        parts.join(",")
172    }
173}
174