2 use ::serde
::{Deserialize, Serialize}
;
4 use proxmox
::api
::{api, schema::*}
;
5 use proxmox
::const_regex
;
6 use proxmox
::{IPRE, IPV4RE, IPV6RE, IPV4OCTET, IPV6H16, IPV6LS32}
;
8 // File names: may not contain slashes, may not start with "."
9 pub const FILENAME_FORMAT
: ApiStringFormat
= ApiStringFormat
::VerifyFn(|name
| {
10 if name
.starts_with('
.'
) {
11 bail
!("file names may not start with '.'");
13 if name
.contains('
/'
) {
14 bail
!("file names may not contain slashes");
19 macro_rules
! DNS_LABEL { () => (r"(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?)") }
20 macro_rules
! DNS_NAME { () => (concat!(r"(?:", DNS_LABEL!() , r"\.)*", DNS_LABEL!())) }
22 // we only allow a limited set of characters
23 // colon is not allowed, because we store usernames in
24 // colon separated lists)!
25 // slash is not allowed because it is used as pve API delimiter
26 // also see "man useradd"
27 macro_rules
! USER_NAME_REGEX_STR { () => (r"(?:[^\s:/[:cntrl:]]+)") }
28 macro_rules
! GROUP_NAME_REGEX_STR { () => (USER_NAME_REGEX_STR!()) }
30 macro_rules
! USER_ID_REGEX_STR { () => (concat!(USER_NAME_REGEX_STR!(), r"@", PROXMOX_SAFE_ID_REGEX_STR!())) }
33 macro_rules
! PROXMOX_SAFE_ID_REGEX_STR { () => (r"(?:[A-Za-z0-9_][A-Za-z0-9._\-]*)") }
35 macro_rules
! CIDR_V4_REGEX_STR { () => (concat!(r"(?:", IPV4RE!(), r"/\d{1,2}
)$
")) }
36 macro_rules! CIDR_V6_REGEX_STR { () => (concat!(r"(?:", IPV6RE!(), r"/\d{1,3})$")) }
39 pub IP_V4_REGEX
= concat
!(r
"^", IPV4RE
!(), r
"$");
40 pub IP_V6_REGEX
= concat
!(r
"^", IPV6RE
!(), r
"$");
41 pub IP_REGEX
= concat
!(r
"^", IPRE
!(), r
"$");
42 pub CIDR_V4_REGEX
= concat
!(r
"^", CIDR_V4_REGEX_STR
!(), r
"$");
43 pub CIDR_V6_REGEX
= concat
!(r
"^", CIDR_V6_REGEX_STR
!(), r
"$");
44 pub CIDR_REGEX
= concat
!(r
"^(?:", CIDR_V4_REGEX_STR
!(), "|", CIDR_V6_REGEX_STR
!(), r
")$");
46 pub SHA256_HEX_REGEX
= r
"^[a-f0-9]{64}$"; // fixme: define in common_regex ?
47 pub SYSTEMD_DATETIME_REGEX
= r
"^\d{4}-\d{2}-\d{2}( \d{2}:\d{2}(:\d{2})?)?$"; // fixme: define in common_regex ?
49 pub PASSWORD_REGEX
= r
"^[[:^cntrl:]]*$"; // everything but control characters
51 /// Regex for safe identifiers.
54 /// [article](https://dwheeler.com/essays/fixing-unix-linux-filenames.html)
55 /// contains further information why it is reasonable to restict
56 /// names this way. This is not only useful for filenames, but for
57 /// any identifier command line tools work with.
58 pub PROXMOX_SAFE_ID_REGEX
= concat
!(r
"^", PROXMOX_SAFE_ID_REGEX_STR
!(), r
"$");
60 pub SINGLE_LINE_COMMENT_REGEX
= r
"^[[:^cntrl:]]*$";
62 pub HOSTNAME_REGEX
= r
"^(?:[a-zA-Z0-9](?:[a-zA-Z0-9\-]*[a-zA-Z0-9])?)$";
64 pub DNS_NAME_REGEX
= concat
!(r
"^", DNS_NAME
!(), r
"$");
66 pub DNS_NAME_OR_IP_REGEX
= concat
!(r
"^", DNS_NAME
!(), "|", IPRE
!(), r
"$");
68 pub PROXMOX_USER_ID_REGEX
= concat
!(r
"^", USER_ID_REGEX_STR
!(), r
"$");
70 pub BACKUP_REPO_URL_REGEX
= concat
!(r
"^^(?:(?:(", USER_ID_REGEX_STR
!(), ")@)?(", DNS_NAME
!(), "|", IPRE
!() ,"):)?(", PROXMOX_SAFE_ID_REGEX_STR
!(), r
")$");
72 pub PROXMOX_GROUP_ID_REGEX
= concat
!(r
"^", GROUP_NAME_REGEX_STR
!(), r
"$");
74 pub CERT_FINGERPRINT_SHA256_REGEX
= r
"^(?:[0-9a-fA-F][0-9a-fA-F])(?::[0-9a-fA-F][0-9a-fA-F]){31}$";
76 pub ACL_PATH_REGEX
= concat
!(r
"^(?:/|", r
"(?:/", PROXMOX_SAFE_ID_REGEX_STR
!(), ")+", r
")$");
79 pub const SYSTEMD_DATETIME_FORMAT
: ApiStringFormat
=
80 ApiStringFormat
::Pattern(&SYSTEMD_DATETIME_REGEX
);
82 pub const IP_V4_FORMAT
: ApiStringFormat
=
83 ApiStringFormat
::Pattern(&IP_V4_REGEX
);
85 pub const IP_V6_FORMAT
: ApiStringFormat
=
86 ApiStringFormat
::Pattern(&IP_V6_REGEX
);
88 pub const IP_FORMAT
: ApiStringFormat
=
89 ApiStringFormat
::Pattern(&IP_REGEX
);
91 pub const PVE_CONFIG_DIGEST_FORMAT
: ApiStringFormat
=
92 ApiStringFormat
::Pattern(&SHA256_HEX_REGEX
);
94 pub const CERT_FINGERPRINT_SHA256_FORMAT
: ApiStringFormat
=
95 ApiStringFormat
::Pattern(&CERT_FINGERPRINT_SHA256_REGEX
);
97 pub const PROXMOX_SAFE_ID_FORMAT
: ApiStringFormat
=
98 ApiStringFormat
::Pattern(&PROXMOX_SAFE_ID_REGEX
);
100 pub const SINGLE_LINE_COMMENT_FORMAT
: ApiStringFormat
=
101 ApiStringFormat
::Pattern(&SINGLE_LINE_COMMENT_REGEX
);
103 pub const HOSTNAME_FORMAT
: ApiStringFormat
=
104 ApiStringFormat
::Pattern(&HOSTNAME_REGEX
);
106 pub const DNS_NAME_FORMAT
: ApiStringFormat
=
107 ApiStringFormat
::Pattern(&DNS_NAME_REGEX
);
109 pub const DNS_NAME_OR_IP_FORMAT
: ApiStringFormat
=
110 ApiStringFormat
::Pattern(&DNS_NAME_OR_IP_REGEX
);
112 pub const PROXMOX_USER_ID_FORMAT
: ApiStringFormat
=
113 ApiStringFormat
::Pattern(&PROXMOX_USER_ID_REGEX
);
115 pub const PROXMOX_GROUP_ID_FORMAT
: ApiStringFormat
=
116 ApiStringFormat
::Pattern(&PROXMOX_GROUP_ID_REGEX
);
118 pub const PASSWORD_FORMAT
: ApiStringFormat
=
119 ApiStringFormat
::Pattern(&PASSWORD_REGEX
);
121 pub const ACL_PATH_FORMAT
: ApiStringFormat
=
122 ApiStringFormat
::Pattern(&ACL_PATH_REGEX
);
124 pub const NETWORK_INTERFACE_FORMAT
: ApiStringFormat
=
125 ApiStringFormat
::Pattern(&PROXMOX_SAFE_ID_REGEX
);
127 pub const CIDR_V4_FORMAT
: ApiStringFormat
=
128 ApiStringFormat
::Pattern(&CIDR_V4_REGEX
);
130 pub const CIDR_V6_FORMAT
: ApiStringFormat
=
131 ApiStringFormat
::Pattern(&CIDR_V6_REGEX
);
133 pub const CIDR_FORMAT
: ApiStringFormat
=
134 ApiStringFormat
::Pattern(&CIDR_REGEX
);
137 pub const PASSWORD_SCHEMA
: Schema
= StringSchema
::new("Password.")
138 .format(&PASSWORD_FORMAT
)
143 pub const PBS_PASSWORD_SCHEMA
: Schema
= StringSchema
::new("User Password.")
144 .format(&PASSWORD_FORMAT
)
149 pub const CERT_FINGERPRINT_SHA256_SCHEMA
: Schema
= StringSchema
::new(
150 "X509 certificate fingerprint (sha256)."
152 .format(&CERT_FINGERPRINT_SHA256_FORMAT
)
155 pub const PROXMOX_CONFIG_DIGEST_SCHEMA
: Schema
= StringSchema
::new(r
#"\
156 Prevent changes if current configuration file has different SHA256 digest.
157 This can be used to prevent concurrent modifications.
160 .format(&PVE_CONFIG_DIGEST_FORMAT
)
164 pub const CHUNK_DIGEST_FORMAT
: ApiStringFormat
=
165 ApiStringFormat
::Pattern(&SHA256_HEX_REGEX
);
167 pub const CHUNK_DIGEST_SCHEMA
: Schema
= StringSchema
::new("Chunk digest (SHA256).")
168 .format(&CHUNK_DIGEST_FORMAT
)
171 pub const NODE_SCHEMA
: Schema
= StringSchema
::new("Node name (or 'localhost')")
172 .format(&ApiStringFormat
::VerifyFn(|node
| {
173 if node
== "localhost" || node
== proxmox
::tools
::nodename() {
176 bail
!("no such node '{}'", node
);
181 pub const SEARCH_DOMAIN_SCHEMA
: Schema
=
182 StringSchema
::new("Search domain for host-name lookup.").schema();
184 pub const FIRST_DNS_SERVER_SCHEMA
: Schema
=
185 StringSchema
::new("First name server IP address.")
189 pub const SECOND_DNS_SERVER_SCHEMA
: Schema
=
190 StringSchema
::new("Second name server IP address.")
194 pub const THIRD_DNS_SERVER_SCHEMA
: Schema
=
195 StringSchema
::new("Third name server IP address.")
199 pub const IP_V4_SCHEMA
: Schema
=
200 StringSchema
::new("IPv4 address.")
201 .format(&IP_V4_FORMAT
)
205 pub const IP_V6_SCHEMA
: Schema
=
206 StringSchema
::new("IPv6 address.")
207 .format(&IP_V6_FORMAT
)
211 pub const IP_SCHEMA
: Schema
=
212 StringSchema
::new("IP (IPv4 or IPv6) address.")
217 pub const CIDR_V4_SCHEMA
: Schema
=
218 StringSchema
::new("IPv4 address with netmask (CIDR notation).")
219 .format(&CIDR_V4_FORMAT
)
223 pub const CIDR_V6_SCHEMA
: Schema
=
224 StringSchema
::new("IPv6 address with netmask (CIDR notation).")
225 .format(&CIDR_V6_FORMAT
)
229 pub const CIDR_SCHEMA
: Schema
=
230 StringSchema
::new("IP address (IPv4 or IPv6) with netmask (CIDR notation).")
231 .format(&CIDR_FORMAT
)
235 pub const TIME_ZONE_SCHEMA
: Schema
= StringSchema
::new(
236 "Time zone. The file '/usr/share/zoneinfo/zone.tab' contains the list of valid names.")
237 .format(&SINGLE_LINE_COMMENT_FORMAT
)
242 pub const ACL_PATH_SCHEMA
: Schema
= StringSchema
::new(
243 "Access control path.")
244 .format(&ACL_PATH_FORMAT
)
249 pub const ACL_PROPAGATE_SCHEMA
: Schema
= BooleanSchema
::new(
250 "Allow to propagate (inherit) permissions.")
254 pub const ACL_UGID_TYPE_SCHEMA
: Schema
= StringSchema
::new(
255 "Type of 'ugid' property.")
256 .format(&ApiStringFormat
::Enum(&[
257 EnumEntry
::new("user", "User"),
258 EnumEntry
::new("group", "Group")]))
261 pub const BACKUP_ARCHIVE_NAME_SCHEMA
: Schema
=
262 StringSchema
::new("Backup archive name.")
263 .format(&PROXMOX_SAFE_ID_FORMAT
)
266 pub const BACKUP_TYPE_SCHEMA
: Schema
=
267 StringSchema
::new("Backup type.")
268 .format(&ApiStringFormat
::Enum(&[
269 EnumEntry
::new("vm", "Virtual Machine Backup"),
270 EnumEntry
::new("ct", "Container Backup"),
271 EnumEntry
::new("host", "Host Backup")]))
274 pub const BACKUP_ID_SCHEMA
: Schema
=
275 StringSchema
::new("Backup ID.")
276 .format(&PROXMOX_SAFE_ID_FORMAT
)
279 pub const BACKUP_TIME_SCHEMA
: Schema
=
280 IntegerSchema
::new("Backup time (Unix epoch.)")
281 .minimum(1_547_797_308)
284 pub const UPID_SCHEMA
: Schema
= StringSchema
::new("Unique Process/Task ID.")
288 pub const DATASTORE_SCHEMA
: Schema
= StringSchema
::new("Datastore name.")
289 .format(&PROXMOX_SAFE_ID_FORMAT
)
294 pub const SYNC_SCHEDULE_SCHEMA
: Schema
= StringSchema
::new(
295 "Run sync job at specified schedule.")
296 .format(&ApiStringFormat
::VerifyFn(crate::tools
::systemd
::time
::verify_calendar_event
))
299 pub const GC_SCHEDULE_SCHEMA
: Schema
= StringSchema
::new(
300 "Run garbage collection job at specified schedule.")
301 .format(&ApiStringFormat
::VerifyFn(crate::tools
::systemd
::time
::verify_calendar_event
))
304 pub const PRUNE_SCHEDULE_SCHEMA
: Schema
= StringSchema
::new(
305 "Run prune job at specified schedule.")
306 .format(&ApiStringFormat
::VerifyFn(crate::tools
::systemd
::time
::verify_calendar_event
))
309 pub const REMOTE_ID_SCHEMA
: Schema
= StringSchema
::new("Remote ID.")
310 .format(&PROXMOX_SAFE_ID_FORMAT
)
315 pub const JOB_ID_SCHEMA
: Schema
= StringSchema
::new("Job ID.")
316 .format(&PROXMOX_SAFE_ID_FORMAT
)
321 pub const REMOVE_VANISHED_BACKUPS_SCHEMA
: Schema
= BooleanSchema
::new(
322 "Delete vanished backups. This remove the local copy if the remote backup was deleted.")
326 pub const SINGLE_LINE_COMMENT_SCHEMA
: Schema
= StringSchema
::new("Comment (single line).")
327 .format(&SINGLE_LINE_COMMENT_FORMAT
)
330 pub const HOSTNAME_SCHEMA
: Schema
= StringSchema
::new("Hostname (as defined in RFC1123).")
331 .format(&HOSTNAME_FORMAT
)
334 pub const DNS_NAME_OR_IP_SCHEMA
: Schema
= StringSchema
::new("DNS name or IP address.")
335 .format(&DNS_NAME_OR_IP_FORMAT
)
338 pub const PROXMOX_AUTH_REALM_SCHEMA
: Schema
= StringSchema
::new("Authentication domain ID")
339 .format(&PROXMOX_SAFE_ID_FORMAT
)
344 pub const PROXMOX_USER_ID_SCHEMA
: Schema
= StringSchema
::new("User ID")
345 .format(&PROXMOX_USER_ID_FORMAT
)
350 pub const PROXMOX_GROUP_ID_SCHEMA
: Schema
= StringSchema
::new("Group ID")
351 .format(&PROXMOX_GROUP_ID_FORMAT
)
357 // Complex type definitions
362 schema
: BACKUP_TYPE_SCHEMA
,
365 schema
: BACKUP_ID_SCHEMA
,
368 schema
: BACKUP_TIME_SCHEMA
,
375 schema
: BACKUP_ARCHIVE_NAME_SCHEMA
380 #[derive(Serialize, Deserialize)]
381 #[serde(rename_all="kebab-case")]
382 /// Basic information about a backup group.
383 pub struct GroupListItem
{
384 pub backup_type
: String
, // enum
385 pub backup_id
: String
,
386 pub last_backup
: i64,
387 /// Number of contained snapshots
388 pub backup_count
: u64,
389 /// List of contained archive files.
390 pub files
: Vec
<String
>,
391 /// The owner of group
392 #[serde(skip_serializing_if="Option::is_none")]
393 pub owner
: Option
<String
>,
399 schema
: BACKUP_TYPE_SCHEMA
,
402 schema
: BACKUP_ID_SCHEMA
,
405 schema
: BACKUP_TIME_SCHEMA
,
409 schema
: BACKUP_ARCHIVE_NAME_SCHEMA
414 #[derive(Serialize, Deserialize)]
415 #[serde(rename_all="kebab-case")]
416 /// Basic information about backup snapshot.
417 pub struct SnapshotListItem
{
418 pub backup_type
: String
, // enum
419 pub backup_id
: String
,
420 pub backup_time
: i64,
421 /// List of contained archive files.
422 pub files
: Vec
<String
>,
423 /// Overall snapshot size (sum of all archive sizes).
424 #[serde(skip_serializing_if="Option::is_none")]
425 pub size
: Option
<u64>,
426 /// The owner of the snapshots group
427 #[serde(skip_serializing_if="Option::is_none")]
428 pub owner
: Option
<String
>,
434 schema
: BACKUP_TYPE_SCHEMA
,
437 schema
: BACKUP_ID_SCHEMA
,
440 schema
: BACKUP_TIME_SCHEMA
,
444 #[derive(Serialize, Deserialize)]
445 #[serde(rename_all="kebab-case")]
447 pub struct PruneListItem
{
448 pub backup_type
: String
, // enum
449 pub backup_id
: String
,
450 pub backup_time
: i64,
455 pub const PRUNE_SCHEMA_KEEP_DAILY
: Schema
= IntegerSchema
::new(
456 "Number of daily backups to keep.")
460 pub const PRUNE_SCHEMA_KEEP_HOURLY
: Schema
= IntegerSchema
::new(
461 "Number of hourly backups to keep.")
465 pub const PRUNE_SCHEMA_KEEP_LAST
: Schema
= IntegerSchema
::new(
466 "Number of backups to keep.")
470 pub const PRUNE_SCHEMA_KEEP_MONTHLY
: Schema
= IntegerSchema
::new(
471 "Number of monthly backups to keep.")
475 pub const PRUNE_SCHEMA_KEEP_WEEKLY
: Schema
= IntegerSchema
::new(
476 "Number of weekly backups to keep.")
480 pub const PRUNE_SCHEMA_KEEP_YEARLY
: Schema
= IntegerSchema
::new(
481 "Number of yearly backups to keep.")
488 schema
: BACKUP_ARCHIVE_NAME_SCHEMA
,
492 #[derive(Serialize, Deserialize)]
493 #[serde(rename_all="kebab-case")]
494 /// Basic information about archive files inside a backup snapshot.
495 pub struct BackupContent
{
496 pub filename
: String
,
497 /// Archive size (from backup manifest).
498 #[serde(skip_serializing_if="Option::is_none")]
499 pub size
: Option
<u64>,
510 #[derive(Clone, Serialize, Deserialize)]
511 #[serde(rename_all="kebab-case")]
512 /// Garbage collection status.
513 pub struct GarbageCollectionStatus
{
514 pub upid
: Option
<String
>,
515 /// Number of processed index files.
516 pub index_file_count
: usize,
517 /// Sum of bytes referred by index files.
518 pub index_data_bytes
: u64,
519 /// Bytes used on disk.
521 /// Chunks used on disk.
522 pub disk_chunks
: usize,
523 /// Sum of removed bytes.
524 pub removed_bytes
: u64,
525 /// Number of removed chunks.
526 pub removed_chunks
: usize,
527 /// Sum of pending bytes (pending removal - kept for safety).
528 pub pending_bytes
: u64,
529 /// Number of pending chunks (pending removal - kept for safety).
530 pub pending_chunks
: usize,
533 impl Default
for GarbageCollectionStatus
{
534 fn default() -> Self {
535 GarbageCollectionStatus
{
551 #[derive(Serialize, Deserialize)]
552 /// Storage space usage information.
553 pub struct StorageStatus
{
554 /// Total space (bytes).
556 /// Used space (bytes).
558 /// Available space (bytes).
564 "upid": { schema: UPID_SCHEMA }
,
567 #[derive(Serialize, Deserialize)]
569 pub struct TaskListItem
{
571 /// The node name where the task is running on.
575 /// The task start time (Epoch)
577 /// The task start time (Epoch)
579 /// Worker type (arbitrary ASCII string)
580 pub worker_type
: String
,
581 /// Worker ID (arbitrary ASCII string)
582 pub worker_id
: Option
<String
>,
583 /// The user who started the task
585 /// The task end time (Epoch)
586 #[serde(skip_serializing_if="Option::is_none")]
587 pub endtime
: Option
<i64>,
589 #[serde(skip_serializing_if="Option::is_none")]
590 pub status
: Option
<String
>,
594 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
595 #[serde(rename_all = "lowercase")]
596 /// Node Power command type.
597 pub enum NodePowerCommand
{
598 /// Restart the server
600 /// Shutdown the server
605 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
606 #[serde(rename_all = "lowercase")]
607 /// Interface configuration method
608 pub enum NetworkConfigMethod
{
609 /// Configuration is done manually using other tools
611 /// Define interfaces with statically allocated addresses.
613 /// Obtain an address via DHCP
615 /// Define the loopback interface.
620 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
621 #[serde(rename_all = "kebab-case")]
622 #[allow(non_camel_case_types)]
625 pub enum LinuxBondMode
{
626 /// Round-robin policy
628 /// Active-backup policy
634 /// IEEE 802.3ad Dynamic link aggregation
635 //#[serde(rename = "802.3ad")]
637 /// Adaptive transmit load balancing
639 /// Adaptive load balancing
644 #[derive(Debug, Copy, Clone, PartialEq, Serialize, Deserialize)]
645 #[serde(rename_all = "lowercase")]
646 /// Network interface type
647 pub enum NetworkInterfaceType
{
650 /// Physical Ethernet device
656 /// Linux VLAN (eth.10)
658 /// Interface Alias (eth:1)
660 /// Unknown interface type
664 pub const NETWORK_INTERFACE_NAME_SCHEMA
: Schema
= StringSchema
::new("Network interface name.")
665 .format(&NETWORK_INTERFACE_FORMAT
)
667 .max_length(libc
::IFNAMSIZ
-1)
670 pub const NETWORK_INTERFACE_ARRAY_SCHEMA
: Schema
= ArraySchema
::new(
671 "Network interface list.", &NETWORK_INTERFACE_NAME_SCHEMA
)
674 pub const NETWORK_INTERFACE_LIST_SCHEMA
: Schema
= StringSchema
::new(
675 "A list of network devices, comma separated.")
676 .format(&ApiStringFormat
::PropertyString(&NETWORK_INTERFACE_ARRAY_SCHEMA
))
682 schema
: NETWORK_INTERFACE_NAME_SCHEMA
,
685 type: NetworkInterfaceType
,
688 type: NetworkConfigMethod
,
692 type: NetworkConfigMethod
,
696 schema
: CIDR_V4_SCHEMA
,
700 schema
: CIDR_V6_SCHEMA
,
704 schema
: IP_V4_SCHEMA
,
708 schema
: IP_V6_SCHEMA
,
712 description
: "Option list (inet)",
715 description
: "Optional attribute line.",
720 description
: "Option list (inet6)",
723 description
: "Optional attribute line.",
728 description
: "Comments (inet, may span multiple lines)",
733 description
: "Comments (inet6, may span multiple lines)",
738 schema
: NETWORK_INTERFACE_ARRAY_SCHEMA
,
742 schema
: NETWORK_INTERFACE_ARRAY_SCHEMA
,
751 #[derive(Debug, Serialize, Deserialize)]
752 /// Network Interface configuration
753 pub struct Interface
{
754 /// Autostart interface
755 #[serde(rename = "autostart")]
757 /// Interface is active (UP)
762 #[serde(rename = "type")]
763 pub interface_type
: NetworkInterfaceType
,
764 #[serde(skip_serializing_if="Option::is_none")]
765 pub method
: Option
<NetworkConfigMethod
>,
766 #[serde(skip_serializing_if="Option::is_none")]
767 pub method6
: Option
<NetworkConfigMethod
>,
768 #[serde(skip_serializing_if="Option::is_none")]
769 /// IPv4 address with netmask
770 pub cidr
: Option
<String
>,
771 #[serde(skip_serializing_if="Option::is_none")]
773 pub gateway
: Option
<String
>,
774 #[serde(skip_serializing_if="Option::is_none")]
775 /// IPv6 address with netmask
776 pub cidr6
: Option
<String
>,
777 #[serde(skip_serializing_if="Option::is_none")]
779 pub gateway6
: Option
<String
>,
781 #[serde(skip_serializing_if="Vec::is_empty")]
782 pub options
: Vec
<String
>,
783 #[serde(skip_serializing_if="Vec::is_empty")]
784 pub options6
: Vec
<String
>,
786 #[serde(skip_serializing_if="Option::is_none")]
787 pub comments
: Option
<String
>,
788 #[serde(skip_serializing_if="Option::is_none")]
789 pub comments6
: Option
<String
>,
791 #[serde(skip_serializing_if="Option::is_none")]
792 /// Maximum Transmission Unit
793 pub mtu
: Option
<u64>,
795 #[serde(skip_serializing_if="Option::is_none")]
796 pub bridge_ports
: Option
<Vec
<String
>>,
797 /// Enable bridge vlan support.
798 #[serde(skip_serializing_if="Option::is_none")]
799 pub bridge_vlan_aware
: Option
<bool
>,
801 #[serde(skip_serializing_if="Option::is_none")]
802 pub slaves
: Option
<Vec
<String
>>,
803 #[serde(skip_serializing_if="Option::is_none")]
804 pub bond_mode
: Option
<LinuxBondMode
>,
810 fn test_cert_fingerprint_schema() -> Result
<(), anyhow
::Error
> {
812 let schema
= CERT_FINGERPRINT_SHA256_SCHEMA
;
814 let invalid_fingerprints
= [
815 "86:88:7c:be:26:77:a5:62:67:d9:06:f5:e4::61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8",
816 "88:7C:BE:26:77:a5:62:67:D9:06:f5:e4:14:61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8",
817 "86:88:7c:be:26:77:a5:62:67:d9:06:f5:e4::14:61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8:ff",
818 "XX:88:7c:be:26:77:a5:62:67:d9:06:f5:e4::14:61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8",
819 "86:88:Y4:be:26:77:a5:62:67:d9:06:f5:e4:14:61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8",
820 "86:88:0:be:26:77:a5:62:67:d9:06:f5:e4:14:61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8",
823 for fingerprint
in invalid_fingerprints
.iter() {
824 if let Ok(_
) = parse_simple_value(fingerprint
, &schema
) {
825 bail
!("test fingerprint '{}' failed - got Ok() while exception an error.", fingerprint
);
829 let valid_fingerprints
= [
830 "86:88:7c:be:26:77:a5:62:67:d9:06:f5:e4:14:61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8",
831 "86:88:7C:BE:26:77:a5:62:67:D9:06:f5:e4:14:61:3e:20:dc:cd:43:92:07:7f:fb:65:54:6c:ff:d2:96:36:f8",
834 for fingerprint
in valid_fingerprints
.iter() {
835 let v
= match parse_simple_value(fingerprint
, &schema
) {
838 bail
!("unable to parse fingerprint '{}' - {}", fingerprint
, err
);
842 if v
!= serde_json
::json
!(fingerprint
) {
843 bail
!("unable to parse fingerprint '{}' - got wrong value {:?}", fingerprint
, v
);
851 fn test_proxmox_user_id_schema() -> Result
<(), anyhow
::Error
> {
853 let schema
= PROXMOX_USER_ID_SCHEMA
;
855 let invalid_user_ids
= [
860 "xx x@test", // contains space
861 "xx\nx@test", // contains control character
862 "x:xx@test", // contains collon
863 "xx/x@test", // contains slash
864 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx@test", // too long
867 for name
in invalid_user_ids
.iter() {
868 if let Ok(_
) = parse_simple_value(name
, &schema
) {
869 bail
!("test userid '{}' failed - got Ok() while exception an error.", name
);
873 let valid_user_ids
= [
877 "xxx@_T_E_S_T-it.com",
878 "x_x-x.x@test-it.com",
881 for name
in valid_user_ids
.iter() {
882 let v
= match parse_simple_value(name
, &schema
) {
885 bail
!("unable to parse userid '{}' - {}", name
, err
);
889 if v
!= serde_json
::json
!(name
) {
890 bail
!("unable to parse userid '{}' - got wrong value {:?}", name
, v
);
898 #[derive(Copy, Clone, Serialize, Deserialize)]
899 #[serde(rename_all = "UPPERCASE")]
910 #[derive(Copy, Clone, Serialize, Deserialize)]
911 #[serde(rename_all = "lowercase")]
912 pub enum RRDTimeFrameResolution
{
913 /// 1 min => last 70 minutes
915 /// 30 min => last 35 hours
917 /// 3 hours => about 8 days
919 /// 12 hours => last 35 days
921 /// 1 week => last 490 days