Skip to main content

clientapi_pve/models/
pve_rootfs_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 PveRootfsConfig {
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    /// 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.
22    #[serde(rename = "idmap", skip_serializing_if = "Option::is_none")]
23    pub idmap: Option<String>,
24
25    /// Extra mount options for rootfs/mps.
26    #[serde(rename = "mountoptions", skip_serializing_if = "Option::is_none")]
27    pub mountoptions: Option<String>,
28
29    /// Enable user quotas inside the container (not supported with zfs subvolumes)
30    #[serde(rename = "quota", skip_serializing_if = "Option::is_none")]
31    pub quota: Option<models::PveBoolean>,
32
33    /// Will include this volume to a storage replica job.
34    #[serde(rename = "replicate", skip_serializing_if = "Option::is_none")]
35    pub replicate: Option<models::PveBoolean>,
36
37    /// Read-only mount point
38    #[serde(rename = "ro", skip_serializing_if = "Option::is_none")]
39    pub ro: Option<models::PveBoolean>,
40
41    /// 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!
42    #[serde(rename = "shared", skip_serializing_if = "Option::is_none")]
43    pub shared: Option<models::PveBoolean>,
44
45    /// Volume size (read only value).
46    #[serde(rename = "size", skip_serializing_if = "Option::is_none")]
47    pub size: Option<String>,
48
49    /// Volume, device or directory to mount into the container.
50    #[serde(rename = "volume")]
51    pub volume: String,
52
53
54}
55
56impl PveRootfsConfig {
57    pub fn new(volume: String) -> PveRootfsConfig {
58        PveRootfsConfig {
59            
60            acl: None,
61            
62            idmap: None,
63            
64            mountoptions: None,
65            
66            quota: None,
67            
68            replicate: None,
69            
70            ro: None,
71            
72            shared: None,
73            
74            size: None,
75            
76            volume,
77            
78        }
79    }
80}
81
82
83impl PveRootfsConfig {
84    /// Serialise this PveRootfsConfig into Proxmox's CLI-style shorthand
85    /// string (`key=value,…`). The property marked `x-pve-default-key`
86    /// is emitted positionally without a `key=` prefix; aliases collapse
87    /// multiple property names to the same wire key.
88    ///
89    /// Example: `PveRootfsConfig `
90    /// → `"virtio,bridge=vmbr0"`
91    pub fn to_shorthand(&self) -> String {
92        let mut parts: Vec<String> = Vec::new();
93        
94        
95        parts.push(format!("{}", self.volume));
96        
97        
98        
99        
100        if let Some(ref v) = self.acl {
101            parts.push(format!("acl={}", v));
102        }
103        
104        
105        if let Some(ref v) = self.idmap {
106            parts.push(format!("idmap={}", v));
107        }
108        
109        
110        if let Some(ref v) = self.mountoptions {
111            parts.push(format!("mountoptions={}", v));
112        }
113        
114        
115        if let Some(ref v) = self.quota {
116            parts.push(format!("quota={}", v));
117        }
118        
119        
120        if let Some(ref v) = self.replicate {
121            parts.push(format!("replicate={}", v));
122        }
123        
124        
125        if let Some(ref v) = self.ro {
126            parts.push(format!("ro={}", v));
127        }
128        
129        
130        if let Some(ref v) = self.shared {
131            parts.push(format!("shared={}", v));
132        }
133        
134        
135        if let Some(ref v) = self.size {
136            parts.push(format!("size={}", v));
137        }
138        
139        parts.join(",")
140    }
141}
142